Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: chrome/browser/extensions/external_install_manager.cc

Issue 2635443002: [Reland][Extensions] Enable sideloading prompt on mac on canary (Closed)
Patch Set: fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/external_install_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/external_install_manager.h" 5 #include "chrome/browser/extensions/external_install_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/extensions/external_install_error.h" 13 #include "chrome/browser/extensions/external_install_error.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "components/version_info/version_info.h"
15 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
17 #include "extensions/browser/extension_prefs.h" 18 #include "extensions/browser/extension_prefs.h"
18 #include "extensions/browser/extension_registry.h" 19 #include "extensions/browser/extension_registry.h"
19 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
20 #include "extensions/common/feature_switch.h" 21 #include "extensions/common/feature_switch.h"
22 #include "extensions/common/features/feature_channel.h"
21 #include "extensions/common/manifest.h" 23 #include "extensions/common/manifest.h"
22 #include "extensions/common/manifest_url_handlers.h" 24 #include "extensions/common/manifest_url_handlers.h"
23 25
24 namespace extensions { 26 namespace extensions {
25 27
26 namespace { 28 namespace {
27 29
28 // Histogram values for logging events related to externally installed 30 // Histogram values for logging events related to externally installed
29 // extensions. 31 // extensions.
30 enum ExternalExtensionEvent { 32 enum ExternalExtensionEvent {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 for (const auto& extension : 79 for (const auto& extension :
78 ExtensionRegistry::Get(browser_context)->disabled_extensions()) { 80 ExtensionRegistry::Get(browser_context)->disabled_extensions()) {
79 if (IsUnacknowledgedExternalExtension(*extension)) 81 if (IsUnacknowledgedExternalExtension(*extension))
80 unacknowledged_ids_.insert(extension->id()); 82 unacknowledged_ids_.insert(extension->id());
81 } 83 }
82 } 84 }
83 85
84 ExternalInstallManager::~ExternalInstallManager() { 86 ExternalInstallManager::~ExternalInstallManager() {
85 } 87 }
86 88
89
90 bool ExternalInstallManager::IsPromptingEnabled() {
91 // Enable this feature on canary on mac.
92 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD)
93 return GetCurrentChannel() <= version_info::Channel::CANARY;
94 #else
95 return FeatureSwitch::prompt_for_external_extensions()->IsEnabled();
96 #endif
97 }
98
87 void ExternalInstallManager::AddExternalInstallError(const Extension* extension, 99 void ExternalInstallManager::AddExternalInstallError(const Extension* extension,
88 bool is_new_profile) { 100 bool is_new_profile) {
89 // Error already exists or has been previously shown. 101 // Error already exists or has been previously shown.
90 if (base::ContainsKey(errors_, extension->id()) || 102 if (base::ContainsKey(errors_, extension->id()) ||
91 shown_ids_.count(extension->id()) > 0) 103 shown_ids_.count(extension->id()) > 0)
92 return; 104 return;
93 105
94 ExternalInstallError::AlertType alert_type = 106 ExternalInstallError::AlertType alert_type =
95 (ManifestURL::UpdatesFromGallery(extension) && !is_new_profile) 107 (ManifestURL::UpdatesFromGallery(extension) && !is_new_profile)
96 ? ExternalInstallError::BUBBLE_ALERT 108 ? ExternalInstallError::BUBBLE_ALERT
(...skipping 12 matching lines...) Expand all
109 if (iter->second.get() == currently_visible_install_alert_) 121 if (iter->second.get() == currently_visible_install_alert_)
110 currently_visible_install_alert_ = nullptr; 122 currently_visible_install_alert_ = nullptr;
111 errors_.erase(iter); 123 errors_.erase(iter);
112 unacknowledged_ids_.erase(extension_id); 124 unacknowledged_ids_.erase(extension_id);
113 UpdateExternalExtensionAlert(); 125 UpdateExternalExtensionAlert();
114 } 126 }
115 } 127 }
116 128
117 void ExternalInstallManager::UpdateExternalExtensionAlert() { 129 void ExternalInstallManager::UpdateExternalExtensionAlert() {
118 // If the feature is not enabled do nothing. 130 // If the feature is not enabled do nothing.
119 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) 131 if (!IsPromptingEnabled())
120 return; 132 return;
121 133
122 // Look for any extensions that were disabled because of being unacknowledged 134 // Look for any extensions that were disabled because of being unacknowledged
123 // external extensions. 135 // external extensions.
124 const ExtensionSet& disabled_extensions = 136 const ExtensionSet& disabled_extensions =
125 ExtensionRegistry::Get(browser_context_)->disabled_extensions(); 137 ExtensionRegistry::Get(browser_context_)->disabled_extensions();
126 for (const auto& id : unacknowledged_ids_) { 138 for (const auto& id : unacknowledged_ids_) {
127 if (base::ContainsKey(errors_, id) || shown_ids_.count(id) > 0) 139 if (base::ContainsKey(errors_, id) || shown_ids_.count(id) > 0)
128 continue; 140 continue;
129 141
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 void ExternalInstallManager::OnExtensionUninstalled( 224 void ExternalInstallManager::OnExtensionUninstalled(
213 content::BrowserContext* browser_context, 225 content::BrowserContext* browser_context,
214 const Extension* extension, 226 const Extension* extension,
215 extensions::UninstallReason reason) { 227 extensions::UninstallReason reason) {
216 if (unacknowledged_ids_.erase(extension->id())) 228 if (unacknowledged_ids_.erase(extension->id()))
217 LogExternalExtensionEvent(extension, EXTERNAL_EXTENSION_UNINSTALLED); 229 LogExternalExtensionEvent(extension, EXTERNAL_EXTENSION_UNINSTALLED);
218 } 230 }
219 231
220 bool ExternalInstallManager::IsUnacknowledgedExternalExtension( 232 bool ExternalInstallManager::IsUnacknowledgedExternalExtension(
221 const Extension& extension) const { 233 const Extension& extension) const {
222 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) 234 if (!IsPromptingEnabled())
223 return false; 235 return false;
224 236
225 int disable_reasons = extension_prefs_->GetDisableReasons(extension.id()); 237 int disable_reasons = extension_prefs_->GetDisableReasons(extension.id());
226 bool is_from_sideload_wipeout = 238 bool is_from_sideload_wipeout =
227 (disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT) != 0; 239 (disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT) != 0;
228 // We don't consider extensions that weren't disabled for being external so 240 // We don't consider extensions that weren't disabled for being external so
229 // that we grandfather in extensions. External extensions are only disabled on 241 // that we grandfather in extensions. External extensions are only disabled on
230 // install with the "prompt for external extensions" feature enabled. 242 // install with the "prompt for external extensions" feature enabled.
231 bool is_disabled_external = 243 bool is_disabled_external =
232 (disable_reasons & Extension::DISABLE_EXTERNAL_EXTENSION) != 0; 244 (disable_reasons & Extension::DISABLE_EXTERNAL_EXTENSION) != 0;
(...skipping 11 matching lines...) Expand all
244 // It's a shame we have to use the notification system (instead of the 256 // It's a shame we have to use the notification system (instead of the
245 // registry observer) for this, but the ExtensionUnloaded notification is 257 // registry observer) for this, but the ExtensionUnloaded notification is
246 // not sent out if the extension is disabled (which it is here). 258 // not sent out if the extension is disabled (which it is here).
247 const std::string& extension_id = 259 const std::string& extension_id =
248 content::Details<const Extension>(details).ptr()->id(); 260 content::Details<const Extension>(details).ptr()->id();
249 if (base::ContainsKey(errors_, extension_id)) 261 if (base::ContainsKey(errors_, extension_id))
250 RemoveExternalInstallError(extension_id); 262 RemoveExternalInstallError(extension_id);
251 } 263 }
252 264
253 } // namespace extensions 265 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_install_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698