| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void ExtensionSettingsHandler::MaybeRegisterForNotifications() { | 203 void ExtensionSettingsHandler::MaybeRegisterForNotifications() { |
| 204 if (registered_for_notifications_) | 204 if (registered_for_notifications_) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 registered_for_notifications_ = true; | 207 registered_for_notifications_ = true; |
| 208 Profile* profile = Profile::FromWebUI(web_ui_); | 208 Profile* profile = Profile::FromWebUI(web_ui_); |
| 209 | 209 |
| 210 // Register for notifications that we need to reload the page. | 210 // Register for notifications that we need to reload the page. |
| 211 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 211 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 212 content::Source<Profile>(profile)); | 212 content::Source<Profile>(profile)); |
| 213 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED, | |
| 214 content::Source<Profile>(profile)); | |
| 215 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 213 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 216 content::Source<Profile>(profile)); | 214 content::Source<Profile>(profile)); |
| 217 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 215 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 218 content::Source<Profile>(profile)); | 216 content::Source<Profile>(profile)); |
| 219 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED, | 217 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED, |
| 220 content::Source<Profile>(profile)); | 218 content::Source<Profile>(profile)); |
| 219 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 220 content::NotificationService::AllBrowserContextsAndSources()); |
| 221 registrar_.Add(this, | 221 registrar_.Add(this, |
| 222 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, | 222 content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, |
| 223 content::NotificationService::AllBrowserContextsAndSources()); | 223 content::NotificationService::AllBrowserContextsAndSources()); |
| 224 registrar_.Add(this, | 224 registrar_.Add(this, |
| 225 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, | 225 content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, |
| 226 content::NotificationService::AllBrowserContextsAndSources()); | 226 content::NotificationService::AllBrowserContextsAndSources()); |
| 227 registrar_.Add(this, | 227 registrar_.Add(this, |
| 228 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, | 228 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
| 229 content::NotificationService::AllBrowserContextsAndSources()); | 229 content::NotificationService::AllBrowserContextsAndSources()); |
| 230 registrar_.Add(this, | 230 registrar_.Add(this, |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 590 |
| 591 void ExtensionSettingsHandler::Observe( | 591 void ExtensionSettingsHandler::Observe( |
| 592 int type, | 592 int type, |
| 593 const content::NotificationSource& source, | 593 const content::NotificationSource& source, |
| 594 const content::NotificationDetails& details) { | 594 const content::NotificationDetails& details) { |
| 595 Profile* profile = Profile::FromWebUI(web_ui_); | 595 Profile* profile = Profile::FromWebUI(web_ui_); |
| 596 Profile* source_profile = NULL; | 596 Profile* source_profile = NULL; |
| 597 switch (type) { | 597 switch (type) { |
| 598 // We listen for notifications that will result in the page being | 598 // We listen for notifications that will result in the page being |
| 599 // repopulated with data twice for the same event in certain cases. | 599 // repopulated with data twice for the same event in certain cases. |
| 600 // For instance, EXTENSION_LOADED & EXTENSION_PROCESS_CREATED because | 600 // For instance, EXTENSION_LOADED & EXTENSION_HOST_CREATED because |
| 601 // 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 |
| 602 // if we only listen to EXTENSION_PROCESS_CREATED, we'll miss extensions | 602 // if we only listen to EXTENSION_HOST_CREATED, we'll miss extensions |
| 603 // that don't have a process at startup. | 603 // that don't have a process at startup. |
| 604 // | 604 // |
| 605 // 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 |
| 606 // 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. |
| 607 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: | 607 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: |
| 608 deleting_rvh_ = content::Source<RenderViewHost>(source).ptr(); | 608 deleting_rvh_ = content::Source<RenderViewHost>(source).ptr(); |
| 609 // Fall through. | 609 // Fall through. |
| 610 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: | 610 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: |
| 611 source_profile = Profile::FromBrowserContext( | 611 source_profile = Profile::FromBrowserContext( |
| 612 content::Source<RenderViewHost>(source)->site_instance()-> | 612 content::Source<RenderViewHost>(source)->site_instance()-> |
| 613 browsing_instance()->browser_context()); | 613 browsing_instance()->browser_context()); |
| 614 if (!profile->IsSameProfile(source_profile)) | 614 if (!profile->IsSameProfile(source_profile)) |
| 615 return; | 615 return; |
| 616 MaybeUpdateAfterNotification(); | 616 MaybeUpdateAfterNotification(); |
| 617 break; | 617 break; |
| 618 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: | 618 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: |
| 619 deleting_rvh_ = | 619 deleting_rvh_ = |
| 620 content::Details<BackgroundContents>(details)->render_view_host(); | 620 content::Details<BackgroundContents>(details)->render_view_host(); |
| 621 // Fall through. | 621 // Fall through. |
| 622 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: | 622 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: |
| 623 case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: |
| 623 source_profile = content::Source<Profile>(source).ptr(); | 624 source_profile = content::Source<Profile>(source).ptr(); |
| 624 if (!profile->IsSameProfile(source_profile)) | 625 if (!profile->IsSameProfile(source_profile)) |
| 625 return; | 626 return; |
| 626 MaybeUpdateAfterNotification(); | 627 MaybeUpdateAfterNotification(); |
| 627 break; | 628 break; |
| 628 case chrome::NOTIFICATION_EXTENSION_LOADED: | 629 case chrome::NOTIFICATION_EXTENSION_LOADED: |
| 629 case chrome::NOTIFICATION_EXTENSION_PROCESS_CREATED: | |
| 630 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 630 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| 631 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: | 631 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| 632 case chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED: | 632 case chrome::NOTIFICATION_EXTENSION_WARNING_CHANGED: |
| 633 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: | 633 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
| 634 MaybeUpdateAfterNotification(); | 634 MaybeUpdateAfterNotification(); |
| 635 break; | 635 break; |
| 636 default: | 636 default: |
| 637 NOTREACHED(); | 637 NOTREACHED(); |
| 638 } | 638 } |
| 639 } | 639 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type) | 776 chrome::VIEW_TYPE_EXTENSION_DIALOG == host_type) |
| 777 continue; | 777 continue; |
| 778 | 778 |
| 779 GURL url = host->delegate()->GetURL(); | 779 GURL url = host->delegate()->GetURL(); |
| 780 RenderProcessHost* process = host->process(); | 780 RenderProcessHost* process = host->process(); |
| 781 result->push_back( | 781 result->push_back( |
| 782 ExtensionPage(url, process->id(), host->routing_id(), | 782 ExtensionPage(url, process->id(), host->routing_id(), |
| 783 process->browser_context()->IsOffTheRecord())); | 783 process->browser_context()->IsOffTheRecord())); |
| 784 } | 784 } |
| 785 } | 785 } |
| OLD | NEW |