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/ui/webui/options/extension_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/extension_settings_handler.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 Source<Profile>(profile)); | 208 Source<Profile>(profile)); |
209 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, | 209 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, |
210 Source<Profile>(profile)); | 210 Source<Profile>(profile)); |
211 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 211 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
212 Source<Profile>(profile)); | 212 Source<Profile>(profile)); |
213 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 213 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
214 Source<Profile>(profile)); | 214 Source<Profile>(profile)); |
215 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED, | 215 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED, |
216 Source<Profile>(profile)); | 216 Source<Profile>(profile)); |
217 registrar_.Add(this, | 217 registrar_.Add(this, |
218 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
219 NotificationService::AllBrowserContextsAndSources()); | |
220 registrar_.Add(this, | |
221 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, | 218 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, |
222 NotificationService::AllBrowserContextsAndSources()); | 219 NotificationService::AllBrowserContextsAndSources()); |
223 registrar_.Add(this, | 220 registrar_.Add(this, |
224 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, | 221 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, |
225 NotificationService::AllBrowserContextsAndSources()); | 222 NotificationService::AllBrowserContextsAndSources()); |
226 registrar_.Add(this, | 223 registrar_.Add(this, |
227 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, | 224 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
228 NotificationService::AllBrowserContextsAndSources()); | 225 NotificationService::AllBrowserContextsAndSources()); |
229 registrar_.Add(this, | 226 registrar_.Add(this, |
230 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, | 227 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 void ExtensionSettingsHandler::MultiFilesSelected( | 492 void ExtensionSettingsHandler::MultiFilesSelected( |
496 const std::vector<FilePath>& files, void* params) { | 493 const std::vector<FilePath>& files, void* params) { |
497 NOTREACHED(); | 494 NOTREACHED(); |
498 } | 495 } |
499 | 496 |
500 void ExtensionSettingsHandler::GetLocalizedValues( | 497 void ExtensionSettingsHandler::GetLocalizedValues( |
501 DictionaryValue* localized_strings) { | 498 DictionaryValue* localized_strings) { |
502 DCHECK(localized_strings); | 499 DCHECK(localized_strings); |
503 | 500 |
504 RegisterTitle(localized_strings, "extensionSettings", | 501 RegisterTitle(localized_strings, "extensionSettings", |
505 IDS_OPTIONS_GENERAL_TAB_LABEL); | 502 IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE); |
506 | 503 |
507 localized_strings->SetString("extensionSettingsTitle", | |
508 l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE)); | |
509 localized_strings->SetString("extensionSettingsVisitWebsite", | 504 localized_strings->SetString("extensionSettingsVisitWebsite", |
510 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); | 505 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); |
511 | 506 |
512 localized_strings->SetString("extensionSettingsDeveloperMode", | 507 localized_strings->SetString("extensionSettingsDeveloperMode", |
513 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK)); | 508 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK)); |
514 localized_strings->SetString("extensionSettingsNoExtensions", | 509 localized_strings->SetString("extensionSettingsNoExtensions", |
515 l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED)); | 510 l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED)); |
516 localized_strings->SetString("extensionSettingsSuggestGallery", | 511 localized_strings->SetString("extensionSettingsSuggestGallery", |
517 l10n_util::GetStringFUTF16(IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY, | 512 l10n_util::GetStringFUTF16(IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY, |
518 ASCIIToUTF16("<a href='") + | 513 ASCIIToUTF16("<a href='") + |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 const NotificationSource& source, | 583 const NotificationSource& source, |
589 const NotificationDetails& details) { | 584 const NotificationDetails& details) { |
590 Profile* profile = Profile::FromWebUI(web_ui_); | 585 Profile* profile = Profile::FromWebUI(web_ui_); |
591 Profile* source_profile = NULL; | 586 Profile* source_profile = NULL; |
592 switch (type) { | 587 switch (type) { |
593 // We listen for notifications that will result in the page being | 588 // We listen for notifications that will result in the page being |
594 // repopulated with data twice for the same event in certain cases. | 589 // repopulated with data twice for the same event in certain cases. |
595 // For instance, EXTENSION_LOADED & EXTENSION_PROCESS_CREATED because | 590 // For instance, EXTENSION_LOADED & EXTENSION_PROCESS_CREATED because |
596 // we don't know about the views for an extension at EXTENSION_LOADED, but | 591 // we don't know about the views for an extension at EXTENSION_LOADED, but |
597 // if we only listen to EXTENSION_PROCESS_CREATED, we'll miss extensions | 592 // if we only listen to EXTENSION_PROCESS_CREATED, we'll miss extensions |
598 // that don't have a process at startup. Similarly, NAV_ENTRY_COMMITTED & | 593 // that don't have a process at startup. |
599 // RENDER_VIEW_HOST_CREATED because we want to handle both | |
600 // the case of navigating from a non-extension page to an extension page in | |
601 // a TabContents (which will generate NAV_ENTRY_COMMITTED) as well as | |
602 // extension content being shown in popups and balloons (which will generate | |
603 // RENDER_VIEW_HOST_CREATED but no NAV_ENTRY_COMMITTED). | |
604 // | 594 // |
605 // Doing it this way gets everything but causes the page to be rendered | 595 // Doing it this way gets everything but causes the page to be rendered |
606 // more than we need. It doesn't seem to result in any noticeable flicker. | 596 // more than we need. It doesn't seem to result in any noticeable flicker. |
607 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: | 597 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: |
608 deleting_rvh_ = Source<RenderViewHost>(source).ptr(); | 598 deleting_rvh_ = Source<RenderViewHost>(source).ptr(); |
609 // Fall through. | 599 // Fall through. |
610 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: | 600 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: |
611 source_profile = Profile::FromBrowserContext( | 601 source_profile = Profile::FromBrowserContext( |
612 Source<RenderViewHost>(source)->site_instance()-> | 602 Source<RenderViewHost>(source)->site_instance()-> |
613 browsing_instance()->browser_context()); | 603 browsing_instance()->browser_context()); |
614 if (!profile->IsSameProfile(source_profile)) | 604 if (!profile->IsSameProfile(source_profile)) |
615 return; | 605 return; |
616 MaybeUpdateAfterNotification(); | 606 MaybeUpdateAfterNotification(); |
617 break; | 607 break; |
618 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: | 608 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: |
619 deleting_rvh_ = Details<BackgroundContents>(details)->render_view_host(); | 609 deleting_rvh_ = Details<BackgroundContents>(details)->render_view_host(); |
620 // Fall through. | 610 // Fall through. |
621 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: | 611 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: |
622 source_profile = Source<Profile>(source).ptr(); | 612 source_profile = Source<Profile>(source).ptr(); |
623 if (!profile->IsSameProfile(source_profile)) | 613 if (!profile->IsSameProfile(source_profile)) |
624 return; | 614 return; |
625 MaybeUpdateAfterNotification(); | 615 MaybeUpdateAfterNotification(); |
626 break; | 616 break; |
627 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: | |
628 source_profile = Profile::FromBrowserContext( | |
629 Source<NavigationController>(source).ptr()->browser_context()); | |
630 if (!profile->IsSameProfile(source_profile)) | |
631 return; | |
632 MaybeUpdateAfterNotification(); | |
633 break; | |
634 case chrome::NOTIFICATION_EXTENSION_LOADED: | 617 case chrome::NOTIFICATION_EXTENSION_LOADED: |
635 case chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED: | 618 case chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED: |
636 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 619 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
637 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: | 620 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
638 case chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED: | 621 case chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED: |
639 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: | 622 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
640 MaybeUpdateAfterNotification(); | 623 MaybeUpdateAfterNotification(); |
641 break; | 624 break; |
642 default: | 625 default: |
643 NOTREACHED(); | 626 NOTREACHED(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 continue; | 780 continue; |
798 } else if (!extension->web_extent().MatchesURL(url)) { | 781 } else if (!extension->web_extent().MatchesURL(url)) { |
799 continue; | 782 continue; |
800 } | 783 } |
801 | 784 |
802 result->push_back( | 785 result->push_back( |
803 ExtensionPage(url, process->id(), host->routing_id(), | 786 ExtensionPage(url, process->id(), host->routing_id(), |
804 process->browser_context()->IsOffTheRecord())); | 787 process->browser_context()->IsOffTheRecord())); |
805 } | 788 } |
806 } | 789 } |
OLD | NEW |