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" |
(...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 iter != extensions_.end(); ++iter) { | 2028 iter != extensions_.end(); ++iter) { |
2029 const Extension* extension = *iter; | 2029 const Extension* extension = *iter; |
2030 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) | 2030 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) |
2031 extension_ids.insert(extension->id()); | 2031 extension_ids.insert(extension->id()); |
2032 } | 2032 } |
2033 | 2033 |
2034 child_process_logging::SetActiveExtensions(extension_ids); | 2034 child_process_logging::SetActiveExtensions(extension_ids); |
2035 } | 2035 } |
2036 | 2036 |
2037 void ExtensionService::OnExtensionInstalled( | 2037 void ExtensionService::OnExtensionInstalled( |
2038 const Extension* extension, | 2038 const Extension* extension, bool from_webstore, int page_index) { |
2039 bool from_webstore, | |
2040 const StringOrdinal& page_ordinal) { | |
2041 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2039 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2042 | 2040 |
2043 // Ensure extension is deleted unless we transfer ownership. | 2041 // Ensure extension is deleted unless we transfer ownership. |
2044 scoped_refptr<const Extension> scoped_extension(extension); | 2042 scoped_refptr<const Extension> scoped_extension(extension); |
2045 const std::string& id = extension->id(); | 2043 const std::string& id = extension->id(); |
2046 // Extensions installed by policy can't be disabled. So even if a previous | 2044 // Extensions installed by policy can't be disabled. So even if a previous |
2047 // installation disabled the extension, make sure it is now enabled. | 2045 // installation disabled the extension, make sure it is now enabled. |
2048 bool initial_enable = | 2046 bool initial_enable = |
2049 !extension_prefs_->IsExtensionDisabled(id) || | 2047 !extension_prefs_->IsExtensionDisabled(id) || |
2050 !Extension::UserMayDisable(extension->location()); | 2048 !Extension::UserMayDisable(extension->location()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", | 2085 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", |
2088 extension->GetType(), 100); | 2086 extension->GetType(), 100); |
2089 RecordPermissionMessagesHistogram( | 2087 RecordPermissionMessagesHistogram( |
2090 extension, "Extensions.Permissions_Install"); | 2088 extension, "Extensions.Permissions_Install"); |
2091 } | 2089 } |
2092 | 2090 |
2093 extension_prefs_->OnExtensionInstalled( | 2091 extension_prefs_->OnExtensionInstalled( |
2094 extension, | 2092 extension, |
2095 initial_enable ? Extension::ENABLED : Extension::DISABLED, | 2093 initial_enable ? Extension::ENABLED : Extension::DISABLED, |
2096 from_webstore, | 2094 from_webstore, |
2097 page_ordinal); | 2095 page_index); |
2098 | 2096 |
2099 // Unpacked extensions default to allowing file access, but if that has been | 2097 // Unpacked extensions default to allowing file access, but if that has been |
2100 // overridden, don't reset the value. | 2098 // overridden, don't reset the value. |
2101 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && | 2099 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && |
2102 !extension_prefs_->HasAllowFileAccessSetting(id)) { | 2100 !extension_prefs_->HasAllowFileAccessSetting(id)) { |
2103 extension_prefs_->SetAllowFileAccess(id, true); | 2101 extension_prefs_->SetAllowFileAccess(id, true); |
2104 } | 2102 } |
2105 | 2103 |
2106 // If the extension should automatically block network startup (e.g., it uses | 2104 // If the extension should automatically block network startup (e.g., it uses |
2107 // the webRequest API), set the preference. Otherwise clear it, in case the | 2105 // the webRequest API), set the preference. Otherwise clear it, in case the |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 const ExtensionResource &resource, | 2533 const ExtensionResource &resource, |
2536 int index) { | 2534 int index) { |
2537 // If the image failed to load (e.g. if the resource being loaded was empty) | 2535 // If the image failed to load (e.g. if the resource being loaded was empty) |
2538 // use the standard application icon. | 2536 // use the standard application icon. |
2539 if (!image || image->isNull()) | 2537 if (!image || image->isNull()) |
2540 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON); | 2538 image = ExtensionIconSource::LoadImageByResourceId(IDR_APP_DEFAULT_ICON); |
2541 | 2539 |
2542 shortcut_info_.favicon = *image; | 2540 shortcut_info_.favicon = *image; |
2543 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); | 2541 web_app::CreateShortcut(profile_->GetPath(), shortcut_info_); |
2544 } | 2542 } |
OLD | NEW |