OLD | NEW |
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_uninstall_dialog.h" | 5 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); | 41 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 ExtensionUninstallDialog::ExtensionUninstallDialog( | 46 ExtensionUninstallDialog::ExtensionUninstallDialog( |
47 Profile* profile, | 47 Profile* profile, |
48 ExtensionUninstallDialog::Delegate* delegate) | 48 ExtensionUninstallDialog::Delegate* delegate) |
49 : profile_(profile), | 49 : profile_(profile), |
50 delegate_(delegate), | 50 delegate_(delegate), |
51 extension_(NULL), | |
52 triggering_extension_(NULL), | |
53 ui_loop_(base::MessageLoop::current()) { | 51 ui_loop_(base::MessageLoop::current()) { |
54 } | 52 } |
55 | 53 |
56 ExtensionUninstallDialog::~ExtensionUninstallDialog() { | 54 ExtensionUninstallDialog::~ExtensionUninstallDialog() { |
57 } | 55 } |
58 | 56 |
59 void ExtensionUninstallDialog::ConfirmProgrammaticUninstall( | 57 void ExtensionUninstallDialog::ConfirmProgrammaticUninstall( |
60 const Extension* extension, | 58 const Extension* extension, |
61 const Extension* triggering_extension) { | 59 const Extension* triggering_extension) { |
62 triggering_extension_ = triggering_extension; | 60 triggering_extension_ = triggering_extension; |
63 ConfirmUninstall(extension); | 61 ConfirmUninstall(extension); |
64 } | 62 } |
65 | 63 |
66 void ExtensionUninstallDialog::ConfirmUninstall(const Extension* extension) { | 64 void ExtensionUninstallDialog::ConfirmUninstall(const Extension* extension) { |
67 DCHECK(ui_loop_ == base::MessageLoop::current()); | 65 DCHECK(ui_loop_ == base::MessageLoop::current()); |
68 extension_ = extension; | 66 extension_ = extension; |
69 // Bookmark apps may not have 128x128 icons so accept 64x64 icons. | 67 // Bookmark apps may not have 128x128 icons so accept 64x64 icons. |
70 const int icon_size = extension_->from_bookmark() | 68 const int icon_size = extension_->from_bookmark() |
71 ? extension_misc::EXTENSION_ICON_SMALL * 2 | 69 ? extension_misc::EXTENSION_ICON_SMALL * 2 |
72 : extension_misc::EXTENSION_ICON_LARGE; | 70 : extension_misc::EXTENSION_ICON_LARGE; |
73 ExtensionResource image = IconsInfo::GetIconResource( | 71 ExtensionResource image = IconsInfo::GetIconResource( |
74 extension_, icon_size, ExtensionIconSet::MATCH_BIGGER); | 72 extension_.get(), icon_size, ExtensionIconSet::MATCH_BIGGER); |
75 | 73 |
76 // Load the image asynchronously. The response will be sent to OnImageLoaded. | 74 // Load the image asynchronously. The response will be sent to OnImageLoaded. |
77 ImageLoader* loader = ImageLoader::Get(profile_); | 75 ImageLoader* loader = ImageLoader::Get(profile_); |
78 | 76 |
79 SetIcon(gfx::Image()); | 77 SetIcon(gfx::Image()); |
80 std::vector<ImageLoader::ImageRepresentation> images_list; | 78 std::vector<ImageLoader::ImageRepresentation> images_list; |
81 images_list.push_back(ImageLoader::ImageRepresentation( | 79 images_list.push_back(ImageLoader::ImageRepresentation( |
82 image, | 80 image, |
83 ImageLoader::ImageRepresentation::NEVER_RESIZE, | 81 ImageLoader::ImageRepresentation::NEVER_RESIZE, |
84 gfx::Size(), | 82 gfx::Size(), |
85 ui::SCALE_FACTOR_100P)); | 83 ui::SCALE_FACTOR_100P)); |
86 loader->LoadImagesAsync(extension_, | 84 loader->LoadImagesAsync(extension_.get(), |
87 images_list, | 85 images_list, |
88 base::Bind(&ExtensionUninstallDialog::OnImageLoaded, | 86 base::Bind(&ExtensionUninstallDialog::OnImageLoaded, |
89 AsWeakPtr(), | 87 AsWeakPtr(), |
90 extension_->id())); | 88 extension_->id())); |
91 } | 89 } |
92 | 90 |
93 void ExtensionUninstallDialog::SetIcon(const gfx::Image& image) { | 91 void ExtensionUninstallDialog::SetIcon(const gfx::Image& image) { |
94 if (image.IsEmpty()) { | 92 if (image.IsEmpty()) { |
95 // Let's set default icon bitmap whose size is equal to the default icon's | 93 // Let's set default icon bitmap whose size is equal to the default icon's |
96 // pixel size under maximal supported scale factor. If the bitmap is larger | 94 // pixel size under maximal supported scale factor. If the bitmap is larger |
(...skipping 26 matching lines...) Expand all Loading... |
123 return l10n_util::GetStringFUTF8( | 121 return l10n_util::GetStringFUTF8( |
124 IDS_EXTENSION_PROGRAMMATIC_UNINSTALL_PROMPT_HEADING, | 122 IDS_EXTENSION_PROGRAMMATIC_UNINSTALL_PROMPT_HEADING, |
125 base::UTF8ToUTF16(triggering_extension_->name()), | 123 base::UTF8ToUTF16(triggering_extension_->name()), |
126 base::UTF8ToUTF16(extension_->name())); | 124 base::UTF8ToUTF16(extension_->name())); |
127 } | 125 } |
128 return l10n_util::GetStringFUTF8(IDS_EXTENSION_UNINSTALL_PROMPT_HEADING, | 126 return l10n_util::GetStringFUTF8(IDS_EXTENSION_UNINSTALL_PROMPT_HEADING, |
129 base::UTF8ToUTF16(extension_->name())); | 127 base::UTF8ToUTF16(extension_->name())); |
130 } | 128 } |
131 | 129 |
132 bool ExtensionUninstallDialog::ShouldShowReportAbuseCheckbox() const { | 130 bool ExtensionUninstallDialog::ShouldShowReportAbuseCheckbox() const { |
133 return ManifestURL::UpdatesFromGallery(extension_); | 131 return ManifestURL::UpdatesFromGallery(extension_.get()); |
134 } | 132 } |
135 | 133 |
136 void ExtensionUninstallDialog::OnDialogClosed(CloseAction action) { | 134 void ExtensionUninstallDialog::OnDialogClosed(CloseAction action) { |
137 // We don't want to artificially weight any of the options, so only record if | 135 // We don't want to artificially weight any of the options, so only record if |
138 // reporting abuse was available. | 136 // reporting abuse was available. |
139 if (ShouldShowReportAbuseCheckbox()) { | 137 if (ShouldShowReportAbuseCheckbox()) { |
140 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallDialogAction", | 138 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallDialogAction", |
141 action, | 139 action, |
142 CLOSE_ACTION_LAST); | 140 CLOSE_ACTION_LAST); |
143 } | 141 } |
144 } | 142 } |
145 | 143 |
146 void ExtensionUninstallDialog::HandleReportAbuse() { | 144 void ExtensionUninstallDialog::HandleReportAbuse() { |
147 chrome::NavigateParams params( | 145 chrome::NavigateParams params( |
148 profile_, | 146 profile_, |
149 extension_urls::GetWebstoreReportAbuseUrl(extension_->id()), | 147 extension_urls::GetWebstoreReportAbuseUrl(extension_->id()), |
150 ui::PAGE_TRANSITION_LINK); | 148 ui::PAGE_TRANSITION_LINK); |
151 params.disposition = NEW_FOREGROUND_TAB; | 149 params.disposition = NEW_FOREGROUND_TAB; |
152 chrome::Navigate(¶ms); | 150 chrome::Navigate(¶ms); |
153 } | 151 } |
154 | 152 |
155 } // namespace extensions | 153 } // namespace extensions |
OLD | NEW |