| 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 ExtensionPrefs* extension_prefs, | 402 ExtensionPrefs* extension_prefs, |
| 403 bool autoupdate_enabled) | 403 bool autoupdate_enabled) |
| 404 : profile_(profile), | 404 : profile_(profile), |
| 405 extension_prefs_(extension_prefs), | 405 extension_prefs_(extension_prefs), |
| 406 ALLOW_THIS_IN_INITIALIZER_LIST(pending_extension_manager_(*this)), | 406 ALLOW_THIS_IN_INITIALIZER_LIST(pending_extension_manager_(*this)), |
| 407 install_directory_(install_directory), | 407 install_directory_(install_directory), |
| 408 extensions_enabled_(true), | 408 extensions_enabled_(true), |
| 409 show_extensions_prompts_(true), | 409 show_extensions_prompts_(true), |
| 410 ready_(false), | 410 ready_(false), |
| 411 ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)), | 411 ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)), |
| 412 default_apps_(profile->GetPrefs(), | 412 apps_promo_(profile->GetPrefs()), |
| 413 g_browser_process->GetApplicationLocale()), | |
| 414 event_routers_initialized_(false) { | 413 event_routers_initialized_(false) { |
| 415 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 414 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 416 | 415 |
| 417 // Figure out if extension installation should be enabled. | 416 // Figure out if extension installation should be enabled. |
| 418 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 417 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 419 extensions_enabled_ = false; | 418 extensions_enabled_ = false; |
| 420 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 419 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 421 extensions_enabled_ = false; | 420 extensions_enabled_ = false; |
| 422 } | 421 } |
| 423 | 422 |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 NotificationType::THEME_INSTALLED, | 1642 NotificationType::THEME_INSTALLED, |
| 1644 Source<Profile>(profile_), | 1643 Source<Profile>(profile_), |
| 1645 Details<const Extension>(extension)); | 1644 Details<const Extension>(extension)); |
| 1646 } else { | 1645 } else { |
| 1647 NotificationService::current()->Notify( | 1646 NotificationService::current()->Notify( |
| 1648 NotificationType::EXTENSION_INSTALLED, | 1647 NotificationType::EXTENSION_INSTALLED, |
| 1649 Source<Profile>(profile_), | 1648 Source<Profile>(profile_), |
| 1650 Details<const Extension>(extension)); | 1649 Details<const Extension>(extension)); |
| 1651 } | 1650 } |
| 1652 | 1651 |
| 1653 if (extension->is_app()) { | |
| 1654 ExtensionIdSet installed_ids = GetAppIds(); | |
| 1655 installed_ids.insert(id); | |
| 1656 default_apps_.DidInstallApp(installed_ids); | |
| 1657 } | |
| 1658 | |
| 1659 // Transfer ownership of |extension| to AddExtension. | 1652 // Transfer ownership of |extension| to AddExtension. |
| 1660 AddExtension(scoped_extension); | 1653 AddExtension(scoped_extension); |
| 1661 } | 1654 } |
| 1662 | 1655 |
| 1663 const Extension* ExtensionService::GetExtensionByIdInternal( | 1656 const Extension* ExtensionService::GetExtensionByIdInternal( |
| 1664 const std::string& id, bool include_enabled, bool include_disabled) const { | 1657 const std::string& id, bool include_enabled, bool include_disabled) const { |
| 1665 std::string lowercase_id = StringToLowerASCII(id); | 1658 std::string lowercase_id = StringToLowerASCII(id); |
| 1666 if (include_enabled) { | 1659 if (include_enabled) { |
| 1667 for (ExtensionList::const_iterator iter = extensions_.begin(); | 1660 for (ExtensionList::const_iterator iter = extensions_.begin(); |
| 1668 iter != extensions_.end(); ++iter) { | 1661 iter != extensions_.end(); ++iter) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1901 } | 1894 } |
| 1902 | 1895 |
| 1903 void ExtensionService::SetBeingUpgraded(const Extension* extension, | 1896 void ExtensionService::SetBeingUpgraded(const Extension* extension, |
| 1904 bool value) { | 1897 bool value) { |
| 1905 extension_runtime_data_[extension->id()].being_upgraded = value; | 1898 extension_runtime_data_[extension->id()].being_upgraded = value; |
| 1906 } | 1899 } |
| 1907 | 1900 |
| 1908 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { | 1901 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { |
| 1909 return &extension_runtime_data_[extension->id()].property_bag; | 1902 return &extension_runtime_data_[extension->id()].property_bag; |
| 1910 } | 1903 } |
| OLD | NEW |