| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_extension_system.h" | 5 #include "extensions/shell/browser/shell_extension_system.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 17 #include "extensions/browser/api/app_runtime/app_runtime_api.h" | |
| 18 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
| 19 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 20 #include "extensions/browser/info_map.h" | 19 #include "extensions/browser/info_map.h" |
| 21 #include "extensions/browser/notification_types.h" | 20 #include "extensions/browser/notification_types.h" |
| 22 #include "extensions/browser/null_app_sorting.h" | 21 #include "extensions/browser/null_app_sorting.h" |
| 23 #include "extensions/browser/quota_service.h" | 22 #include "extensions/browser/quota_service.h" |
| 24 #include "extensions/browser/renderer_startup_helper.h" | 23 #include "extensions/browser/renderer_startup_helper.h" |
| 25 #include "extensions/browser/runtime_data.h" | 24 #include "extensions/browser/runtime_data.h" |
| 26 #include "extensions/browser/service_worker_manager.h" | 25 #include "extensions/browser/service_worker_manager.h" |
| 27 #include "extensions/browser/value_store/value_store_factory_impl.h" | 26 #include "extensions/browser/value_store/value_store_factory_impl.h" |
| 28 #include "extensions/common/api/app_runtime.h" | |
| 29 #include "extensions/common/constants.h" | |
| 30 #include "extensions/common/file_util.h" | 27 #include "extensions/common/file_util.h" |
| 31 | 28 |
| 32 using content::BrowserContext; | 29 using content::BrowserContext; |
| 33 using content::BrowserThread; | 30 using content::BrowserThread; |
| 34 | 31 |
| 35 namespace extensions { | 32 namespace extensions { |
| 36 | 33 |
| 37 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) | 34 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) |
| 38 : browser_context_(browser_context), | 35 : browser_context_(browser_context), |
| 39 store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())), | 36 store_factory_(new ValueStoreFactoryImpl(browser_context->GetPath())), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 84 |
| 88 void ShellExtensionSystem::Init() { | 85 void ShellExtensionSystem::Init() { |
| 89 // Inform the rest of the extensions system to start. | 86 // Inform the rest of the extensions system to start. |
| 90 ready_.Signal(); | 87 ready_.Signal(); |
| 91 content::NotificationService::current()->Notify( | 88 content::NotificationService::current()->Notify( |
| 92 NOTIFICATION_EXTENSIONS_READY_DEPRECATED, | 89 NOTIFICATION_EXTENSIONS_READY_DEPRECATED, |
| 93 content::Source<BrowserContext>(browser_context_), | 90 content::Source<BrowserContext>(browser_context_), |
| 94 content::NotificationService::NoDetails()); | 91 content::NotificationService::NoDetails()); |
| 95 } | 92 } |
| 96 | 93 |
| 97 void ShellExtensionSystem::LaunchApp(const ExtensionId& extension_id) { | |
| 98 // Send the onLaunched event. | |
| 99 DCHECK(ExtensionRegistry::Get(browser_context_) | |
| 100 ->enabled_extensions() | |
| 101 .Contains(extension_id)); | |
| 102 const Extension* extension = ExtensionRegistry::Get(browser_context_) | |
| 103 ->enabled_extensions() | |
| 104 .GetByID(extension_id); | |
| 105 AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context_, extension, | |
| 106 SOURCE_UNTRACKED, nullptr); | |
| 107 } | |
| 108 | |
| 109 void ShellExtensionSystem::Shutdown() { | 94 void ShellExtensionSystem::Shutdown() { |
| 110 } | 95 } |
| 111 | 96 |
| 112 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { | 97 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { |
| 113 service_worker_manager_.reset(new ServiceWorkerManager(browser_context_)); | 98 service_worker_manager_.reset(new ServiceWorkerManager(browser_context_)); |
| 114 runtime_data_.reset( | 99 runtime_data_.reset( |
| 115 new RuntimeData(ExtensionRegistry::Get(browser_context_))); | 100 new RuntimeData(ExtensionRegistry::Get(browser_context_))); |
| 116 quota_service_.reset(new QuotaService); | 101 quota_service_.reset(new QuotaService); |
| 117 app_sorting_.reset(new NullAppSorting); | 102 app_sorting_.reset(new NullAppSorting); |
| 118 } | 103 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 182 } |
| 198 | 183 |
| 199 void ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts( | 184 void ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts( |
| 200 scoped_refptr<Extension> extension) { | 185 scoped_refptr<Extension> extension) { |
| 201 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_); | 186 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_); |
| 202 registry->AddReady(extension); | 187 registry->AddReady(extension); |
| 203 registry->TriggerOnReady(extension.get()); | 188 registry->TriggerOnReady(extension.get()); |
| 204 } | 189 } |
| 205 | 190 |
| 206 } // namespace extensions | 191 } // namespace extensions |
| OLD | NEW |