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 22 matching lines...) Expand all Loading... |
33 #include "chrome/common/extensions/user_script.h" | 33 #include "chrome/common/extensions/user_script.h" |
34 #include "chrome/common/jstemplate_builder.h" | 34 #include "chrome/common/jstemplate_builder.h" |
35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
36 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
37 #include "content/browser/debugger/devtools_window.h" | 37 #include "content/browser/debugger/devtools_window.h" |
38 #include "content/browser/renderer_host/render_process_host.h" | 38 #include "content/browser/renderer_host/render_process_host.h" |
39 #include "content/browser/renderer_host/render_view_host.h" | 39 #include "content/browser/renderer_host/render_view_host.h" |
40 #include "content/browser/renderer_host/render_widget_host.h" | 40 #include "content/browser/renderer_host/render_widget_host.h" |
41 #include "content/browser/tab_contents/tab_contents.h" | 41 #include "content/browser/tab_contents/tab_contents.h" |
42 #include "content/browser/tab_contents/tab_contents_view.h" | 42 #include "content/browser/tab_contents/tab_contents_view.h" |
| 43 #include "content/common/content_notification_types.h" |
43 #include "content/common/notification_service.h" | 44 #include "content/common/notification_service.h" |
44 #include "content/common/notification_type.h" | |
45 #include "grit/browser_resources.h" | 45 #include "grit/browser_resources.h" |
46 #include "grit/chromium_strings.h" | 46 #include "grit/chromium_strings.h" |
47 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
48 #include "grit/theme_resources.h" | 48 #include "grit/theme_resources.h" |
49 #include "net/base/net_util.h" | 49 #include "net/base/net_util.h" |
50 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
51 #include "ui/base/resource/resource_bundle.h" | 51 #include "ui/base/resource/resource_bundle.h" |
52 #include "ui/gfx/codec/png_codec.h" | 52 #include "ui/gfx/codec/png_codec.h" |
53 #include "ui/gfx/color_utils.h" | 53 #include "ui/gfx/color_utils.h" |
54 #include "ui/gfx/skbitmap_operations.h" | 54 #include "ui/gfx/skbitmap_operations.h" |
(...skipping 335 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 ListValue results; | 703 ListValue results; |
704 results.Append(Value::CreateStringValue(path.value())); | 704 results.Append(Value::CreateStringValue(path.value())); |
705 web_ui_->CallJavascriptFunction(L"window.handleFilePathSelected", results); | 705 web_ui_->CallJavascriptFunction(L"window.handleFilePathSelected", results); |
706 } | 706 } |
707 | 707 |
708 void ExtensionsDOMHandler::MultiFilesSelected( | 708 void ExtensionsDOMHandler::MultiFilesSelected( |
709 const std::vector<FilePath>& files, void* params) { | 709 const std::vector<FilePath>& files, void* params) { |
710 NOTREACHED(); | 710 NOTREACHED(); |
711 } | 711 } |
712 | 712 |
713 void ExtensionsDOMHandler::Observe(NotificationType type, | 713 void ExtensionsDOMHandler::Observe(int type, |
714 const NotificationSource& source, | 714 const NotificationSource& source, |
715 const NotificationDetails& details) { | 715 const NotificationDetails& details) { |
716 switch (type.value) { | 716 switch (type) { |
717 // We listen for notifications that will result in the page being | 717 // We listen for notifications that will result in the page being |
718 // repopulated with data twice for the same event in certain cases. | 718 // repopulated with data twice for the same event in certain cases. |
719 // For instance, EXTENSION_LOADED & EXTENSION_PROCESS_CREATED because | 719 // For instance, EXTENSION_LOADED & EXTENSION_PROCESS_CREATED because |
720 // we don't know about the views for an extension at EXTENSION_LOADED, but | 720 // we don't know about the views for an extension at EXTENSION_LOADED, but |
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 |