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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 9 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ExtensionUninstallDialogDelegateView* view_; | 73 ExtensionUninstallDialogDelegateView* view_; |
74 | 74 |
75 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogViews); | 75 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogViews); |
76 }; | 76 }; |
77 | 77 |
78 // The dialog's view, owned by the views framework. | 78 // The dialog's view, owned by the views framework. |
79 class ExtensionUninstallDialogDelegateView : public views::DialogDelegateView { | 79 class ExtensionUninstallDialogDelegateView : public views::DialogDelegateView { |
80 public: | 80 public: |
81 ExtensionUninstallDialogDelegateView( | 81 ExtensionUninstallDialogDelegateView( |
82 ExtensionUninstallDialogViews* dialog_view, | 82 ExtensionUninstallDialogViews* dialog_view, |
83 const Extension* extension, | 83 const extensions::Extension* extension, |
84 SkBitmap* icon); | 84 SkBitmap* icon); |
85 virtual ~ExtensionUninstallDialogDelegateView(); | 85 virtual ~ExtensionUninstallDialogDelegateView(); |
86 | 86 |
87 // Called when the ExtensionUninstallDialog has been destroyed to make sure | 87 // Called when the ExtensionUninstallDialog has been destroyed to make sure |
88 // we invalidate pointers. | 88 // we invalidate pointers. |
89 void DialogDestroyed() { dialog_ = NULL; } | 89 void DialogDestroyed() { dialog_ = NULL; } |
90 | 90 |
91 private: | 91 private: |
92 // views::DialogDelegate: | 92 // views::DialogDelegate: |
93 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; | 93 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 | 150 |
151 void ExtensionUninstallDialogViews::ExtensionUninstallCanceled() { | 151 void ExtensionUninstallDialogViews::ExtensionUninstallCanceled() { |
152 // The widget gets destroyed when the dialog is canceled. | 152 // The widget gets destroyed when the dialog is canceled. |
153 view_ = NULL; | 153 view_ = NULL; |
154 delegate_->ExtensionUninstallCanceled(); | 154 delegate_->ExtensionUninstallCanceled(); |
155 } | 155 } |
156 | 156 |
157 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( | 157 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( |
158 ExtensionUninstallDialogViews* dialog_view, | 158 ExtensionUninstallDialogViews* dialog_view, |
159 const Extension* extension, | 159 const extensions::Extension* extension, |
160 SkBitmap* icon) | 160 SkBitmap* icon) |
161 : dialog_(dialog_view) { | 161 : dialog_(dialog_view) { |
162 // Scale down to icon size, but allow smaller icons (don't scale up). | 162 // Scale down to icon size, but allow smaller icons (don't scale up). |
163 gfx::Size size(icon->width(), icon->height()); | 163 gfx::Size size(icon->width(), icon->height()); |
164 if (size.width() > kIconSize || size.height() > kIconSize) | 164 if (size.width() > kIconSize || size.height() > kIconSize) |
165 size = gfx::Size(kIconSize, kIconSize); | 165 size = gfx::Size(kIconSize, kIconSize); |
166 icon_ = new views::ImageView(); | 166 icon_ = new views::ImageView(); |
167 icon_->SetImageSize(size); | 167 icon_->SetImageSize(size); |
168 icon_->SetImage(*icon); | 168 icon_->SetImage(*icon); |
169 AddChildView(icon_); | 169 AddChildView(icon_); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 } // namespace | 242 } // namespace |
243 | 243 |
244 // static | 244 // static |
245 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( | 245 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( |
246 Profile* profile, Delegate* delegate) { | 246 Profile* profile, Delegate* delegate) { |
247 return new ExtensionUninstallDialogViews(profile, delegate); | 247 return new ExtensionUninstallDialogViews(profile, delegate); |
248 } | 248 } |
OLD | NEW |