app_info_dialog_views.cc revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h" 6 7#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_manage_tab.h" 8#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_tab.h" 9#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_summary_tab.h" 10#include "chrome/browser/ui/views/constrained_window_views.h" 11#include "grit/generated_resources.h" 12#include "ui/base/l10n/l10n_util.h" 13#include "ui/views/controls/tabbed_pane/tabbed_pane.h" 14#include "ui/views/layout/fill_layout.h" 15#include "ui/views/layout/layout_manager.h" 16#include "ui/views/widget/widget.h" 17#include "ui/views/window/dialog_delegate.h" 18 19void ShowAppInfoDialog(gfx::NativeWindow parent_window, 20 const gfx::Rect& dialog_widget_bounds, 21 Profile* profile, 22 const extensions::Extension* app, 23 const base::Closure& close_callback) { 24 views::Widget* dialog = CreateBrowserModalDialogViews( 25 new AppInfoDialog(parent_window, profile, app, close_callback), 26 parent_window); 27 dialog->SetBounds(dialog_widget_bounds); 28 dialog->Show(); 29} 30 31AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window, 32 Profile* profile, 33 const extensions::Extension* app, 34 const base::Closure& close_callback) 35 : parent_window_(parent_window), 36 profile_(profile), 37 app_(app), 38 close_callback_(close_callback) { 39 SetLayoutManager(new views::FillLayout()); 40 41 views::TabbedPane* tabbed_pane = new views::TabbedPane(); 42 AddChildView(tabbed_pane); 43 44 tabbed_pane->AddTab( 45 l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_SUMMARY_TAB_TITLE), 46 new AppInfoSummaryTab(parent_window_, profile_, app_, close_callback_)); 47 tabbed_pane->AddTab( 48 l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_PERMISSIONS_TAB_TITLE), 49 new AppInfoPermissionsTab( 50 parent_window_, profile_, app_, close_callback_)); 51 // TODO(sashab): Add the manage tab back once there is content for it. 52} 53 54AppInfoDialog::~AppInfoDialog() {} 55 56bool AppInfoDialog::Cancel() { 57 if (!close_callback_.is_null()) 58 close_callback_.Run(); 59 return true; 60} 61 62gfx::Size AppInfoDialog::GetPreferredSize() const { 63 // These numbers represent the size of the view, not the total size of the 64 // dialog. The actual dialog will be slightly taller (have a larger height) 65 // than what is specified here. 66 static const int kDialogWidth = 360; 67 static const int kDialogHeight = 360; 68 return gfx::Size(kDialogWidth, kDialogHeight); 69} 70 71int AppInfoDialog::GetDialogButtons() const { return ui::DIALOG_BUTTON_NONE; } 72 73ui::ModalType AppInfoDialog::GetModalType() const { 74 return ui::MODAL_TYPE_WINDOW; 75} 76