Chromium Code Reviews| Index: chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.cc |
| diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..71a2464133de83f2f799e43d31e229703a7ed3ca |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.cc |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h" |
| + |
| +#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_tab_manage_views.h" |
| +#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_tab_permissions_views.h" |
| +#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_tab_summary_views.h" |
| +#include "chrome/browser/ui/views/constrained_window_views.h" |
| +#include "grit/generated_resources.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| +#include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
| +#include "ui/views/layout/fill_layout.h" |
| +#include "ui/views/layout/layout_manager.h" |
| +#include "ui/views/widget/widget.h" |
| +#include "ui/views/window/dialog_delegate.h" |
| + |
| +void ShowChromeAppInfoDialog(gfx::NativeWindow parent_window, |
|
Matt Giuca
2014/03/04 01:36:57
Can this just be called ShowAppInfoDialog?
(I thi
sashab
2014/03/04 04:10:58
Done.
|
| + Profile* profile, |
| + const extensions::Extension* app, |
| + const base::Closure& close_callback) { |
| + CreateBrowserModalDialogViews( |
| + new AppInfoView(parent_window, profile, app, close_callback), |
| + parent_window)->Show(); |
| +} |
| + |
| +AppInfoView::AppInfoView(gfx::NativeWindow parent_window, |
| + Profile* profile, |
| + const extensions::Extension* app, |
| + const base::Closure& close_callback) |
| + : profile_(profile), |
| + parent_window_(parent_window), |
| + app_(app), |
| + close_callback_(close_callback), |
| + tabbed_pane_(NULL) { |
| + SetLayoutManager(new views::FillLayout()); |
| + |
| + tabbed_pane_ = new views::TabbedPane(); |
| + AddChildView(tabbed_pane_); |
| + |
| + tabbed_pane_->AddTab( |
| + l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_SUMMARY_TAB_TITLE), |
| + new AppInfoSummaryTabView( |
| + parent_window_, profile_, app_, close_callback_)); |
| + tabbed_pane_->AddTab( |
| + l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_PERMISSIONS_TAB_TITLE), |
| + new AppInfoPermissionsTabView( |
| + parent_window_, profile_, app_, close_callback_)); |
| + tabbed_pane_->AddTab( |
| + l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_MANAGE_TAB_TITLE), |
| + new AppInfoManageTabView( |
| + parent_window_, profile_, app_, close_callback_)); |
| + |
| + tabbed_pane_->set_listener(this); |
| +} |
| + |
| +AppInfoView::~AppInfoView() {} |
| + |
| +bool AppInfoView::Cancel() { |
| + if (!close_callback_.is_null()) |
| + close_callback_.Run(); |
| + return true; |
| +} |
| + |
| +gfx::Size AppInfoView::GetPreferredSize() { |
| + static const int kDialogWidth = 360; |
| + int height = |
| + GetLayoutManager()->GetPreferredHeightForWidth(this, kDialogWidth); |
| + return gfx::Size(kDialogWidth, height); |
| +} |
| + |
| +base::string16 AppInfoView::GetDialogButtonLabel( |
| + ui::DialogButton button) const { |
| + if (button == ui::DIALOG_BUTTON_CANCEL) { |
| + return l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_CLOSE_BUTTON); |
| + } |
| + return views::DialogDelegateView::GetDialogButtonLabel(button); |
| +} |
| + |
| +int AppInfoView::GetDialogButtons() const { return ui::DIALOG_BUTTON_CANCEL; } |
| + |
| +bool AppInfoView::IsDialogButtonEnabled(ui::DialogButton button) const { |
| + return true; |
| +} |
| + |
| +ui::ModalType AppInfoView::GetModalType() const { |
| + return ui::MODAL_TYPE_WINDOW; |
| +} |
| + |
| +void AppInfoView::TabSelectedAt(int index) { |
| + tabbed_pane_->GetSelectedTab()->Layout(); |
| +} |