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