Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: chrome/browser/extensions/extensions_ui.cc

Issue 1075006: Eliminate all UI thread decoding of extension images.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extensions_ui.h" 5 #include "chrome/browser/extensions/extensions_ui.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 std::map<int, std::string>::const_iterator iter = 365 std::map<int, std::string>::const_iterator iter =
366 icons.find(Extension::EXTENSION_ICON_MEDIUM); 366 icons.find(Extension::EXTENSION_ICON_MEDIUM);
367 if (iter == icons.end()) 367 if (iter == icons.end())
368 iter = icons.find(Extension::EXTENSION_ICON_LARGE); 368 iter = icons.find(Extension::EXTENSION_ICON_LARGE);
369 if (iter != icons.end()) 369 if (iter != icons.end())
370 return extension->GetResource(iter->second); 370 return extension->GetResource(iter->second);
371 else 371 else
372 return ExtensionResource(); 372 return ExtensionResource();
373 } 373 }
374 374
375 ExtensionInstallUI* ExtensionsDOMHandler::GetExtensionInstallUI() {
376 if (!install_ui_.get())
377 install_ui_.reset(new ExtensionInstallUI(dom_ui_->GetProfile()));
378 return install_ui_.get();
379 }
380
375 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const Value* value) { 381 void ExtensionsDOMHandler::HandleToggleDeveloperMode(const Value* value) {
376 bool developer_mode = dom_ui_->GetProfile()->GetPrefs() 382 bool developer_mode = dom_ui_->GetProfile()->GetPrefs()
377 ->GetBoolean(prefs::kExtensionsUIDeveloperMode); 383 ->GetBoolean(prefs::kExtensionsUIDeveloperMode);
378 dom_ui_->GetProfile()->GetPrefs()->SetBoolean( 384 dom_ui_->GetProfile()->GetPrefs()->SetBoolean(
379 prefs::kExtensionsUIDeveloperMode, !developer_mode); 385 prefs::kExtensionsUIDeveloperMode, !developer_mode);
380 } 386 }
381 387
382 void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) { 388 void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) {
383 std::string render_process_id_str; 389 std::string render_process_id_str;
384 std::string render_view_id_str; 390 std::string render_view_id_str;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 CHECK(list->GetString(1, &enable_str)); 447 CHECK(list->GetString(1, &enable_str));
442 Extension* extension = extensions_service_->GetExtensionById(extension_id, 448 Extension* extension = extensions_service_->GetExtensionById(extension_id,
443 true); 449 true);
444 DCHECK(extension); 450 DCHECK(extension);
445 451
446 if (enable_str == "true") { 452 if (enable_str == "true") {
447 if (!extension_id_prompting_.empty()) 453 if (!extension_id_prompting_.empty())
448 return; // only one prompt at a time 454 return; // only one prompt at a time
449 455
450 // Prompt the user first. 456 // Prompt the user first.
451 scoped_ptr<SkBitmap> icon;
452 Extension::DecodeIcon(extension, Extension::EXTENSION_ICON_LARGE, &icon);
453
454 ui_prompt_type_ = ExtensionInstallUI::ENABLE_INCOGNITO_PROMPT; 457 ui_prompt_type_ = ExtensionInstallUI::ENABLE_INCOGNITO_PROMPT;
455 extension_id_prompting_ = extension_id; 458 extension_id_prompting_ = extension_id;
456 ExtensionInstallUI client(dom_ui_->GetProfile()); 459
457 client.ConfirmEnableIncognito(this, extension, icon.get()); 460 GetExtensionInstallUI()->ConfirmEnableIncognito(this, extension);
458 } else { 461 } else {
459 extensions_service_->SetIsIncognitoEnabled(extension, false); 462 extensions_service_->SetIsIncognitoEnabled(extension, false);
460 } 463 }
461 } 464 }
462 465
463 void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { 466 void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) {
464 CHECK(value->IsType(Value::TYPE_LIST)); 467 CHECK(value->IsType(Value::TYPE_LIST));
465 const ListValue* list = static_cast<const ListValue*>(value); 468 const ListValue* list = static_cast<const ListValue*>(value);
466 CHECK(list->GetSize() == 1); 469 CHECK(list->GetSize() == 1);
467 std::string extension_id; 470 std::string extension_id;
468 CHECK(list->GetString(0, &extension_id)); 471 CHECK(list->GetString(0, &extension_id));
469 472
470 Extension *extension = 473 Extension *extension =
471 extensions_service_->GetExtensionById(extension_id, true); 474 extensions_service_->GetExtensionById(extension_id, true);
472 if (!extension) 475 if (!extension)
473 return; 476 return;
474 477
475 if (!extension_id_prompting_.empty()) 478 if (!extension_id_prompting_.empty())
476 return; // only one prompt at a time 479 return; // only one prompt at a time
477 480
478 scoped_ptr<SkBitmap> uninstall_icon;
479 Extension::DecodeIcon(extension, Extension::EXTENSION_ICON_LARGE,
480 &uninstall_icon);
481
482 ui_prompt_type_ = ExtensionInstallUI::UNINSTALL_PROMPT; 481 ui_prompt_type_ = ExtensionInstallUI::UNINSTALL_PROMPT;
483 extension_id_prompting_ = extension_id; 482 extension_id_prompting_ = extension_id;
484 ExtensionInstallUI client(dom_ui_->GetProfile()); 483
485 client.ConfirmUninstall(this, extension, uninstall_icon.get()); 484 GetExtensionInstallUI()->ConfirmUninstall(this, extension);
486 } 485 }
487 486
488 void ExtensionsDOMHandler::InstallUIProceed(bool create_app_shortcut) { 487 void ExtensionsDOMHandler::InstallUIProceed(bool create_app_shortcut) {
489 // We only ever use ExtensionInstallUI for uninstalling, which should never 488 // We only ever use ExtensionInstallUI for uninstalling, which should never
490 // result in it telling us to create a shortcut. 489 // result in it telling us to create a shortcut.
491 DCHECK(!create_app_shortcut); 490 DCHECK(!create_app_shortcut);
492 491
493 // The extension can be uninstalled in another window while the UI was 492 // The extension can be uninstalled in another window while the UI was
494 // showing. Do nothing in that case. 493 // showing. Do nothing in that case.
495 Extension* extension = 494 Extension* extension =
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 // static 852 // static
854 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() { 853 RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes() {
855 return ResourceBundle::GetSharedInstance(). 854 return ResourceBundle::GetSharedInstance().
856 LoadDataResourceBytes(IDR_PLUGIN); 855 LoadDataResourceBytes(IDR_PLUGIN);
857 } 856 }
858 857
859 // static 858 // static
860 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { 859 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) {
861 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false); 860 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, false);
862 } 861 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698