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 "chrome/browser/extensions/extension_system_impl.h" | 5 #include "chrome/browser/extensions/extension_system_impl.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/strings/string_tokenizer.h" | 12 #include "base/strings/string_tokenizer.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/extensions/chrome_app_sorting.h" | |
15 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h" | 16 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h" |
16 #include "chrome/browser/extensions/component_loader.h" | 17 #include "chrome/browser/extensions/component_loader.h" |
17 #include "chrome/browser/extensions/extension_error_reporter.h" | 18 #include "chrome/browser/extensions/extension_error_reporter.h" |
18 #include "chrome/browser/extensions/extension_management.h" | 19 #include "chrome/browser/extensions/extension_management.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/extension_system_factory.h" | 21 #include "chrome/browser/extensions/extension_system_factory.h" |
21 #include "chrome/browser/extensions/extension_util.h" | 22 #include "chrome/browser/extensions/extension_util.h" |
22 #include "chrome/browser/extensions/install_verifier.h" | 23 #include "chrome/browser/extensions/install_verifier.h" |
23 #include "chrome/browser/extensions/navigation_observer.h" | 24 #include "chrome/browser/extensions/navigation_observer.h" |
24 #include "chrome/browser/extensions/shared_module_service.h" | 25 #include "chrome/browser/extensions/shared_module_service.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 t(path_list, FILE_PATH_LITERAL(",")); | 195 t(path_list, FILE_PATH_LITERAL(",")); |
195 while (t.GetNext()) { | 196 while (t.GetNext()) { |
196 // Load the component extension manifest synchronously. | 197 // Load the component extension manifest synchronously. |
197 // Blocking the UI thread is acceptable here since | 198 // Blocking the UI thread is acceptable here since |
198 // this flag designated for developers. | 199 // this flag designated for developers. |
199 base::ThreadRestrictions::ScopedAllowIO allow_io; | 200 base::ThreadRestrictions::ScopedAllowIO allow_io; |
200 extension_service_->component_loader()->AddOrReplace( | 201 extension_service_->component_loader()->AddOrReplace( |
201 base::FilePath(t.token())); | 202 base::FilePath(t.token())); |
202 } | 203 } |
203 } | 204 } |
205 | |
206 app_sorting_.reset(new ChromeAppSorting(profile_)); | |
207 ExtensionIdList extensions; | |
208 ExtensionPrefs::Get(profile_)->GetExtensions(&extensions); | |
209 app_sorting_->Initialize(extensions); | |
210 ExtensionPrefs::Get(profile_)->set_app_sorting(app_sorting_.get()); | |
Marc Treib
2015/07/29 09:53:32
This is super ugly :( But when the ExtensionPrefs
not at google - send to devlin
2015/07/29 18:22:03
I don't think making something a KeyedService is t
Marc Treib
2015/07/30 14:04:12
Done. Together with an set_app_sorting call, this
| |
211 | |
204 extension_service_->Init(); | 212 extension_service_->Init(); |
205 | 213 |
206 // Make the chrome://extension-icon/ resource available. | 214 // Make the chrome://extension-icon/ resource available. |
207 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_)); | 215 content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_)); |
208 | 216 |
209 quota_service_.reset(new QuotaService); | 217 quota_service_.reset(new QuotaService); |
210 | 218 |
211 if (extensions_enabled) { | 219 if (extensions_enabled) { |
212 // Load any extensions specified with --load-extension. | 220 // Load any extensions specified with --load-extension. |
213 // TODO(yoz): Seems like this should move into ExtensionService::Init. | 221 // TODO(yoz): Seems like this should move into ExtensionService::Init. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 InfoMap* ExtensionSystemImpl::Shared::info_map() { | 270 InfoMap* ExtensionSystemImpl::Shared::info_map() { |
263 if (!extension_info_map_.get()) | 271 if (!extension_info_map_.get()) |
264 extension_info_map_ = new InfoMap(); | 272 extension_info_map_ = new InfoMap(); |
265 return extension_info_map_.get(); | 273 return extension_info_map_.get(); |
266 } | 274 } |
267 | 275 |
268 QuotaService* ExtensionSystemImpl::Shared::quota_service() { | 276 QuotaService* ExtensionSystemImpl::Shared::quota_service() { |
269 return quota_service_.get(); | 277 return quota_service_.get(); |
270 } | 278 } |
271 | 279 |
280 AppSorting* ExtensionSystemImpl::Shared::app_sorting() { | |
281 return app_sorting_.get(); | |
282 } | |
283 | |
272 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() { | 284 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() { |
273 return content_verifier_.get(); | 285 return content_verifier_.get(); |
274 } | 286 } |
275 | 287 |
276 // | 288 // |
277 // ExtensionSystemImpl | 289 // ExtensionSystemImpl |
278 // | 290 // |
279 | 291 |
280 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) | 292 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) |
281 : profile_(profile) { | 293 : profile_(profile) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); } | 342 InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); } |
331 | 343 |
332 const OneShotEvent& ExtensionSystemImpl::ready() const { | 344 const OneShotEvent& ExtensionSystemImpl::ready() const { |
333 return shared_->ready(); | 345 return shared_->ready(); |
334 } | 346 } |
335 | 347 |
336 QuotaService* ExtensionSystemImpl::quota_service() { | 348 QuotaService* ExtensionSystemImpl::quota_service() { |
337 return shared_->quota_service(); | 349 return shared_->quota_service(); |
338 } | 350 } |
339 | 351 |
352 AppSorting* ExtensionSystemImpl::app_sorting() { | |
353 return shared_->app_sorting(); | |
354 } | |
355 | |
340 ContentVerifier* ExtensionSystemImpl::content_verifier() { | 356 ContentVerifier* ExtensionSystemImpl::content_verifier() { |
341 return shared_->content_verifier(); | 357 return shared_->content_verifier(); |
342 } | 358 } |
343 | 359 |
344 scoped_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions( | 360 scoped_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions( |
345 const Extension* extension) { | 361 const Extension* extension) { |
346 return extension_service()->shared_module_service()->GetDependentExtensions( | 362 return extension_service()->shared_module_service()->GetDependentExtensions( |
347 extension); | 363 extension); |
348 } | 364 } |
349 | 365 |
(...skipping 28 matching lines...) Expand all Loading... | |
378 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 394 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
379 const std::string& extension_id, | 395 const std::string& extension_id, |
380 const UnloadedExtensionInfo::Reason reason) { | 396 const UnloadedExtensionInfo::Reason reason) { |
381 BrowserThread::PostTask( | 397 BrowserThread::PostTask( |
382 BrowserThread::IO, | 398 BrowserThread::IO, |
383 FROM_HERE, | 399 FROM_HERE, |
384 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); | 400 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
385 } | 401 } |
386 | 402 |
387 } // namespace extensions | 403 } // namespace extensions |
OLD | NEW |