| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_settings_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" |
| 6 | 6 |
| 7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
| 8 #include "apps/app_window.h" | 8 #include "apps/app_window.h" |
| 9 #include "apps/app_window_registry.h" | 9 #include "apps/app_window_registry.h" |
| 10 #include "apps/saved_files_service.h" | 10 #include "apps/saved_files_service.h" |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 // if we only listen to EXTENSION_HOST_CREATED, we'll miss extensions | 675 // if we only listen to EXTENSION_HOST_CREATED, we'll miss extensions |
| 676 // that don't have a process at startup. | 676 // that don't have a process at startup. |
| 677 // | 677 // |
| 678 // Doing it this way gets everything but causes the page to be rendered | 678 // Doing it this way gets everything but causes the page to be rendered |
| 679 // more than we need. It doesn't seem to result in any noticeable flicker. | 679 // more than we need. It doesn't seem to result in any noticeable flicker. |
| 680 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: | 680 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: |
| 681 deleting_rvh_ = content::Details<BackgroundContents>(details)-> | 681 deleting_rvh_ = content::Details<BackgroundContents>(details)-> |
| 682 web_contents()->GetRenderViewHost(); | 682 web_contents()->GetRenderViewHost(); |
| 683 // Fall through. | 683 // Fall through. |
| 684 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: | 684 case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: |
| 685 case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: | 685 case extensions::NOTIFICATION_EXTENSION_HOST_CREATED: |
| 686 source_profile = content::Source<Profile>(source).ptr(); | 686 source_profile = content::Source<Profile>(source).ptr(); |
| 687 if (!profile->IsSameProfile(source_profile)) | 687 if (!profile->IsSameProfile(source_profile)) |
| 688 return; | 688 return; |
| 689 MaybeUpdateAfterNotification(); | 689 MaybeUpdateAfterNotification(); |
| 690 break; | 690 break; |
| 691 case content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { | 691 case content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { |
| 692 content::RenderWidgetHost* rwh = | 692 content::RenderWidgetHost* rwh = |
| 693 content::Source<content::RenderWidgetHost>(source).ptr(); | 693 content::Source<content::RenderWidgetHost>(source).ptr(); |
| 694 deleting_rwh_id_ = rwh->GetRoutingID(); | 694 deleting_rwh_id_ = rwh->GetRoutingID(); |
| 695 deleting_rph_id_ = rwh->GetProcess()->GetID(); | 695 deleting_rph_id_ = rwh->GetProcess()->GetID(); |
| 696 MaybeUpdateAfterNotification(); | 696 MaybeUpdateAfterNotification(); |
| 697 break; | 697 break; |
| 698 } | 698 } |
| 699 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: | 699 case extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| 700 case chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: | 700 case extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED: |
| 701 MaybeUpdateAfterNotification(); | 701 MaybeUpdateAfterNotification(); |
| 702 break; | 702 break; |
| 703 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: | 703 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: |
| 704 // This notification is sent when the extension host destruction begins, | 704 // This notification is sent when the extension host destruction begins, |
| 705 // not when it finishes. We use PostTask to delay the update until after | 705 // not when it finishes. We use PostTask to delay the update until after |
| 706 // the destruction finishes. | 706 // the destruction finishes. |
| 707 base::MessageLoop::current()->PostTask( | 707 base::MessageLoop::current()->PostTask( |
| 708 FROM_HERE, | 708 FROM_HERE, |
| 709 base::Bind(&ExtensionSettingsHandler::MaybeUpdateAfterNotification, | 709 base::Bind(&ExtensionSettingsHandler::MaybeUpdateAfterNotification, |
| 710 AsWeakPtr())); | 710 AsWeakPtr())); |
| 711 break; | 711 break; |
| 712 default: | 712 default: |
| 713 NOTREACHED(); | 713 NOTREACHED(); |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 void ExtensionSettingsHandler::MaybeRegisterForNotifications() { | 1209 void ExtensionSettingsHandler::MaybeRegisterForNotifications() { |
| 1210 if (registered_for_notifications_) | 1210 if (registered_for_notifications_) |
| 1211 return; | 1211 return; |
| 1212 | 1212 |
| 1213 registered_for_notifications_ = true; | 1213 registered_for_notifications_ = true; |
| 1214 Profile* profile = Profile::FromWebUI(web_ui()); | 1214 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1215 | 1215 |
| 1216 // Register for notifications that we need to reload the page. | 1216 // Register for notifications that we need to reload the page. |
| 1217 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 1217 registrar_.Add(this, |
| 1218 extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 1218 content::Source<Profile>(profile)); | 1219 content::Source<Profile>(profile)); |
| 1219 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 1220 registrar_.Add(this, |
| 1221 extensions::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 1220 content::NotificationService::AllBrowserContextsAndSources()); | 1222 content::NotificationService::AllBrowserContextsAndSources()); |
| 1221 registrar_.Add(this, | 1223 registrar_.Add(this, |
| 1222 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, | 1224 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
| 1223 content::NotificationService::AllBrowserContextsAndSources()); | 1225 content::NotificationService::AllBrowserContextsAndSources()); |
| 1224 registrar_.Add(this, | 1226 registrar_.Add(this, |
| 1225 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, | 1227 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
| 1226 content::NotificationService::AllBrowserContextsAndSources()); | 1228 content::NotificationService::AllBrowserContextsAndSources()); |
| 1227 registrar_.Add( | 1229 registrar_.Add( |
| 1228 this, | 1230 this, |
| 1229 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, | 1231 extensions::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |
| 1230 content::Source<ExtensionPrefs>(ExtensionPrefs::Get(profile))); | 1232 content::Source<ExtensionPrefs>(ExtensionPrefs::Get(profile))); |
| 1231 registrar_.Add(this, | 1233 registrar_.Add(this, |
| 1232 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 1234 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 1233 content::NotificationService::AllBrowserContextsAndSources()); | 1235 content::NotificationService::AllBrowserContextsAndSources()); |
| 1234 registrar_.Add(this, | 1236 registrar_.Add(this, |
| 1235 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1237 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1236 content::NotificationService::AllBrowserContextsAndSources()); | 1238 content::NotificationService::AllBrowserContextsAndSources()); |
| 1237 | 1239 |
| 1238 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); | 1240 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); |
| 1239 | 1241 |
| 1240 content::WebContentsObserver::Observe(web_ui()->GetWebContents()); | 1242 content::WebContentsObserver::Observe(web_ui()->GetWebContents()); |
| 1241 | 1243 |
| 1242 warning_service_observer_.Add( | 1244 warning_service_observer_.Add( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 extension_service_->EnableExtension(extension_id); | 1395 extension_service_->EnableExtension(extension_id); |
| 1394 } else { | 1396 } else { |
| 1395 ExtensionErrorReporter::GetInstance()->ReportError( | 1397 ExtensionErrorReporter::GetInstance()->ReportError( |
| 1396 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), | 1398 base::UTF8ToUTF16(JoinString(requirement_errors, ' ')), |
| 1397 true); // Be noisy. | 1399 true); // Be noisy. |
| 1398 } | 1400 } |
| 1399 requirements_checker_.reset(); | 1401 requirements_checker_.reset(); |
| 1400 } | 1402 } |
| 1401 | 1403 |
| 1402 } // namespace extensions | 1404 } // namespace extensions |
| OLD | NEW |