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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 77 |
| 78 // Called when the ExtensionUninstallDialog has been destroyed to make sure | 78 // Called when the ExtensionUninstallDialog has been destroyed to make sure |
| 79 // we invalidate pointers. | 79 // we invalidate pointers. |
| 80 void DialogDestroyed() { dialog_ = NULL; } | 80 void DialogDestroyed() { dialog_ = NULL; } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 // views::DialogDelegate: | 83 // views::DialogDelegate: |
| 84 virtual base::string16 GetDialogButtonLabel( | 84 virtual base::string16 GetDialogButtonLabel( |
| 85 ui::DialogButton button) const OVERRIDE; | 85 ui::DialogButton button) const OVERRIDE; |
| 86 virtual int GetDefaultDialogButton() const OVERRIDE { | 86 virtual int GetDefaultDialogButton() const OVERRIDE { |
| 87 return ui::DIALOG_BUTTON_CANCEL; | 87 // Default to cancel when uninstall is triggered by API. |
|
Yoyo Zhou
2014/04/18 23:07:13
ditto
| |
| 88 return triggering_extension_ ? | |
| 89 ui::DIALOG_BUTTON_CANCEL : ui::DIALOG_BUTTON_OK; | |
| 88 } | 90 } |
| 89 virtual bool Accept() OVERRIDE; | 91 virtual bool Accept() OVERRIDE; |
| 90 virtual bool Cancel() OVERRIDE; | 92 virtual bool Cancel() OVERRIDE; |
| 91 | 93 |
| 92 // views::WidgetDelegate: | 94 // views::WidgetDelegate: |
| 93 virtual ui::ModalType GetModalType() const OVERRIDE { | 95 virtual ui::ModalType GetModalType() const OVERRIDE { |
| 94 return ui::MODAL_TYPE_WINDOW; | 96 return ui::MODAL_TYPE_WINDOW; |
| 95 } | 97 } |
| 96 virtual base::string16 GetWindowTitle() const OVERRIDE; | 98 virtual base::string16 GetWindowTitle() const OVERRIDE; |
| 97 | 99 |
| 98 // views::View: | 100 // views::View: |
| 99 virtual gfx::Size GetPreferredSize() OVERRIDE; | 101 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 100 | 102 |
| 101 virtual void Layout() OVERRIDE; | 103 virtual void Layout() OVERRIDE; |
| 102 | 104 |
| 103 ExtensionUninstallDialogViews* dialog_; | 105 ExtensionUninstallDialogViews* dialog_; |
| 104 | 106 |
| 105 views::ImageView* icon_; | 107 views::ImageView* icon_; |
| 106 views::Label* heading_; | 108 views::Label* heading_; |
| 109 const extensions::Extension* triggering_extension_; | |
| 107 | 110 |
| 108 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogDelegateView); | 111 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogDelegateView); |
| 109 }; | 112 }; |
| 110 | 113 |
| 111 ExtensionUninstallDialogViews::ExtensionUninstallDialogViews( | 114 ExtensionUninstallDialogViews::ExtensionUninstallDialogViews( |
| 112 Profile* profile, | 115 Profile* profile, |
| 113 Browser* browser, | 116 Browser* browser, |
| 114 ExtensionUninstallDialog::Delegate* delegate) | 117 ExtensionUninstallDialog::Delegate* delegate) |
| 115 : ExtensionUninstallDialog(profile, browser, delegate), | 118 : ExtensionUninstallDialog(profile, browser, delegate), |
| 116 view_(NULL), | 119 view_(NULL), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 size = gfx::Size(kIconSize, kIconSize); | 168 size = gfx::Size(kIconSize, kIconSize); |
| 166 icon_ = new views::ImageView(); | 169 icon_ = new views::ImageView(); |
| 167 icon_->SetImageSize(size); | 170 icon_->SetImageSize(size); |
| 168 icon_->SetImage(*icon); | 171 icon_->SetImage(*icon); |
| 169 AddChildView(icon_); | 172 AddChildView(icon_); |
| 170 | 173 |
| 171 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText())); | 174 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText())); |
| 172 heading_->SetMultiLine(true); | 175 heading_->SetMultiLine(true); |
| 173 heading_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 176 heading_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 174 AddChildView(heading_); | 177 AddChildView(heading_); |
| 178 | |
| 179 triggering_extension_ = triggering_extension; | |
| 175 } | 180 } |
| 176 | 181 |
| 177 ExtensionUninstallDialogDelegateView::~ExtensionUninstallDialogDelegateView() { | 182 ExtensionUninstallDialogDelegateView::~ExtensionUninstallDialogDelegateView() { |
| 178 } | 183 } |
| 179 | 184 |
| 180 base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel( | 185 base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel( |
| 181 ui::DialogButton button) const { | 186 ui::DialogButton button) const { |
| 182 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? | 187 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? |
| 183 IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : IDS_CANCEL); | 188 IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : IDS_CANCEL); |
| 184 } | 189 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 | 245 |
| 241 } // namespace | 246 } // namespace |
| 242 | 247 |
| 243 // static | 248 // static |
| 244 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( | 249 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( |
| 245 Profile* profile, | 250 Profile* profile, |
| 246 Browser* browser, | 251 Browser* browser, |
| 247 Delegate* delegate) { | 252 Delegate* delegate) { |
| 248 return new ExtensionUninstallDialogViews(profile, browser, delegate); | 253 return new ExtensionUninstallDialogViews(profile, browser, delegate); |
| 249 } | 254 } |
| OLD | NEW |