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

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

Issue 2821123002: Differentiate new permissions from old in extension permission update bubble (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_disabled_ui.h" 5 #include "chrome/browser/extensions/extension_disabled_ui.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "extensions/common/extension.h" 45 #include "extensions/common/extension.h"
46 #include "extensions/common/extension_icon_set.h" 46 #include "extensions/common/extension_icon_set.h"
47 #include "extensions/common/manifest_handlers/icons_handler.h" 47 #include "extensions/common/manifest_handlers/icons_handler.h"
48 #include "extensions/common/permissions/permission_message.h" 48 #include "extensions/common/permissions/permission_message.h"
49 #include "extensions/common/permissions/permissions_data.h" 49 #include "extensions/common/permissions/permissions_data.h"
50 #include "ui/base/l10n/l10n_util.h" 50 #include "ui/base/l10n/l10n_util.h"
51 #include "ui/gfx/geometry/size.h" 51 #include "ui/gfx/geometry/size.h"
52 #include "ui/gfx/image/image.h" 52 #include "ui/gfx/image/image.h"
53 #include "ui/gfx/image/image_skia_operations.h" 53 #include "ui/gfx/image/image_skia_operations.h"
54 54
55 using extensions::Extension; 55 using extensions::Extension;
Devlin 2017/04/20 16:40:53 nit: now we can remove these "using" lines.
catmullings 2017/04/20 17:10:38 Done.
56 using extensions::PermissionMessage; 56 using extensions::PermissionMessage;
57 using extensions::PermissionMessages; 57 using extensions::PermissionMessages;
58 58
59 namespace { 59 namespace {
60 60
61 static const int kIconSize = extension_misc::EXTENSION_ICON_SMALL; 61 static const int kIconSize = extension_misc::EXTENSION_ICON_SMALL;
62 62
63 } // namespace 63 } // namespace
64 64
65 // ExtensionDisabledGlobalError ----------------------------------------------- 65 // ExtensionDisabledGlobalError -----------------------------------------------
66 66
67 class ExtensionDisabledGlobalError 67 namespace extensions {
68 : public GlobalErrorWithStandardBubble, 68
69 public content::NotificationObserver, 69 class ExtensionDisabledGlobalError : public GlobalErrorWithStandardBubble,
70 public extensions::ExtensionUninstallDialog::Delegate, 70 public content::NotificationObserver,
71 public extensions::ExtensionRegistryObserver { 71 public ExtensionUninstallDialog::Delegate,
72 public ExtensionRegistryObserver {
72 public: 73 public:
73 ExtensionDisabledGlobalError(ExtensionService* service, 74 ExtensionDisabledGlobalError(ExtensionService* service,
74 const Extension* extension, 75 const Extension* extension,
75 bool is_remote_install, 76 bool is_remote_install,
76 const gfx::Image& icon); 77 const gfx::Image& icon);
77 ~ExtensionDisabledGlobalError() override; 78 ~ExtensionDisabledGlobalError() override;
78 79
79 // GlobalError: 80 // GlobalError:
80 Severity GetSeverity() override; 81 Severity GetSeverity() override;
81 bool HasMenuItem() override; 82 bool HasMenuItem() override;
(...skipping 17 matching lines...) Expand all
99 100
100 private: 101 private:
101 // content::NotificationObserver: 102 // content::NotificationObserver:
102 void Observe(int type, 103 void Observe(int type,
103 const content::NotificationSource& source, 104 const content::NotificationSource& source,
104 const content::NotificationDetails& details) override; 105 const content::NotificationDetails& details) override;
105 106
106 // ExtensionRegistryObserver: 107 // ExtensionRegistryObserver:
107 void OnExtensionLoaded(content::BrowserContext* browser_context, 108 void OnExtensionLoaded(content::BrowserContext* browser_context,
108 const Extension* extension) override; 109 const Extension* extension) override;
109 void OnShutdown(extensions::ExtensionRegistry* registry) override; 110 void OnShutdown(ExtensionRegistry* registry) override;
110 111
111 void RemoveGlobalError(); 112 void RemoveGlobalError();
112 113
113 ExtensionService* service_; 114 ExtensionService* service_;
114 const Extension* extension_; 115 const Extension* extension_;
115 bool is_remote_install_; 116 bool is_remote_install_;
116 gfx::Image icon_; 117 gfx::Image icon_;
117 118
118 // How the user responded to the error; used for metrics. 119 // How the user responded to the error; used for metrics.
119 enum UserResponse { 120 enum UserResponse {
120 IGNORED, 121 IGNORED,
121 REENABLE, 122 REENABLE,
122 UNINSTALL, 123 UNINSTALL,
123 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY 124 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY
124 }; 125 };
125 UserResponse user_response_; 126 UserResponse user_response_;
126 127
127 std::unique_ptr<extensions::ExtensionUninstallDialog> uninstall_dialog_; 128 std::unique_ptr<ExtensionUninstallDialog> uninstall_dialog_;
128 129
129 // Helper to get menu command ID assigned for this extension's error. 130 // Helper to get menu command ID assigned for this extension's error.
130 extensions::ExtensionInstallErrorMenuItemIdProvider id_provider_; 131 ExtensionInstallErrorMenuItemIdProvider id_provider_;
131 132
132 content::NotificationRegistrar registrar_; 133 content::NotificationRegistrar registrar_;
133 134
134 ScopedObserver<extensions::ExtensionRegistry, 135 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
135 extensions::ExtensionRegistryObserver> registry_observer_; 136 registry_observer_;
136 }; 137 };
137 138
138 // TODO(yoz): create error at startup for disabled extensions. 139 // TODO(yoz): create error at startup for disabled extensions.
139 ExtensionDisabledGlobalError::ExtensionDisabledGlobalError( 140 ExtensionDisabledGlobalError::ExtensionDisabledGlobalError(
140 ExtensionService* service, 141 ExtensionService* service,
141 const Extension* extension, 142 const Extension* extension,
142 bool is_remote_install, 143 bool is_remote_install,
143 const gfx::Image& icon) 144 const gfx::Image& icon)
144 : service_(service), 145 : service_(service),
145 extension_(extension), 146 extension_(extension),
146 is_remote_install_(is_remote_install), 147 is_remote_install_(is_remote_install),
147 icon_(icon), 148 icon_(icon),
148 user_response_(IGNORED), 149 user_response_(IGNORED),
149 registry_observer_(this) { 150 registry_observer_(this) {
150 if (icon_.IsEmpty()) { 151 if (icon_.IsEmpty()) {
151 icon_ = gfx::Image( 152 icon_ = gfx::Image(gfx::ImageSkiaOperations::CreateResizedImage(
152 gfx::ImageSkiaOperations::CreateResizedImage( 153 extension_->is_app() ? util::GetDefaultAppIcon()
153 extension_->is_app() ? 154 : util::GetDefaultExtensionIcon(),
154 extensions::util::GetDefaultAppIcon() : 155 skia::ImageOperations::RESIZE_BEST, gfx::Size(kIconSize, kIconSize)));
155 extensions::util::GetDefaultExtensionIcon(),
156 skia::ImageOperations::RESIZE_BEST,
157 gfx::Size(kIconSize, kIconSize)));
158 } 156 }
159 registry_observer_.Add( 157 registry_observer_.Add(ExtensionRegistry::Get(service->profile()));
160 extensions::ExtensionRegistry::Get(service->profile())); 158 registrar_.Add(this, NOTIFICATION_EXTENSION_REMOVED,
161 registrar_.Add(this,
162 extensions::NOTIFICATION_EXTENSION_REMOVED,
163 content::Source<Profile>(service->profile())); 159 content::Source<Profile>(service->profile()));
164 } 160 }
165 161
166 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() {} 162 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() {}
167 163
168 GlobalError::Severity ExtensionDisabledGlobalError::GetSeverity() { 164 GlobalError::Severity ExtensionDisabledGlobalError::GetSeverity() {
169 return SEVERITY_LOW; 165 return SEVERITY_LOW;
170 } 166 }
171 167
172 bool ExtensionDisabledGlobalError::HasMenuItem() { 168 bool ExtensionDisabledGlobalError::HasMenuItem() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 base::UTF8ToUTF16(extension_->name())); 204 base::UTF8ToUTF16(extension_->name()));
209 } else { 205 } else {
210 return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE, 206 return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_ERROR_TITLE,
211 base::UTF8ToUTF16(extension_->name())); 207 base::UTF8ToUTF16(extension_->name()));
212 } 208 }
213 } 209 }
214 210
215 std::vector<base::string16> 211 std::vector<base::string16>
216 ExtensionDisabledGlobalError::GetBubbleViewMessages() { 212 ExtensionDisabledGlobalError::GetBubbleViewMessages() {
217 std::vector<base::string16> messages; 213 std::vector<base::string16> messages;
214
215 std::unique_ptr<const PermissionSet> granted_permissions =
216 ExtensionPrefs::Get(service_->GetBrowserContext())
217 ->GetGrantedPermissions(extension_->id());
218
218 PermissionMessages permission_warnings = 219 PermissionMessages permission_warnings =
219 extension_->permissions_data()->GetPermissionMessages(); 220 extension_->permissions_data()->GetNewPermissionMessages(
221 *granted_permissions);
222
220 if (is_remote_install_) { 223 if (is_remote_install_) {
221 if (!permission_warnings.empty()) 224 if (!permission_warnings.empty())
222 messages.push_back( 225 messages.push_back(
223 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO)); 226 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO));
224 } else { 227 } else {
225 // TODO(treib): If NeedCustodianApprovalForPermissionIncrease, add an extra 228 // TODO(treib): If NeedCustodianApprovalForPermissionIncrease, add an extra
226 // message for supervised users. crbug.com/461261 229 // message for supervised users. crbug.com/461261
227 messages.push_back(l10n_util::GetStringFUTF16( 230 messages.push_back(
228 extension_->is_app() ? IDS_APP_DISABLED_ERROR_LABEL 231 l10n_util::GetStringUTF16(IDS_EXTENSION_DISABLED_ERROR_LABEL));
229 : IDS_EXTENSION_DISABLED_ERROR_LABEL,
230 base::UTF8ToUTF16(extension_->name())));
231 messages.push_back(l10n_util::GetStringUTF16(
232 IDS_EXTENSION_PROMPT_WILL_NOW_HAVE_ACCESS_TO));
233 } 232 }
234 for (const PermissionMessage& msg : permission_warnings) { 233 for (const PermissionMessage& msg : permission_warnings) {
235 messages.push_back(l10n_util::GetStringFUTF16(IDS_EXTENSION_PERMISSION_LINE, 234 messages.push_back(l10n_util::GetStringFUTF16(IDS_EXTENSION_PERMISSION_LINE,
236 msg.message())); 235 msg.message()));
237 } 236 }
238 return messages; 237 return messages;
239 } 238 }
240 239
241 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() { 240 base::string16 ExtensionDisabledGlobalError::GetBubbleViewAcceptButtonLabel() {
242 if (extensions::util::IsExtensionSupervised(extension_, 241 if (util::IsExtensionSupervised(extension_, service_->profile())) {
243 service_->profile())) {
244 // TODO(treib): Probably use a new string here once we get UX design. 242 // TODO(treib): Probably use a new string here once we get UX design.
245 // For now, just use "OK". crbug.com/461261 243 // For now, just use "OK". crbug.com/461261
246 return l10n_util::GetStringUTF16(IDS_OK); 244 return l10n_util::GetStringUTF16(IDS_OK);
247 } 245 }
248 if (is_remote_install_) { 246 if (is_remote_install_) {
249 return l10n_util::GetStringUTF16( 247 return l10n_util::GetStringUTF16(
250 extension_->is_app() 248 extension_->is_app()
251 ? IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP 249 ? IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_APP
252 : IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION); 250 : IDS_EXTENSION_PROMPT_REMOTE_INSTALL_BUTTON_EXTENSION);
253 } 251 }
254 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_RE_ENABLE_BUTTON); 252 return l10n_util::GetStringUTF16(
253 IDS_EXTENSION_PROMPT_PERMISSIONS_ACCEPT_BUTTON);
255 } 254 }
256 255
257 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() { 256 base::string16 ExtensionDisabledGlobalError::GetBubbleViewCancelButtonLabel() {
258 if (extensions::util::IsExtensionSupervised(extension_, 257 if (util::IsExtensionSupervised(extension_, service_->profile())) {
259 service_->profile())) {
260 // The supervised user can't approve the update, and hence there is no 258 // The supervised user can't approve the update, and hence there is no
261 // "cancel" button. Return an empty string such that the "cancel" button 259 // "cancel" button. Return an empty string such that the "cancel" button
262 // is not shown in the dialog. 260 // is not shown in the dialog.
263 return base::string16(); 261 return base::string16();
264 } 262 }
265 return l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL); 263 return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON);
266 } 264 }
267 265
268 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { 266 void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) {
269 // If the user takes an action, |user_response_| is set in 267 // If the user takes an action, |user_response_| is set in
270 // BubbleView[Cancel|Accept]Pressed(). Otherwise, the IGNORE value set in the 268 // BubbleView[Cancel|Accept]Pressed(). Otherwise, the IGNORE value set in the
271 // constructor is correct. 269 // constructor is correct.
272 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponseRemoteInstall2", 270 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponseRemoteInstall2",
273 user_response_, 271 user_response_,
274 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); 272 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY);
275 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse2", 273 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse2",
276 user_response_, 274 user_response_,
277 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); 275 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY);
278 // Reset in case the user does not follow through on subsequent dialogs to 276 // Reset in case the user does not follow through on subsequent dialogs to
279 // confirm removal decision, in which case the bubble can be shown again 277 // confirm removal decision, in which case the bubble can be shown again
280 // when the user clicks on the global error in the menu. 278 // when the user clicks on the global error in the menu.
281 user_response_ = IGNORED; 279 user_response_ = IGNORED;
282 } 280 }
283 281
284 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( 282 void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed(
285 Browser* browser) { 283 Browser* browser) {
286 if (extensions::util::IsExtensionSupervised(extension_, 284 if (util::IsExtensionSupervised(extension_, service_->profile())) {
287 service_->profile())) {
288 return; 285 return;
289 } 286 }
290 user_response_ = REENABLE; 287 user_response_ = REENABLE;
291 // Delay extension reenabling so this bubble closes properly. 288 // Delay extension reenabling so this bubble closes properly.
292 base::ThreadTaskRunnerHandle::Get()->PostTask( 289 base::ThreadTaskRunnerHandle::Get()->PostTask(
293 FROM_HERE, 290 FROM_HERE,
294 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension, 291 base::Bind(&ExtensionService::GrantPermissionsAndEnableExtension,
295 service_->AsWeakPtr(), extension_)); 292 service_->AsWeakPtr(), extension_));
296 } 293 }
297 294
298 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( 295 void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed(
299 Browser* browser) { 296 Browser* browser) {
300 // For custodian-installed extensions, this button should not exist because 297 // For custodian-installed extensions, this button should not exist because
301 // there is only an "OK" button. 298 // there is only an "OK" button.
302 // Supervised users may never remove custodian-installed extensions. 299 // Supervised users may never remove custodian-installed extensions.
303 DCHECK(!extensions::util::IsExtensionSupervised(extension_, 300 DCHECK(!util::IsExtensionSupervised(extension_, service_->profile()));
304 service_->profile())); 301 uninstall_dialog_.reset(ExtensionUninstallDialog::Create(
305 uninstall_dialog_.reset(extensions::ExtensionUninstallDialog::Create(
306 service_->profile(), browser->window()->GetNativeWindow(), this)); 302 service_->profile(), browser->window()->GetNativeWindow(), this));
307 user_response_ = UNINSTALL; 303 user_response_ = UNINSTALL;
308 // Delay showing the uninstall dialog, so that this function returns 304 // Delay showing the uninstall dialog, so that this function returns
309 // immediately, to close the bubble properly. See crbug.com/121544. 305 // immediately, to close the bubble properly. See crbug.com/121544.
310 base::ThreadTaskRunnerHandle::Get()->PostTask( 306 base::ThreadTaskRunnerHandle::Get()->PostTask(
311 FROM_HERE, 307 FROM_HERE, base::Bind(&ExtensionUninstallDialog::ConfirmUninstall,
312 base::Bind(&extensions::ExtensionUninstallDialog::ConfirmUninstall, 308 uninstall_dialog_->AsWeakPtr(), extension_,
313 uninstall_dialog_->AsWeakPtr(), extension_, 309 UNINSTALL_REASON_EXTENSION_DISABLED,
314 extensions::UNINSTALL_REASON_EXTENSION_DISABLED, 310 UNINSTALL_SOURCE_PERMISSIONS_INCREASE));
315 extensions::UNINSTALL_SOURCE_PERMISSIONS_INCREASE));
316 } 311 }
317 312
318 bool ExtensionDisabledGlobalError::ShouldCloseOnDeactivate() const { 313 bool ExtensionDisabledGlobalError::ShouldCloseOnDeactivate() const {
319 // Since this indicates that an extension was disabled, we should definitely 314 // Since this indicates that an extension was disabled, we should definitely
320 // have the user acknowledge it, rather than having the bubble disappear when 315 // have the user acknowledge it, rather than having the bubble disappear when
321 // a new window pops up. 316 // a new window pops up.
322 return false; 317 return false;
323 } 318 }
324 319
325 bool ExtensionDisabledGlobalError::ShouldShowCloseButton() const { 320 bool ExtensionDisabledGlobalError::ShouldShowCloseButton() const {
326 // As we don't close the bubble on deactivation (see ShouldCloseOnDeactivate), 321 // As we don't close the bubble on deactivation (see ShouldCloseOnDeactivate),
327 // we add a close button so the user doesn't *need* to act right away. 322 // we add a close button so the user doesn't *need* to act right away.
328 // If the bubble is closed, the error remains in the wrench menu and the user 323 // If the bubble is closed, the error remains in the wrench menu and the user
329 // can address it later. 324 // can address it later.
330 return true; 325 return true;
331 } 326 }
332 327
333 void ExtensionDisabledGlobalError::OnExtensionUninstallDialogClosed( 328 void ExtensionDisabledGlobalError::OnExtensionUninstallDialogClosed(
334 bool did_start_uninstall, 329 bool did_start_uninstall,
335 const base::string16& error) { 330 const base::string16& error) {
336 // No need to do anything. 331 // No need to do anything.
337 } 332 }
338 333
339 void ExtensionDisabledGlobalError::Observe( 334 void ExtensionDisabledGlobalError::Observe(
340 int type, 335 int type,
341 const content::NotificationSource& source, 336 const content::NotificationSource& source,
342 const content::NotificationDetails& details) { 337 const content::NotificationDetails& details) {
343 // The error is invalidated if the extension has been loaded or removed. 338 // The error is invalidated if the extension has been loaded or removed.
344 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_REMOVED, type); 339 DCHECK_EQ(NOTIFICATION_EXTENSION_REMOVED, type);
345 const Extension* extension = content::Details<const Extension>(details).ptr(); 340 const Extension* extension = content::Details<const Extension>(details).ptr();
346 if (extension != extension_) 341 if (extension != extension_)
347 return; 342 return;
348 RemoveGlobalError(); 343 RemoveGlobalError();
349 } 344 }
350 345
351 void ExtensionDisabledGlobalError::OnExtensionLoaded( 346 void ExtensionDisabledGlobalError::OnExtensionLoaded(
352 content::BrowserContext* browser_context, 347 content::BrowserContext* browser_context,
353 const Extension* extension) { 348 const Extension* extension) {
354 if (extension != extension_) 349 if (extension != extension_)
355 return; 350 return;
356 RemoveGlobalError(); 351 RemoveGlobalError();
357 } 352 }
358 353
359 void ExtensionDisabledGlobalError::OnShutdown( 354 void ExtensionDisabledGlobalError::OnShutdown(ExtensionRegistry* registry) {
360 extensions::ExtensionRegistry* registry) { 355 DCHECK_EQ(ExtensionRegistry::Get(service_->profile()), registry);
361 DCHECK_EQ(extensions::ExtensionRegistry::Get(service_->profile()), registry);
362 registry_observer_.RemoveAll(); 356 registry_observer_.RemoveAll();
363 } 357 }
364 358
365 void ExtensionDisabledGlobalError::RemoveGlobalError() { 359 void ExtensionDisabledGlobalError::RemoveGlobalError() {
366 std::unique_ptr<GlobalError> ptr = 360 std::unique_ptr<GlobalError> ptr =
367 GlobalErrorServiceFactory::GetForProfile(service_->profile()) 361 GlobalErrorServiceFactory::GetForProfile(service_->profile())
368 ->RemoveGlobalError(this); 362 ->RemoveGlobalError(this);
369 registrar_.RemoveAll(); 363 registrar_.RemoveAll();
370 registry_observer_.RemoveAll(); 364 registry_observer_.RemoveAll();
371 // Delete this object after any running tasks, so that the extension dialog 365 // Delete this object after any running tasks, so that the extension dialog
372 // still has it as a delegate to finish the current tasks. 366 // still has it as a delegate to finish the current tasks.
373 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, ptr.release()); 367 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, ptr.release());
374 } 368 }
375 369
376 // Globals -------------------------------------------------------------------- 370 // Globals --------------------------------------------------------------------
377 371
378 namespace extensions {
379
380 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, 372 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service,
381 const std::string& extension_id, 373 const std::string& extension_id,
382 bool is_remote_install, 374 bool is_remote_install,
383 const gfx::Image& icon) { 375 const gfx::Image& icon) {
384 if (!service.get()) 376 if (!service.get())
385 return; 377 return;
386 const Extension* extension = service->GetInstalledExtension(extension_id); 378 const Extension* extension = service->GetInstalledExtension(extension_id);
387 if (extension) { 379 if (extension) {
388 GlobalErrorServiceFactory::GetForProfile(service->profile()) 380 GlobalErrorServiceFactory::GetForProfile(service->profile())
389 ->AddGlobalError(base::MakeUnique<ExtensionDisabledGlobalError>( 381 ->AddGlobalError(base::MakeUnique<ExtensionDisabledGlobalError>(
390 service.get(), extension, is_remote_install, icon)); 382 service.get(), extension, is_remote_install, icon));
391 } 383 }
392 } 384 }
393 385
394 void AddExtensionDisabledError(ExtensionService* service, 386 void AddExtensionDisabledError(ExtensionService* service,
395 const Extension* extension, 387 const Extension* extension,
396 bool is_remote_install) { 388 bool is_remote_install) {
397 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( 389 ExtensionResource image = IconsInfo::GetIconResource(
398 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER); 390 extension, kIconSize, ExtensionIconSet::MATCH_BIGGER);
399 gfx::Size size(kIconSize, kIconSize); 391 gfx::Size size(kIconSize, kIconSize);
400 ImageLoader::Get(service->profile()) 392 ImageLoader::Get(service->profile())
401 ->LoadImageAsync(extension, 393 ->LoadImageAsync(extension,
402 image, 394 image,
403 size, 395 size,
404 base::Bind(&AddExtensionDisabledErrorWithIcon, 396 base::Bind(&AddExtensionDisabledErrorWithIcon,
405 service->AsWeakPtr(), 397 service->AsWeakPtr(),
406 extension->id(), 398 extension->id(),
407 is_remote_install)); 399 is_remote_install));
408 } 400 }
409 401
410 } // namespace extensions 402 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698