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

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

Issue 7920023: Fix crashes related to the extension uninstall dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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) 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_uninstall_dialog.h" 5 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
6 6
7 #include "base/logging.h" 7 ExtensionUninstallDialog::ExtensionUninstallDialog(
8 #include "base/message_loop.h" 8 Profile* profile,
9 #include "chrome/browser/profiles/profile.h" 9 ExtensionUninstallUI::Delegate* delegate,
10 #include "chrome/common/extensions/extension.h" 10 const Extension* extension,
11 #include "chrome/common/extensions/extension_icon_set.h" 11 SkBitmap* icon)
12 #include "chrome/common/extensions/extension_resource.h" 12 : profile_(profile),
13 #include "grit/generated_resources.h" 13 delegate_(delegate),
14 #include "grit/theme_resources.h" 14 extension_(extension),
15 #include "ui/base/resource/resource_bundle.h" 15 icon_(icon) {}
16 16
17 // Size of extension icon in top left of dialog. 17 ExtensionUninstallDialog::~ExtensionUninstallDialog() {}
18 static const int kIconSize = 69;
19
20 ExtensionUninstallDialog::ExtensionUninstallDialog(Profile* profile)
21 : profile_(profile),
22 ui_loop_(MessageLoop::current()),
23 delegate_(NULL),
24 extension_(NULL),
25 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {
26 }
27
28 ExtensionUninstallDialog::~ExtensionUninstallDialog() {
29 }
30
31 void ExtensionUninstallDialog::ConfirmUninstall(Delegate* delegate,
32 const Extension* extension) {
33 DCHECK(ui_loop_ == MessageLoop::current());
34 delegate_ = delegate;
35 extension_ = extension;
36
37 ExtensionResource image =
38 extension_->GetIconResource(Extension::EXTENSION_ICON_LARGE,
39 ExtensionIconSet::MATCH_EXACTLY);
40 // Load the image asynchronously. The response will be sent to OnImageLoaded.
41 tracker_.LoadImage(extension_, image,
42 gfx::Size(kIconSize, kIconSize),
43 ImageLoadingTracker::DONT_CACHE);
44 }
45
46 void ExtensionUninstallDialog::SetIcon(SkBitmap* image) {
47 if (image)
48 icon_ = *image;
49 else
50 icon_ = SkBitmap();
51 if (icon_.empty()) {
52 if (extension_->is_app()) {
53 icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed(
54 IDR_APP_DEFAULT_ICON);
55 } else {
56 icon_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed(
57 IDR_EXTENSION_DEFAULT_ICON);
58 }
59 }
60 }
61
62 void ExtensionUninstallDialog::OnImageLoaded(SkBitmap* image,
63 const ExtensionResource& resource,
64 int index) {
65 SetIcon(image);
66
67 Show(profile_, delegate_, extension_, &icon_);
68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698