app_info_dialog_views.cc revision a02191e04bc25c4935f804f2c080ae28663d096d
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 Profile* profile, 21 const extensions::Extension* app, 22 const base::Closure& close_callback) { 23 CreateBrowserModalDialogViews( 24 new AppInfoDialog(parent_window, profile, app, close_callback), 25 parent_window)->Show(); 26} 27 28AppInfoDialog::AppInfoDialog(gfx::NativeWindow parent_window, 29 Profile* profile, 30 const extensions::Extension* app, 31 const base::Closure& close_callback) 32 : parent_window_(parent_window), 33 profile_(profile), 34 app_(app), 35 close_callback_(close_callback) { 36 SetLayoutManager(new views::FillLayout()); 37 38 views::TabbedPane* tabbed_pane = new views::TabbedPane(); 39 AddChildView(tabbed_pane); 40 41 tabbed_pane->AddTab( 42 l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_SUMMARY_TAB_TITLE), 43 new AppInfoSummaryTab(parent_window_, profile_, app_, close_callback_)); 44 tabbed_pane->AddTab( 45 l10n_util::GetStringUTF16(IDS_APPLICATION_INFO_PERMISSIONS_TAB_TITLE), 46 new AppInfoPermissionsTab( 47 parent_window_, profile_, app_, close_callback_)); 48 // TODO(sashab): Add the manage tab back once there is content for it. 49} 50 51AppInfoDialog::~AppInfoDialog() {} 52 53bool AppInfoDialog::Cancel() { 54 if (!close_callback_.is_null()) 55 close_callback_.Run(); 56 return true; 57} 58 59gfx::Size AppInfoDialog::GetPreferredSize() { 60 // These numbers represent the size of the view, not the total size of the 61 // dialog. The actual dialog will be slightly taller (have a larger height) 62 // than what is specified here. 63 static const int kDialogWidth = 360; 64 static const int kDialogHeight = 360; 65 return gfx::Size(kDialogWidth, kDialogHeight); 66} 67 68int AppInfoDialog::GetDialogButtons() const { return ui::DIALOG_BUTTON_NONE; } 69 70ui::ModalType AppInfoDialog::GetModalType() const { 71 return ui::MODAL_TYPE_WINDOW; 72} 73