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

Side by Side Diff: chrome/browser/extensions/extension_system_impl.cc

Issue 1890163004: extensions: Abstract out install delay strategy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for comments in #4 Created 4 years, 8 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
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 "chrome/browser/extensions/extension_system_impl.h" 5 #include "chrome/browser/extensions/extension_system_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string_tokenizer.h" 15 #include "base/strings/string_tokenizer.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/extensions/chrome_app_sorting.h" 19 #include "chrome/browser/extensions/chrome_app_sorting.h"
20 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h" 20 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h"
21 #include "chrome/browser/extensions/component_loader.h" 21 #include "chrome/browser/extensions/component_loader.h"
22 #include "chrome/browser/extensions/extension_error_reporter.h" 22 #include "chrome/browser/extensions/extension_error_reporter.h"
23 #include "chrome/browser/extensions/extension_garbage_collector.h"
23 #include "chrome/browser/extensions/extension_management.h" 24 #include "chrome/browser/extensions/extension_management.h"
24 #include "chrome/browser/extensions/extension_service.h" 25 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/extensions/extension_sync_service.h" 26 #include "chrome/browser/extensions/extension_sync_service.h"
26 #include "chrome/browser/extensions/extension_system_factory.h" 27 #include "chrome/browser/extensions/extension_system_factory.h"
27 #include "chrome/browser/extensions/extension_util.h" 28 #include "chrome/browser/extensions/extension_util.h"
28 #include "chrome/browser/extensions/install_verifier.h" 29 #include "chrome/browser/extensions/install_verifier.h"
29 #include "chrome/browser/extensions/navigation_observer.h" 30 #include "chrome/browser/extensions/navigation_observer.h"
30 #include "chrome/browser/extensions/shared_module_service.h" 31 #include "chrome/browser/extensions/shared_module_service.h"
31 #include "chrome/browser/extensions/shared_user_script_master.h" 32 #include "chrome/browser/extensions/shared_user_script_master.h"
32 #include "chrome/browser/extensions/state_store_notification_observer.h" 33 #include "chrome/browser/extensions/state_store_notification_observer.h"
33 #include "chrome/browser/extensions/unpacked_installer.h" 34 #include "chrome/browser/extensions/unpacked_installer.h"
35 #include "chrome/browser/extensions/update_install_gate.h"
34 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/profiles/profile_manager.h" 37 #include "chrome/browser/profiles/profile_manager.h"
36 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
37 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
38 #include "chrome/common/extensions/features/feature_channel.h" 40 #include "chrome/common/extensions/features/feature_channel.h"
39 #include "content/public/browser/browser_thread.h" 41 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/url_data_source.h" 42 #include "content/public/browser/url_data_source.h"
41 #include "extensions/browser/content_verifier.h" 43 #include "extensions/browser/content_verifier.h"
42 #include "extensions/browser/extension_pref_store.h" 44 #include "extensions/browser/extension_pref_store.h"
43 #include "extensions/browser/extension_pref_value_map.h" 45 #include "extensions/browser/extension_pref_value_map.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 #if defined(OS_CHROMEOS) 137 #if defined(OS_CHROMEOS)
136 if (device_local_account_management_policy_provider_) { 138 if (device_local_account_management_policy_provider_) {
137 management_policy_->RegisterProvider( 139 management_policy_->RegisterProvider(
138 device_local_account_management_policy_provider_.get()); 140 device_local_account_management_policy_provider_.get());
139 } 141 }
140 #endif // defined(OS_CHROMEOS) 142 #endif // defined(OS_CHROMEOS)
141 143
142 management_policy_->RegisterProvider(InstallVerifier::Get(profile_)); 144 management_policy_->RegisterProvider(InstallVerifier::Get(profile_));
143 } 145 }
144 146
147 void ExtensionSystemImpl::Shared::InitInstallGates() {
148 update_install_gate_.reset(new UpdateInstallGate(extension_service_.get()));
149 extension_service_->RegisterInstallGate(
150 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, update_install_gate_.get());
151 extension_service_->RegisterInstallGate(
152 ExtensionPrefs::DELAY_REASON_GC,
153 ExtensionGarbageCollector::Get(profile_));
154 extension_service_->RegisterInstallGate(
155 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IMPORTS,
156 extension_service_->shared_module_service());
157 }
158
145 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { 159 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) {
146 TRACE_EVENT0("browser,startup", "ExtensionSystemImpl::Shared::Init"); 160 TRACE_EVENT0("browser,startup", "ExtensionSystemImpl::Shared::Init");
147 const base::CommandLine* command_line = 161 const base::CommandLine* command_line =
148 base::CommandLine::ForCurrentProcess(); 162 base::CommandLine::ForCurrentProcess();
149 163
150 navigation_observer_.reset(new NavigationObserver(profile_)); 164 navigation_observer_.reset(new NavigationObserver(profile_));
151 165
152 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); 166 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs);
153 ExtensionErrorReporter::Init(allow_noisy_errors); 167 ExtensionErrorReporter::Init(allow_noisy_errors);
154 168
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Blocking the UI thread is acceptable here since 234 // Blocking the UI thread is acceptable here since
221 // this flag designated for developers. 235 // this flag designated for developers.
222 base::ThreadRestrictions::ScopedAllowIO allow_io; 236 base::ThreadRestrictions::ScopedAllowIO allow_io;
223 extension_service_->component_loader()->AddOrReplace( 237 extension_service_->component_loader()->AddOrReplace(
224 base::FilePath(t.token())); 238 base::FilePath(t.token()));
225 } 239 }
226 } 240 }
227 241
228 app_sorting_.reset(new ChromeAppSorting(profile_)); 242 app_sorting_.reset(new ChromeAppSorting(profile_));
229 243
244 InitInstallGates();
245
230 extension_service_->Init(); 246 extension_service_->Init();
231 247
232 // Make sure ExtensionSyncService is created. 248 // Make sure ExtensionSyncService is created.
233 ExtensionSyncService::Get(profile_); 249 ExtensionSyncService::Get(profile_);
234 250
235 // Make the chrome://extension-icon/ resource available. 251 // Make the chrome://extension-icon/ resource available.
236 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_)); 252 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_));
237 253
238 quota_service_.reset(new QuotaService); 254 quota_service_.reset(new QuotaService);
239 255
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( 456 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
441 const std::string& extension_id, 457 const std::string& extension_id,
442 const UnloadedExtensionInfo::Reason reason) { 458 const UnloadedExtensionInfo::Reason reason) {
443 BrowserThread::PostTask( 459 BrowserThread::PostTask(
444 BrowserThread::IO, 460 BrowserThread::IO,
445 FROM_HERE, 461 FROM_HERE,
446 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); 462 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
447 } 463 }
448 464
449 } // namespace extensions 465 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system_impl.h ('k') | chrome/browser/extensions/install_gate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698