| 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 "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 ExtensionUninstallDialog::~ExtensionUninstallDialog() { | 69 ExtensionUninstallDialog::~ExtensionUninstallDialog() { |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ExtensionUninstallDialog::ConfirmUninstall( | 72 void ExtensionUninstallDialog::ConfirmUninstall( |
| 73 const extensions::Extension* extension) { | 73 const extensions::Extension* extension) { |
| 74 DCHECK(ui_loop_ == base::MessageLoop::current()); | 74 DCHECK(ui_loop_ == base::MessageLoop::current()); |
| 75 extension_ = extension; | 75 extension_ = extension; |
| 76 // Bookmark apps may not have 128x128 icons so accept 48x48 icons. |
| 77 const int icon_size = extension_->from_bookmark() |
| 78 ? extension_misc::EXTENSION_ICON_MEDIUM |
| 79 : extension_misc::EXTENSION_ICON_LARGE; |
| 76 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( | 80 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( |
| 77 extension_, | 81 extension_, |
| 78 extension_misc::EXTENSION_ICON_LARGE, | 82 icon_size, |
| 79 ExtensionIconSet::MATCH_BIGGER); | 83 ExtensionIconSet::MATCH_BIGGER); |
| 80 // Load the icon whose pixel size is large enough to be displayed under | 84 // Load the icon whose pixel size is large enough to be displayed under |
| 81 // maximal supported scale factor. UI code will scale the icon down if needed. | 85 // maximal supported scale factor. UI code will scale the icon down if needed. |
| 82 int pixel_size = GetSizeForMaxScaleFactor(kIconSize); | 86 int pixel_size = GetSizeForMaxScaleFactor(kIconSize); |
| 83 | 87 |
| 84 // Load the image asynchronously. The response will be sent to OnImageLoaded. | 88 // Load the image asynchronously. The response will be sent to OnImageLoaded. |
| 85 state_ = kImageIsLoading; | 89 state_ = kImageIsLoading; |
| 86 extensions::ImageLoader* loader = | 90 extensions::ImageLoader* loader = |
| 87 extensions::ImageLoader::Get(profile_); | 91 extensions::ImageLoader::Get(profile_); |
| 88 loader->LoadImageAsync(extension_, image, | 92 loader->LoadImageAsync(extension_, image, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 129 |
| 126 browser_ = NULL; | 130 browser_ = NULL; |
| 127 // If the browser is closed while waiting for the image, we need to send a | 131 // If the browser is closed while waiting for the image, we need to send a |
| 128 // "cancel" event here, because there will not be another opportunity to | 132 // "cancel" event here, because there will not be another opportunity to |
| 129 // notify the delegate of the cancellation as we won't open the dialog. | 133 // notify the delegate of the cancellation as we won't open the dialog. |
| 130 if (state_ == kImageIsLoading) { | 134 if (state_ == kImageIsLoading) { |
| 131 state_ = kBrowserIsClosing; | 135 state_ = kBrowserIsClosing; |
| 132 delegate_->ExtensionUninstallCanceled(); | 136 delegate_->ExtensionUninstallCanceled(); |
| 133 } | 137 } |
| 134 } | 138 } |
| OLD | NEW |