| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 20 #include "base/time.h" | 20 #include "base/time.h" |
| 21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "base/version.h" | 23 #include "base/version.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/debugger/devtools_manager.h" | 25 #include "chrome/browser/debugger/devtools_manager.h" |
| 26 #include "chrome/browser/extensions/crx_installer.h" | 26 #include "chrome/browser/extensions/crx_installer.h" |
| 27 #include "chrome/browser/extensions/default_apps.h" | 27 #include "chrome/browser/extensions/apps_promo.h" |
| 28 #include "chrome/browser/extensions/extension_accessibility_api.h" | 28 #include "chrome/browser/extensions/extension_accessibility_api.h" |
| 29 #include "chrome/browser/extensions/extension_bookmarks_module.h" | 29 #include "chrome/browser/extensions/extension_bookmarks_module.h" |
| 30 #include "chrome/browser/extensions/extension_browser_event_router.h" | 30 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 31 #include "chrome/browser/extensions/extension_cookies_api.h" | 31 #include "chrome/browser/extensions/extension_cookies_api.h" |
| 32 #include "chrome/browser/extensions/extension_data_deleter.h" | 32 #include "chrome/browser/extensions/extension_data_deleter.h" |
| 33 #include "chrome/browser/extensions/extension_error_reporter.h" | 33 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 34 #include "chrome/browser/extensions/extension_history_api.h" | 34 #include "chrome/browser/extensions/extension_history_api.h" |
| 35 #include "chrome/browser/extensions/extension_host.h" | 35 #include "chrome/browser/extensions/extension_host.h" |
| 36 #include "chrome/browser/extensions/extension_management_api.h" | 36 #include "chrome/browser/extensions/extension_management_api.h" |
| 37 #include "chrome/browser/extensions/extension_preference_api.h" | 37 #include "chrome/browser/extensions/extension_preference_api.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 ExtensionPrefs* extension_prefs, | 403 ExtensionPrefs* extension_prefs, |
| 404 bool autoupdate_enabled) | 404 bool autoupdate_enabled) |
| 405 : profile_(profile), | 405 : profile_(profile), |
| 406 extension_prefs_(extension_prefs), | 406 extension_prefs_(extension_prefs), |
| 407 ALLOW_THIS_IN_INITIALIZER_LIST(pending_extension_manager_(*this)), | 407 ALLOW_THIS_IN_INITIALIZER_LIST(pending_extension_manager_(*this)), |
| 408 install_directory_(install_directory), | 408 install_directory_(install_directory), |
| 409 extensions_enabled_(true), | 409 extensions_enabled_(true), |
| 410 show_extensions_prompts_(true), | 410 show_extensions_prompts_(true), |
| 411 ready_(false), | 411 ready_(false), |
| 412 ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)), | 412 ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)), |
| 413 default_apps_(profile->GetPrefs(), | 413 apps_promo_(profile->GetPrefs()), |
| 414 g_browser_process->GetApplicationLocale()), | |
| 415 event_routers_initialized_(false) { | 414 event_routers_initialized_(false) { |
| 416 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 415 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 417 | 416 |
| 418 // Figure out if extension installation should be enabled. | 417 // Figure out if extension installation should be enabled. |
| 419 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 418 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 420 extensions_enabled_ = false; | 419 extensions_enabled_ = false; |
| 421 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 420 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 422 extensions_enabled_ = false; | 421 extensions_enabled_ = false; |
| 423 } | 422 } |
| 424 | 423 |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 NotificationType::THEME_INSTALLED, | 1666 NotificationType::THEME_INSTALLED, |
| 1668 Source<Profile>(profile_), | 1667 Source<Profile>(profile_), |
| 1669 Details<const Extension>(extension)); | 1668 Details<const Extension>(extension)); |
| 1670 } else { | 1669 } else { |
| 1671 NotificationService::current()->Notify( | 1670 NotificationService::current()->Notify( |
| 1672 NotificationType::EXTENSION_INSTALLED, | 1671 NotificationType::EXTENSION_INSTALLED, |
| 1673 Source<Profile>(profile_), | 1672 Source<Profile>(profile_), |
| 1674 Details<const Extension>(extension)); | 1673 Details<const Extension>(extension)); |
| 1675 } | 1674 } |
| 1676 | 1675 |
| 1677 if (extension->is_app()) { | |
| 1678 ExtensionIdSet installed_ids = GetAppIds(); | |
| 1679 installed_ids.insert(id); | |
| 1680 default_apps_.DidInstallApp(installed_ids); | |
| 1681 } | |
| 1682 | |
| 1683 // Transfer ownership of |extension| to AddExtension. | 1676 // Transfer ownership of |extension| to AddExtension. |
| 1684 AddExtension(scoped_extension); | 1677 AddExtension(scoped_extension); |
| 1685 } | 1678 } |
| 1686 | 1679 |
| 1687 const Extension* ExtensionService::GetExtensionByIdInternal( | 1680 const Extension* ExtensionService::GetExtensionByIdInternal( |
| 1688 const std::string& id, bool include_enabled, bool include_disabled) const { | 1681 const std::string& id, bool include_enabled, bool include_disabled) const { |
| 1689 std::string lowercase_id = StringToLowerASCII(id); | 1682 std::string lowercase_id = StringToLowerASCII(id); |
| 1690 if (include_enabled) { | 1683 if (include_enabled) { |
| 1691 for (ExtensionList::const_iterator iter = extensions_.begin(); | 1684 for (ExtensionList::const_iterator iter = extensions_.begin(); |
| 1692 iter != extensions_.end(); ++iter) { | 1685 iter != extensions_.end(); ++iter) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 } | 1918 } |
| 1926 | 1919 |
| 1927 void ExtensionService::SetBeingUpgraded(const Extension* extension, | 1920 void ExtensionService::SetBeingUpgraded(const Extension* extension, |
| 1928 bool value) { | 1921 bool value) { |
| 1929 extension_runtime_data_[extension->id()].being_upgraded = value; | 1922 extension_runtime_data_[extension->id()].being_upgraded = value; |
| 1930 } | 1923 } |
| 1931 | 1924 |
| 1932 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { | 1925 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { |
| 1933 return &extension_runtime_data_[extension->id()].property_bag; | 1926 return &extension_runtime_data_[extension->id()].property_bag; |
| 1934 } | 1927 } |
| OLD | NEW |