| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 content::Source<Profile>(profile)); | 211 content::Source<Profile>(profile)); |
| 212 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, | 212 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, |
| 213 content::Source<Profile>(profile)); | 213 content::Source<Profile>(profile)); |
| 214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 215 content::Source<Profile>(profile)); | 215 content::Source<Profile>(profile)); |
| 216 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 216 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 217 content::Source<Profile>(profile)); | 217 content::Source<Profile>(profile)); |
| 218 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED, | 218 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED, |
| 219 content::Source<Profile>(profile)); | 219 content::Source<Profile>(profile)); |
| 220 registrar_.Add(this, | 220 registrar_.Add(this, |
| 221 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
| 222 content::NotificationService::AllBrowserContextsAndSources()); | |
| 223 registrar_.Add(this, | |
| 224 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, | 221 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, |
| 225 content::NotificationService::AllBrowserContextsAndSources()); | 222 content::NotificationService::AllBrowserContextsAndSources()); |
| 226 registrar_.Add(this, | 223 registrar_.Add(this, |
| 227 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, | 224 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, |
| 228 content::NotificationService::AllBrowserContextsAndSources()); | 225 content::NotificationService::AllBrowserContextsAndSources()); |
| 229 registrar_.Add(this, | 226 registrar_.Add(this, |
| 230 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, | 227 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
| 231 content::NotificationService::AllBrowserContextsAndSources()); | 228 content::NotificationService::AllBrowserContextsAndSources()); |
| 232 registrar_.Add(this, | 229 registrar_.Add(this, |
| 233 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, | 230 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 void ExtensionSettingsHandler::MultiFilesSelected( | 495 void ExtensionSettingsHandler::MultiFilesSelected( |
| 499 const std::vector<FilePath>& files, void* params) { | 496 const std::vector<FilePath>& files, void* params) { |
| 500 NOTREACHED(); | 497 NOTREACHED(); |
| 501 } | 498 } |
| 502 | 499 |
| 503 void ExtensionSettingsHandler::GetLocalizedValues( | 500 void ExtensionSettingsHandler::GetLocalizedValues( |
| 504 DictionaryValue* localized_strings) { | 501 DictionaryValue* localized_strings) { |
| 505 DCHECK(localized_strings); | 502 DCHECK(localized_strings); |
| 506 | 503 |
| 507 RegisterTitle(localized_strings, "extensionSettings", | 504 RegisterTitle(localized_strings, "extensionSettings", |
| 508 IDS_OPTIONS_GENERAL_TAB_LABEL); | 505 IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE); |
| 509 | 506 |
| 510 localized_strings->SetString("extensionSettingsTitle", | |
| 511 l10n_util::GetStringUTF16(IDS_MANAGE_EXTENSIONS_SETTING_WINDOWS_TITLE)); | |
| 512 localized_strings->SetString("extensionSettingsVisitWebsite", | 507 localized_strings->SetString("extensionSettingsVisitWebsite", |
| 513 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); | 508 l10n_util::GetStringUTF16(IDS_EXTENSIONS_VISIT_WEBSITE)); |
| 514 | 509 |
| 515 localized_strings->SetString("extensionSettingsDeveloperMode", | 510 localized_strings->SetString("extensionSettingsDeveloperMode", |
| 516 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK)); | 511 l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK)); |
| 517 localized_strings->SetString("extensionSettingsNoExtensions", | 512 localized_strings->SetString("extensionSettingsNoExtensions", |
| 518 l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED)); | 513 l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED)); |
| 519 localized_strings->SetString("extensionSettingsSuggestGallery", | 514 localized_strings->SetString("extensionSettingsSuggestGallery", |
| 520 l10n_util::GetStringFUTF16(IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY, | 515 l10n_util::GetStringFUTF16(IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY, |
| 521 ASCIIToUTF16("<a href='") + | 516 ASCIIToUTF16("<a href='") + |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 const content::NotificationSource& source, | 593 const content::NotificationSource& source, |
| 599 const content::NotificationDetails& details) { | 594 const content::NotificationDetails& details) { |
| 600 Profile* profile = Profile::FromWebUI(web_ui_); | 595 Profile* profile = Profile::FromWebUI(web_ui_); |
| 601 Profile* source_profile = NULL; | 596 Profile* source_profile = NULL; |
| 602 switch (type) { | 597 switch (type) { |
| 603 // We listen for notifications that will result in the page being | 598 // We listen for notifications that will result in the page being |
| 604 // repopulated with data twice for the same event in certain cases. | 599 // repopulated with data twice for the same event in certain cases. |
| 605 // For instance, EXTENSION_LOADED & EXTENSION_PROCESS_CREATED because | 600 // For instance, EXTENSION_LOADED & EXTENSION_PROCESS_CREATED because |
| 606 // we don't know about the views for an extension at EXTENSION_LOADED, but | 601 // we don't know about the views for an extension at EXTENSION_LOADED, but |
| 607 // if we only listen to EXTENSION_PROCESS_CREATED, we'll miss extensions | 602 // if we only listen to EXTENSION_PROCESS_CREATED, we'll miss extensions |
| 608 // that don't have a process at startup. Similarly, NAV_ENTRY_COMMITTED & | 603 // that don't have a process at startup. |
| 609 // RENDER_VIEW_HOST_CREATED because we want to handle both | |
| 610 // the case of navigating from a non-extension page to an extension page in | |
| 611 // a TabContents (which will generate NAV_ENTRY_COMMITTED) as well as | |
| 612 // extension content being shown in popups and balloons (which will generate | |
| 613 // RENDER_VIEW_HOST_CREATED but no NAV_ENTRY_COMMITTED). | |
| 614 // | 604 // |
| 615 // Doing it this way gets everything but causes the page to be rendered | 605 // Doing it this way gets everything but causes the page to be rendered |
| 616 // more than we need. It doesn't seem to result in any noticeable flicker. | 606 // more than we need. It doesn't seem to result in any noticeable flicker. |
| 617 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: | 607 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: |
| 618 deleting_rvh_ = content::Source<RenderViewHost>(source).ptr(); | 608 deleting_rvh_ = content::Source<RenderViewHost>(source).ptr(); |
| 619 // Fall through. | 609 // Fall through. |
| 620 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: | 610 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: |
| 621 source_profile = Profile::FromBrowserContext( | 611 source_profile = Profile::FromBrowserContext( |
| 622 content::Source<RenderViewHost>(source)->site_instance()-> | 612 content::Source<RenderViewHost>(source)->site_instance()-> |
| 623 browsing_instance()->browser_context()); | 613 browsing_instance()->browser_context()); |
| 624 if (!profile->IsSameProfile(source_profile)) | 614 if (!profile->IsSameProfile(source_profile)) |
| 625 return; | 615 return; |
| 626 MaybeUpdateAfterNotification(); | 616 MaybeUpdateAfterNotification(); |
| 627 break; | 617 break; |
| 628 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: | 618 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: |
| 629 deleting_rvh_ = | 619 deleting_rvh_ = |
| 630 content::Details<BackgroundContents>(details)->render_view_host(); | 620 content::Details<BackgroundContents>(details)->render_view_host(); |
| 631 // Fall through. | 621 // Fall through. |
| 632 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: | 622 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: |
| 633 source_profile = content::Source<Profile>(source).ptr(); | 623 source_profile = content::Source<Profile>(source).ptr(); |
| 634 if (!profile->IsSameProfile(source_profile)) | 624 if (!profile->IsSameProfile(source_profile)) |
| 635 return; | 625 return; |
| 636 MaybeUpdateAfterNotification(); | 626 MaybeUpdateAfterNotification(); |
| 637 break; | 627 break; |
| 638 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: | |
| 639 source_profile = Profile::FromBrowserContext( | |
| 640 content::Source<NavigationController>( | |
| 641 source).ptr()->browser_context()); | |
| 642 if (!profile->IsSameProfile(source_profile)) | |
| 643 return; | |
| 644 MaybeUpdateAfterNotification(); | |
| 645 break; | |
| 646 case chrome::NOTIFICATION_EXTENSION_LOADED: | 628 case chrome::NOTIFICATION_EXTENSION_LOADED: |
| 647 case chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED: | 629 case chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED: |
| 648 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 630 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| 649 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: | 631 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| 650 case chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED: | 632 case chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED: |
| 651 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: | 633 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
| 652 MaybeUpdateAfterNotification(); | 634 MaybeUpdateAfterNotification(); |
| 653 break; | 635 break; |
| 654 default: | 636 default: |
| 655 NOTREACHED(); | 637 NOTREACHED(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type) | 776 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type) |
| 795 continue; | 777 continue; |
| 796 | 778 |
| 797 GURL url = host->delegate()->GetURL(); | 779 GURL url = host->delegate()->GetURL(); |
| 798 RenderProcessHost* process = host->process(); | 780 RenderProcessHost* process = host->process(); |
| 799 result->push_back( | 781 result->push_back( |
| 800 ExtensionPage(url, process->id(), host->routing_id(), | 782 ExtensionPage(url, process->id(), host->routing_id(), |
| 801 process->browser_context()->IsOffTheRecord())); | 783 process->browser_context()->IsOffTheRecord())); |
| 802 } | 784 } |
| 803 } | 785 } |
| OLD | NEW |