| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/trace_event/trace_event.h" |
| 19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 21 #include "chrome/browser/content_settings/content_settings_internal_extension_pr
ovider.h" | 22 #include "chrome/browser/content_settings/content_settings_internal_extension_pr
ovider.h" |
| 22 #include "chrome/browser/extensions/api/content_settings/content_settings_custom
_extension_provider.h" | 23 #include "chrome/browser/extensions/api/content_settings/content_settings_custom
_extension_provider.h" |
| 23 #include "chrome/browser/extensions/api/content_settings/content_settings_servic
e.h" | 24 #include "chrome/browser/extensions/api/content_settings/content_settings_servic
e.h" |
| 24 #include "chrome/browser/extensions/app_data_migrator.h" | 25 #include "chrome/browser/extensions/app_data_migrator.h" |
| 25 #include "chrome/browser/extensions/component_loader.h" | 26 #include "chrome/browser/extensions/component_loader.h" |
| 26 #include "chrome/browser/extensions/crx_installer.h" | 27 #include "chrome/browser/extensions/crx_installer.h" |
| 27 #include "chrome/browser/extensions/data_deleter.h" | 28 #include "chrome/browser/extensions/data_deleter.h" |
| 28 #include "chrome/browser/extensions/extension_action_storage_manager.h" | 29 #include "chrome/browser/extensions/extension_action_storage_manager.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // hundreds of callers of this function, and many might assume that this | 378 // hundreds of callers of this function, and many might assume that this |
| 378 // includes those that have been disabled due to blacklisting or blocking. | 379 // includes those that have been disabled due to blacklisting or blocking. |
| 379 include_mask |= ExtensionRegistry::DISABLED | | 380 include_mask |= ExtensionRegistry::DISABLED | |
| 380 ExtensionRegistry::BLACKLISTED | ExtensionRegistry::BLOCKED; | 381 ExtensionRegistry::BLACKLISTED | ExtensionRegistry::BLOCKED; |
| 381 } | 382 } |
| 382 return registry_->GetExtensionById(id, include_mask); | 383 return registry_->GetExtensionById(id, include_mask); |
| 383 } | 384 } |
| 384 | 385 |
| 385 void ExtensionService::Init() { | 386 void ExtensionService::Init() { |
| 386 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 387 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 387 | 388 TRACE_EVENT0("browser,startup", "ExtensionService::Init"); |
| 388 base::Time begin_time = base::Time::Now(); | 389 base::Time begin_time = base::Time::Now(); |
| 389 | 390 |
| 390 DCHECK(!is_ready()); // Can't redo init. | 391 DCHECK(!is_ready()); // Can't redo init. |
| 391 DCHECK_EQ(registry_->enabled_extensions().size(), 0u); | 392 DCHECK_EQ(registry_->enabled_extensions().size(), 0u); |
| 392 | 393 |
| 393 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 394 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 394 if (cmd_line->HasSwitch(switches::kInstallEphemeralAppFromWebstore)) { | 395 if (cmd_line->HasSwitch(switches::kInstallEphemeralAppFromWebstore)) { |
| 395 // The sole purpose of this launch is to install a new extension from CWS | 396 // The sole purpose of this launch is to install a new extension from CWS |
| 396 // and immediately terminate: loading already installed extensions is | 397 // and immediately terminate: loading already installed extensions is |
| 397 // unnecessary and may interfere with the inline install dialog (e.g. if an | 398 // unnecessary and may interfere with the inline install dialog (e.g. if an |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); | 2042 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); |
| 2042 } | 2043 } |
| 2043 | 2044 |
| 2044 const Extension* ExtensionService::GetPendingExtensionUpdate( | 2045 const Extension* ExtensionService::GetPendingExtensionUpdate( |
| 2045 const std::string& id) const { | 2046 const std::string& id) const { |
| 2046 return delayed_installs_.GetByID(id); | 2047 return delayed_installs_.GetByID(id); |
| 2047 } | 2048 } |
| 2048 | 2049 |
| 2049 void ExtensionService::RegisterContentSettings( | 2050 void ExtensionService::RegisterContentSettings( |
| 2050 HostContentSettingsMap* host_content_settings_map) { | 2051 HostContentSettingsMap* host_content_settings_map) { |
| 2052 TRACE_EVENT0("browser,startup", "ExtensionService::RegisterContentSettings"); |
| 2051 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2053 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2052 host_content_settings_map->RegisterProvider( | 2054 host_content_settings_map->RegisterProvider( |
| 2053 HostContentSettingsMap::INTERNAL_EXTENSION_PROVIDER, | 2055 HostContentSettingsMap::INTERNAL_EXTENSION_PROVIDER, |
| 2054 scoped_ptr<content_settings::ObservableProvider>( | 2056 scoped_ptr<content_settings::ObservableProvider>( |
| 2055 new content_settings::InternalExtensionProvider(profile_))); | 2057 new content_settings::InternalExtensionProvider(profile_))); |
| 2056 | 2058 |
| 2057 host_content_settings_map->RegisterProvider( | 2059 host_content_settings_map->RegisterProvider( |
| 2058 HostContentSettingsMap::CUSTOM_EXTENSION_PROVIDER, | 2060 HostContentSettingsMap::CUSTOM_EXTENSION_PROVIDER, |
| 2059 scoped_ptr<content_settings::ObservableProvider>( | 2061 scoped_ptr<content_settings::ObservableProvider>( |
| 2060 new content_settings::CustomExtensionProvider( | 2062 new content_settings::CustomExtensionProvider( |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 } | 2549 } |
| 2548 | 2550 |
| 2549 void ExtensionService::OnProfileDestructionStarted() { | 2551 void ExtensionService::OnProfileDestructionStarted() { |
| 2550 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2552 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2551 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2553 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2552 it != ids_to_unload.end(); | 2554 it != ids_to_unload.end(); |
| 2553 ++it) { | 2555 ++it) { |
| 2554 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2556 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2555 } | 2557 } |
| 2556 } | 2558 } |
| OLD | NEW |