extension_uninstall_dialog_view.cc revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// Use of this source code is governed by a BSD-style license that can be
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// found in the LICENSE file.
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#include "chrome/browser/extensions/extension_uninstall_dialog.h"
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#include "base/basictypes.h"
8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#include "base/compiler_specific.h"
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/strings/string_util.h"
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "base/strings/utf_string_conversions.h"
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/ui/app_list/app_list_service.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/ui/browser.h"
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/ui/browser_window.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "chrome/browser/ui/views/constrained_window_views.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "extensions/common/extension.h"
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "grit/generated_resources.h"
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/base/l10n/l10n_util.h"
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/compositor/compositor.h"
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/compositor/layer.h"
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/controls/image_view.h"
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/controls/label.h"
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/layout/layout_constants.h"
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/view.h"
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/widget/widget.h"
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ui/views/window/dialog_delegate.h"
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if defined(USE_ASH)
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "ash/shell.h"
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comnamespace {
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst int kRightColumnWidth = 210;
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst int kIconSize = 69;
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass ExtensionUninstallDialogDelegateView;
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Returns parent window for extension uninstall dialog.
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comgfx::NativeWindow GetParent(Browser* browser) {
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  if (browser && browser->window())
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return browser->window()->GetNativeWindow();
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  return NULL;
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// Views implementation of the uninstall dialog.
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass ExtensionUninstallDialogViews : public ExtensionUninstallDialog {
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public:
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ExtensionUninstallDialogViews(Profile* profile,
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                Browser* browser,
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                ExtensionUninstallDialog::Delegate* delegate);
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual ~ExtensionUninstallDialogViews();
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Forwards the accept and cancels to the delegate.
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void ExtensionUninstallAccepted();
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void ExtensionUninstallCanceled();
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ExtensionUninstallDialogDelegateView* view() { return view_; }
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com private:
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void Show() OVERRIDE;
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ExtensionUninstallDialogDelegateView* view_;
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  bool show_in_app_list_;
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogViews);
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// The dialog's view, owned by the views framework.
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass ExtensionUninstallDialogDelegateView : public views::DialogDelegateView {
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com public:
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ExtensionUninstallDialogDelegateView(
72d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com      ExtensionUninstallDialogViews* dialog_view,
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      const extensions::Extension* extension,
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      gfx::ImageSkia* icon);
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual ~ExtensionUninstallDialogDelegateView();
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Called when the ExtensionUninstallDialog has been destroyed to make sure
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // we invalidate pointers.
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  void DialogDestroyed() { dialog_ = NULL; }
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com private:
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // views::DialogDelegate:
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual base::string16 GetDialogButtonLabel(
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      ui::DialogButton button) const OVERRIDE;
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual int GetDefaultDialogButton() const OVERRIDE {
868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return ui::DIALOG_BUTTON_CANCEL;
878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  }
888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual bool Accept() OVERRIDE;
898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual bool Cancel() OVERRIDE;
908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // views::WidgetDelegate:
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual ui::ModalType GetModalType() const OVERRIDE {
938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return ui::MODAL_TYPE_WINDOW;
948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  }
958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual base::string16 GetWindowTitle() const OVERRIDE;
968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // views::View:
988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual gfx::Size GetPreferredSize() OVERRIDE;
998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  virtual void Layout() OVERRIDE;
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  ExtensionUninstallDialogViews* dialog_;
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::ImageView* icon_;
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  views::Label* heading_;
1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogDelegateView);
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comExtensionUninstallDialogViews::ExtensionUninstallDialogViews(
1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Profile* profile,
1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Browser* browser,
1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ExtensionUninstallDialog::Delegate* delegate)
1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    : ExtensionUninstallDialog(profile, browser, delegate),
1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      view_(NULL),
1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      show_in_app_list_(!browser) {
1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comExtensionUninstallDialogViews::~ExtensionUninstallDialogViews() {
1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Close the widget (the views framework will delete view_).
1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  if (view_) {
1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    view_->DialogDestroyed();
1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    view_->GetWidget()->CloseNow();
1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  }
1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid ExtensionUninstallDialogViews::Show() {
1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // TODO(tapted): A true |desktop_type| needs to be passed in at creation time
1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // to remove reliance on GetActiveDesktop(). http://crbug.com/308360
1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  gfx::NativeWindow parent = show_in_app_list_ ?
1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      AppListService::Get(chrome::GetActiveDesktop())->GetAppListWindow() :
1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      GetParent(browser_);
1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  if (browser_ && !parent) {
1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    delegate_->ExtensionUninstallCanceled();
1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return;
1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  }
1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  view_ = new ExtensionUninstallDialogDelegateView(this, extension_, &icon_);
1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  CreateBrowserModalDialogViews(view_, parent)->Show();
1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid ExtensionUninstallDialogViews::ExtensionUninstallAccepted() {
1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // The widget gets destroyed when the dialog is accepted.
1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  view_ = NULL;
1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  delegate_->ExtensionUninstallAccepted();
1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid ExtensionUninstallDialogViews::ExtensionUninstallCanceled() {
1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // The widget gets destroyed when the dialog is canceled.
1508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  view_ = NULL;
1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  delegate_->ExtensionUninstallCanceled();
1528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView(
1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ExtensionUninstallDialogViews* dialog_view,
1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    const extensions::Extension* extension,
1578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    gfx::ImageSkia* icon)
1588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    : dialog_(dialog_view) {
1598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  // Scale down to icon size, but allow smaller icons (don't scale up).
1608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  gfx::Size size(icon->width(), icon->height());
1618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  if (size.width() > kIconSize || size.height() > kIconSize)
1628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    size = gfx::Size(kIconSize, kIconSize);
1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  icon_ = new views::ImageView();
1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  icon_->SetImageSize(size);
1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  icon_->SetImage(*icon);
1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  AddChildView(icon_);
1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  heading_ = new views::Label(
1698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      l10n_util::GetStringFUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_HEADING,
1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                 UTF8ToUTF16(extension->name())));
1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  heading_->SetMultiLine(true);
1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  AddChildView(heading_);
1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comExtensionUninstallDialogDelegateView::~ExtensionUninstallDialogDelegateView() {
1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combase::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel(
1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ui::DialogButton button) const {
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ?
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : IDS_CANCEL);
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool ExtensionUninstallDialogDelegateView::Accept() {
1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  if (dialog_)
1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    dialog_->ExtensionUninstallAccepted();
1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  return true;
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool ExtensionUninstallDialogDelegateView::Cancel() {
1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  if (dialog_)
1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    dialog_->ExtensionUninstallCanceled();
1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  return true;
1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combase::string16 ExtensionUninstallDialogDelegateView::GetWindowTitle() const {
1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  return l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE);
1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comgfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() {
2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  int width = kRightColumnWidth;
2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  width += kIconSize;
2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  width += views::kButtonHEdgeMarginNew * 2;
2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  width += views::kRelatedControlHorizontalSpacing;
2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  int height = views::kPanelVertMargin * 2;
2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  height += heading_->GetHeightForWidth(kRightColumnWidth);
2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  return gfx::Size(width,
2108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                   std::max(height, kIconSize + views::kPanelVertMargin * 2));
2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid ExtensionUninstallDialogDelegateView::Layout() {
2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  int x = views::kButtonHEdgeMarginNew;
2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  int y = views::kPanelVertMargin;
2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  heading_->SizeToFit(kRightColumnWidth);
2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  if (heading_->height() <= kIconSize) {
2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    icon_->SetBounds(x, y, kIconSize, kIconSize);
2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    x += kIconSize;
2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    x += views::kRelatedControlHorizontalSpacing;
2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    heading_->SetX(x);
2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    heading_->SetY(y + (kIconSize - heading_->height()) / 2);
2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  } else {
2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    icon_->SetBounds(x,
2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     y + (heading_->height() - kIconSize) / 2,
2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     kIconSize,
2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     kIconSize);
2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    x += kIconSize;
2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    x += views::kRelatedControlHorizontalSpacing;
2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    heading_->SetX(x);
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    heading_->SetY(y);
2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  }
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}  // namespace
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// static
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comExtensionUninstallDialog* ExtensionUninstallDialog::Create(
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Profile* profile,
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Browser* browser,
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Delegate* delegate) {
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com  return new ExtensionUninstallDialogViews(profile, browser, delegate);
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com