OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 icon_loader_ = new IconLoader(this); | 390 icon_loader_ = new IconLoader(this); |
391 icon_loader_->LoadIcons(extension_icons, results); | 391 icon_loader_->LoadIcons(extension_icons, results); |
392 } | 392 } |
393 | 393 |
394 void ExtensionsDOMHandler::OnIconsLoaded(DictionaryValue* json) { | 394 void ExtensionsDOMHandler::OnIconsLoaded(DictionaryValue* json) { |
395 web_ui_->CallJavascriptFunction(L"returnExtensionsData", *json); | 395 web_ui_->CallJavascriptFunction(L"returnExtensionsData", *json); |
396 delete json; | 396 delete json; |
397 | 397 |
398 // Register for notifications that we need to reload the page. | 398 // Register for notifications that we need to reload the page. |
399 registrar_.RemoveAll(); | 399 registrar_.RemoveAll(); |
400 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 400 registrar_.Add(this, chrome::EXTENSION_LOADED, |
401 NotificationService::AllSources()); | 401 NotificationService::AllSources()); |
402 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CREATED, | 402 registrar_.Add(this, chrome::EXTENSION_PROCESS_CREATED, |
403 NotificationService::AllSources()); | 403 NotificationService::AllSources()); |
404 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 404 registrar_.Add(this, chrome::EXTENSION_UNLOADED, |
405 NotificationService::AllSources()); | 405 NotificationService::AllSources()); |
406 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 406 registrar_.Add(this, chrome::EXTENSION_UPDATE_DISABLED, |
407 NotificationService::AllSources()); | 407 NotificationService::AllSources()); |
408 registrar_.Add(this, | 408 registrar_.Add(this, |
409 NotificationType::NAV_ENTRY_COMMITTED, | 409 chrome::NAV_ENTRY_COMMITTED, |
410 NotificationService::AllSources()); | 410 NotificationService::AllSources()); |
411 registrar_.Add(this, | 411 registrar_.Add(this, |
412 NotificationType::RENDER_VIEW_HOST_CREATED, | 412 chrome::RENDER_VIEW_HOST_CREATED, |
413 NotificationService::AllSources()); | 413 NotificationService::AllSources()); |
414 registrar_.Add(this, | 414 registrar_.Add(this, |
415 NotificationType::RENDER_VIEW_HOST_DELETED, | 415 chrome::RENDER_VIEW_HOST_DELETED, |
416 NotificationService::AllSources()); | 416 NotificationService::AllSources()); |
417 registrar_.Add(this, | 417 registrar_.Add(this, |
418 NotificationType::BACKGROUND_CONTENTS_NAVIGATED, | 418 chrome::BACKGROUND_CONTENTS_NAVIGATED, |
419 NotificationService::AllSources()); | 419 NotificationService::AllSources()); |
420 registrar_.Add(this, | 420 registrar_.Add(this, |
421 NotificationType::BACKGROUND_CONTENTS_DELETED, | 421 chrome::BACKGROUND_CONTENTS_DELETED, |
422 NotificationService::AllSources()); | 422 NotificationService::AllSources()); |
423 registrar_.Add(this, | 423 registrar_.Add(this, |
424 NotificationType::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 424 chrome::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
425 NotificationService::AllSources()); | 425 NotificationService::AllSources()); |
426 } | 426 } |
427 | 427 |
428 ExtensionResource ExtensionsDOMHandler::PickExtensionIcon( | 428 ExtensionResource ExtensionsDOMHandler::PickExtensionIcon( |
429 const Extension* extension) { | 429 const Extension* extension) { |
430 return extension->GetIconResource(Extension::EXTENSION_ICON_MEDIUM, | 430 return extension->GetIconResource(Extension::EXTENSION_ICON_MEDIUM, |
431 ExtensionIconSet::MATCH_BIGGER); | 431 ExtensionIconSet::MATCH_BIGGER); |
432 } | 432 } |
433 | 433 |
434 ExtensionUninstallDialog* ExtensionsDOMHandler::GetExtensionUninstallDialog() { | 434 ExtensionUninstallDialog* ExtensionsDOMHandler::GetExtensionUninstallDialog() { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 // if we only listen to EXTENSION_PROCESS_CREATED, we'll miss extensions | 721 // if we only listen to EXTENSION_PROCESS_CREATED, we'll miss extensions |
722 // that don't have a process at startup. Similarly, NAV_ENTRY_COMMITTED & | 722 // that don't have a process at startup. Similarly, NAV_ENTRY_COMMITTED & |
723 // RENDER_VIEW_HOST_CREATED because we want to handle both | 723 // RENDER_VIEW_HOST_CREATED because we want to handle both |
724 // the case of navigating from a non-extension page to an extension page in | 724 // the case of navigating from a non-extension page to an extension page in |
725 // a TabContents (which will generate NAV_ENTRY_COMMITTED) as well as | 725 // a TabContents (which will generate NAV_ENTRY_COMMITTED) as well as |
726 // extension content being shown in popups and balloons (which will generate | 726 // extension content being shown in popups and balloons (which will generate |
727 // RENDER_VIEW_CREATED but no NAV_ENTRY_COMMITTED). | 727 // RENDER_VIEW_CREATED but no NAV_ENTRY_COMMITTED). |
728 // | 728 // |
729 // Doing it this way gets everything but causes the page to be rendered | 729 // Doing it this way gets everything but causes the page to be rendered |
730 // more than we need. It doesn't seem to result in any noticeable flicker. | 730 // more than we need. It doesn't seem to result in any noticeable flicker. |
731 case NotificationType::RENDER_VIEW_HOST_DELETED: | 731 case chrome::RENDER_VIEW_HOST_DELETED: |
732 deleting_rvh_ = Details<RenderViewHost>(details).ptr(); | 732 deleting_rvh_ = Details<RenderViewHost>(details).ptr(); |
733 MaybeUpdateAfterNotification(); | 733 MaybeUpdateAfterNotification(); |
734 break; | 734 break; |
735 case NotificationType::BACKGROUND_CONTENTS_DELETED: | 735 case chrome::BACKGROUND_CONTENTS_DELETED: |
736 deleting_rvh_ = Details<BackgroundContents>(details)->render_view_host(); | 736 deleting_rvh_ = Details<BackgroundContents>(details)->render_view_host(); |
737 MaybeUpdateAfterNotification(); | 737 MaybeUpdateAfterNotification(); |
738 break; | 738 break; |
739 case NotificationType::EXTENSION_LOADED: | 739 case chrome::EXTENSION_LOADED: |
740 case NotificationType::EXTENSION_PROCESS_CREATED: | 740 case chrome::EXTENSION_PROCESS_CREATED: |
741 case NotificationType::EXTENSION_UNLOADED: | 741 case chrome::EXTENSION_UNLOADED: |
742 case NotificationType::EXTENSION_UPDATE_DISABLED: | 742 case chrome::EXTENSION_UPDATE_DISABLED: |
743 case NotificationType::RENDER_VIEW_HOST_CREATED: | 743 case chrome::RENDER_VIEW_HOST_CREATED: |
744 case NotificationType::NAV_ENTRY_COMMITTED: | 744 case chrome::NAV_ENTRY_COMMITTED: |
745 case NotificationType::BACKGROUND_CONTENTS_NAVIGATED: | 745 case chrome::BACKGROUND_CONTENTS_NAVIGATED: |
746 case NotificationType::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: | 746 case chrome::EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
747 MaybeUpdateAfterNotification(); | 747 MaybeUpdateAfterNotification(); |
748 break; | 748 break; |
749 default: | 749 default: |
750 NOTREACHED(); | 750 NOTREACHED(); |
751 } | 751 } |
752 } | 752 } |
753 | 753 |
754 const Extension* ExtensionsDOMHandler::GetExtension(const ListValue* args) { | 754 const Extension* ExtensionsDOMHandler::GetExtension(const ListValue* args) { |
755 std::string extension_id = WideToASCII(ExtractStringValue(args)); | 755 std::string extension_id = WideToASCII(ExtractStringValue(args)); |
756 CHECK(!extension_id.empty()); | 756 CHECK(!extension_id.empty()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 return ResourceBundle::GetSharedInstance(). | 914 return ResourceBundle::GetSharedInstance(). |
915 LoadDataResourceBytes(IDR_PLUGIN); | 915 LoadDataResourceBytes(IDR_PLUGIN); |
916 } | 916 } |
917 | 917 |
918 // static | 918 // static |
919 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { | 919 void ExtensionsUI::RegisterUserPrefs(PrefService* prefs) { |
920 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, | 920 prefs->RegisterBooleanPref(prefs::kExtensionsUIDeveloperMode, |
921 false, | 921 false, |
922 PrefService::SYNCABLE_PREF); | 922 PrefService::SYNCABLE_PREF); |
923 } | 923 } |
OLD | NEW |