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

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

Issue 21443002: Add NOTIFICATION_EXTENSION_REMOVED for Extensions removed from ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 icon_ = gfx::Image( 204 icon_ = gfx::Image(
205 gfx::ImageSkiaOperations::CreateResizedImage( 205 gfx::ImageSkiaOperations::CreateResizedImage(
206 extension_->is_app() ? 206 extension_->is_app() ?
207 extensions::IconsInfo::GetDefaultAppIcon() : 207 extensions::IconsInfo::GetDefaultAppIcon() :
208 extensions::IconsInfo::GetDefaultExtensionIcon(), 208 extensions::IconsInfo::GetDefaultExtensionIcon(),
209 skia::ImageOperations::RESIZE_BEST, 209 skia::ImageOperations::RESIZE_BEST,
210 gfx::Size(kIconSize, kIconSize))); 210 gfx::Size(kIconSize, kIconSize)));
211 } 211 }
212 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 212 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
213 content::Source<Profile>(service->profile())); 213 content::Source<Profile>(service->profile()));
214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 214 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_REMOVED,
215 content::Source<Profile>(service->profile())); 215 content::Source<Profile>(service->profile()));
216 } 216 }
217 217
218 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() { 218 ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() {
219 ReleaseMenuCommandID(menu_command_id_); 219 ReleaseMenuCommandID(menu_command_id_);
220 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse", 220 UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse",
221 user_response_, 221 user_response_,
222 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY); 222 EXTENSION_DISABLED_UI_BUCKET_BOUNDARY);
223 } 223 }
224 224
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 311 }
312 312
313 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() { 313 void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() {
314 // Nothing happens, and the error is still there. 314 // Nothing happens, and the error is still there.
315 } 315 }
316 316
317 void ExtensionDisabledGlobalError::Observe( 317 void ExtensionDisabledGlobalError::Observe(
318 int type, 318 int type,
319 const content::NotificationSource& source, 319 const content::NotificationSource& source,
320 const content::NotificationDetails& details) { 320 const content::NotificationDetails& details) {
321 const Extension* extension = NULL; 321 // The error is invalidated if the extension has been loaded or removed.
322 // The error is invalidated if the extension has been reloaded 322 DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED ||
323 // or unloaded. 323 type == chrome::NOTIFICATION_EXTENSION_REMOVED);
324 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 324 const Extension* extension = content::Details<const Extension>(details).ptr();
325 extension = content::Details<const Extension>(details).ptr(); 325 if (extension != extension_)
326 } else { 326 return;
327 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type); 327 GlobalErrorServiceFactory::GetForProfile(service_->profile())->
328 extensions::UnloadedExtensionInfo* info = 328 RemoveGlobalError(this);
329 content::Details<extensions::UnloadedExtensionInfo>(details).ptr();
330 extension = info->extension;
331 }
332 if (extension == extension_) {
333 GlobalErrorServiceFactory::GetForProfile(service_->profile())->
334 RemoveGlobalError(this);
335 329
336 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) 330 if (type == chrome::NOTIFICATION_EXTENSION_LOADED)
337 user_response_ = REENABLE; 331 user_response_ = REENABLE;
338 else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) 332 else if (type == chrome::NOTIFICATION_EXTENSION_REMOVED)
339 user_response_ = UNINSTALL; 333 user_response_ = UNINSTALL;
340 delete this; 334 delete this;
341 }
342 } 335 }
343 336
344 // Globals -------------------------------------------------------------------- 337 // Globals --------------------------------------------------------------------
345 338
346 namespace extensions { 339 namespace extensions {
347 340
348 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service, 341 void AddExtensionDisabledErrorWithIcon(base::WeakPtr<ExtensionService> service,
349 const std::string& extension_id, 342 const std::string& extension_id,
350 const gfx::Image& icon) { 343 const gfx::Image& icon) {
351 if (!service.get()) 344 if (!service.get())
(...skipping 20 matching lines...) Expand all
372 void ShowExtensionDisabledDialog(ExtensionService* service, 365 void ShowExtensionDisabledDialog(ExtensionService* service,
373 content::WebContents* web_contents, 366 content::WebContents* web_contents,
374 const Extension* extension) { 367 const Extension* extension) {
375 scoped_ptr<ExtensionInstallPrompt> install_ui( 368 scoped_ptr<ExtensionInstallPrompt> install_ui(
376 new ExtensionInstallPrompt(web_contents)); 369 new ExtensionInstallPrompt(web_contents));
377 // This object manages its own lifetime. 370 // This object manages its own lifetime.
378 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension); 371 new ExtensionDisabledDialogDelegate(service, install_ui.Pass(), extension);
379 } 372 }
380 373
381 } // namespace extensions 374 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chrome_notification_types.h ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698