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