OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 // access to the Extension and ExtensionHost. | 2493 // access to the Extension and ExtensionHost. |
2494 base::MessageLoop::current()->PostTask( | 2494 base::MessageLoop::current()->PostTask( |
2495 FROM_HERE, | 2495 FROM_HERE, |
2496 base::Bind( | 2496 base::Bind( |
2497 &ExtensionService::TrackTerminatedExtension, | 2497 &ExtensionService::TrackTerminatedExtension, |
2498 AsWeakPtr(), | 2498 AsWeakPtr(), |
2499 host->extension())); | 2499 host->extension())); |
2500 break; | 2500 break; |
2501 } | 2501 } |
2502 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { | 2502 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { |
| 2503 // TODO(jamescook): Extract this block of code to src/extensions so it |
| 2504 // can be shared with app_shell. |
2503 content::RenderProcessHost* process = | 2505 content::RenderProcessHost* process = |
2504 content::Source<content::RenderProcessHost>(source).ptr(); | 2506 content::Source<content::RenderProcessHost>(source).ptr(); |
2505 Profile* host_profile = | 2507 Profile* host_profile = |
2506 Profile::FromBrowserContext(process->GetBrowserContext()); | 2508 Profile::FromBrowserContext(process->GetBrowserContext()); |
2507 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) | 2509 if (!profile_->IsSameProfile(host_profile->GetOriginalProfile())) |
2508 break; | 2510 break; |
2509 | 2511 |
2510 // Extensions need to know the channel for API restrictions. | 2512 // Extensions need to know the channel for API restrictions. |
2511 process->Send(new ExtensionMsg_SetChannel( | 2513 process->Send(new ExtensionMsg_SetChannel( |
2512 extensions::GetCurrentChannel())); | 2514 extensions::GetCurrentChannel())); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 return true; | 2616 return true; |
2615 ExtensionRuntimeDataMap::const_iterator it = | 2617 ExtensionRuntimeDataMap::const_iterator it = |
2616 extension_runtime_data_.find(extension->id()); | 2618 extension_runtime_data_.find(extension->id()); |
2617 return it == extension_runtime_data_.end() ? false : | 2619 return it == extension_runtime_data_.end() ? false : |
2618 it->second.background_page_ready; | 2620 it->second.background_page_ready; |
2619 } | 2621 } |
2620 | 2622 |
2621 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { | 2623 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { |
2622 DCHECK(extensions::BackgroundInfo::HasBackgroundPage(extension)); | 2624 DCHECK(extensions::BackgroundInfo::HasBackgroundPage(extension)); |
2623 extension_runtime_data_[extension->id()].background_page_ready = true; | 2625 extension_runtime_data_[extension->id()].background_page_ready = true; |
2624 content::NotificationService::current()->Notify( | |
2625 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | |
2626 content::Source<const Extension>(extension), | |
2627 content::NotificationService::NoDetails()); | |
2628 } | 2626 } |
2629 | 2627 |
2630 bool ExtensionService::IsBeingUpgraded(const Extension* extension) const { | 2628 bool ExtensionService::IsBeingUpgraded(const Extension* extension) const { |
2631 ExtensionRuntimeDataMap::const_iterator it = | 2629 ExtensionRuntimeDataMap::const_iterator it = |
2632 extension_runtime_data_.find(extension->id()); | 2630 extension_runtime_data_.find(extension->id()); |
2633 return it == extension_runtime_data_.end() ? false : | 2631 return it == extension_runtime_data_.end() ? false : |
2634 it->second.being_upgraded; | 2632 it->second.being_upgraded; |
2635 } | 2633 } |
2636 | 2634 |
2637 void ExtensionService::SetBeingUpgraded(const Extension* extension, | 2635 void ExtensionService::SetBeingUpgraded(const Extension* extension, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 void ExtensionService::UnloadAllExtensionsInternal() { | 2813 void ExtensionService::UnloadAllExtensionsInternal() { |
2816 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2814 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
2817 | 2815 |
2818 registry_->ClearAll(); | 2816 registry_->ClearAll(); |
2819 extension_runtime_data_.clear(); | 2817 extension_runtime_data_.clear(); |
2820 | 2818 |
2821 // TODO(erikkay) should there be a notification for this? We can't use | 2819 // TODO(erikkay) should there be a notification for this? We can't use |
2822 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2820 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
2823 // or uninstalled. | 2821 // or uninstalled. |
2824 } | 2822 } |
OLD | NEW |