Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: extensions/shell/browser/shell_extension_system.cc

Issue 2212303003: Implement app launch changes for app runtime extension proposal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tool-screenshot
Patch Set: Nits Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/common/api/app_runtime.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 17 #include "extensions/browser/api/app_runtime/app_runtime_api.h"
18 #include "extensions/browser/extension_prefs.h" 18 #include "extensions/browser/extension_prefs.h"
19 #include "extensions/browser/extension_registry.h" 19 #include "extensions/browser/extension_registry.h"
20 #include "extensions/browser/info_map.h" 20 #include "extensions/browser/info_map.h"
21 #include "extensions/browser/notification_types.h" 21 #include "extensions/browser/notification_types.h"
22 #include "extensions/browser/null_app_sorting.h" 22 #include "extensions/browser/null_app_sorting.h"
23 #include "extensions/browser/quota_service.h" 23 #include "extensions/browser/quota_service.h"
24 #include "extensions/browser/runtime_data.h" 24 #include "extensions/browser/runtime_data.h"
25 #include "extensions/browser/service_worker_manager.h" 25 #include "extensions/browser/service_worker_manager.h"
26 #include "extensions/browser/value_store/value_store_factory_impl.h" 26 #include "extensions/browser/value_store/value_store_factory_impl.h"
27 #include "extensions/common/api/app_runtime.h"
27 #include "extensions/common/constants.h" 28 #include "extensions/common/constants.h"
28 #include "extensions/common/file_util.h" 29 #include "extensions/common/file_util.h"
29 30
30 using content::BrowserContext; 31 using content::BrowserContext;
31 using content::BrowserThread; 32 using content::BrowserThread;
32 33
33 namespace extensions { 34 namespace extensions {
34 35
35 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context) 36 ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context)
36 : browser_context_(browser_context), 37 : browser_context_(browser_context),
(...skipping 27 matching lines...) Expand all
64 65
65 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension.get()); 66 ExtensionRegistry::Get(browser_context_)->AddEnabled(extension.get());
66 67
67 RegisterExtensionWithRequestContexts( 68 RegisterExtensionWithRequestContexts(
68 extension.get(), 69 extension.get(),
69 base::Bind( 70 base::Bind(
70 &ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts, 71 &ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts,
71 weak_factory_.GetWeakPtr(), extension)); 72 weak_factory_.GetWeakPtr(), extension));
72 73
73 content::NotificationService::current()->Notify( 74 content::NotificationService::current()->Notify(
74 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 75 NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
75 content::Source<BrowserContext>(browser_context_), 76 content::Source<BrowserContext>(browser_context_),
76 content::Details<const Extension>(extension.get())); 77 content::Details<const Extension>(extension.get()));
77 78
78 return extension.get(); 79 return extension.get();
79 } 80 }
80 81
81 void ShellExtensionSystem::Init() { 82 void ShellExtensionSystem::Init() {
82 // Inform the rest of the extensions system to start. 83 // Inform the rest of the extensions system to start.
83 ready_.Signal(); 84 ready_.Signal();
84 content::NotificationService::current()->Notify( 85 content::NotificationService::current()->Notify(
85 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, 86 NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
86 content::Source<BrowserContext>(browser_context_), 87 content::Source<BrowserContext>(browser_context_),
87 content::NotificationService::NoDetails()); 88 content::NotificationService::NoDetails());
88 } 89 }
89 90
90 void ShellExtensionSystem::LaunchApp(const ExtensionId& extension_id) { 91 void ShellExtensionSystem::LaunchApp(const ExtensionId& extension_id) {
91 // Send the onLaunched event. 92 // Send the onLaunched event.
92 DCHECK(ExtensionRegistry::Get(browser_context_) 93 DCHECK(ExtensionRegistry::Get(browser_context_)
93 ->enabled_extensions() 94 ->enabled_extensions()
94 .Contains(extension_id)); 95 .Contains(extension_id));
95 const Extension* extension = ExtensionRegistry::Get(browser_context_) 96 const Extension* extension = ExtensionRegistry::Get(browser_context_)
96 ->enabled_extensions() 97 ->enabled_extensions()
97 .GetByID(extension_id); 98 .GetByID(extension_id);
98 AppRuntimeEventRouter::DispatchOnLaunchedEvent( 99 AppRuntimeEventRouter::DispatchOnLaunchedEvent(
99 browser_context_, extension, extensions::SOURCE_UNTRACKED); 100 browser_context_, extension, SOURCE_UNTRACKED,
101 std::unique_ptr<api::app_runtime::ActionData>());
100 } 102 }
101 103
102 void ShellExtensionSystem::Shutdown() { 104 void ShellExtensionSystem::Shutdown() {
103 } 105 }
104 106
105 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) { 107 void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
106 service_worker_manager_.reset(new ServiceWorkerManager(browser_context_)); 108 service_worker_manager_.reset(new ServiceWorkerManager(browser_context_));
107 runtime_data_.reset( 109 runtime_data_.reset(
108 new RuntimeData(ExtensionRegistry::Get(browser_context_))); 110 new RuntimeData(ExtensionRegistry::Get(browser_context_)));
109 quota_service_.reset(new QuotaService); 111 quota_service_.reset(new QuotaService);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 193 }
192 194
193 void ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts( 195 void ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts(
194 scoped_refptr<Extension> extension) { 196 scoped_refptr<Extension> extension) {
195 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_); 197 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_);
196 registry->AddReady(extension); 198 registry->AddReady(extension);
197 registry->TriggerOnReady(extension.get()); 199 registry->TriggerOnReady(extension.get());
198 } 200 }
199 201
200 } // namespace extensions 202 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/api/app_runtime.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698