app_info_footer_panel.h revision 6d86b77056ed63eb6871182f42a9fd5f07550f90
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#ifndef CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_FOOTER_PANEL_H_ 6#define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_FOOTER_PANEL_H_ 7 8#include "base/memory/scoped_ptr.h" 9#include "base/memory/weak_ptr.h" 10#include "chrome/browser/extensions/extension_uninstall_dialog.h" 11#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_panel.h" 12#include "ui/gfx/native_widget_types.h" 13#include "ui/views/controls/button/button.h" 14 15class Profile; 16 17namespace extensions { 18class Extension; 19} 20 21namespace ui { 22class Event; 23} 24 25namespace views { 26class LabelButton; 27} 28 29// A small summary panel with buttons to control the app that is displayed at 30// the bottom of the app info dialog. 31class AppInfoFooterPanel 32 : public AppInfoPanel, 33 public views::ButtonListener, 34 public extensions::ExtensionUninstallDialog::Delegate, 35 public base::SupportsWeakPtr<AppInfoFooterPanel> { 36 public: 37 AppInfoFooterPanel(gfx::NativeWindow parent_window, 38 Profile* profile, 39 const extensions::Extension* app); 40 virtual ~AppInfoFooterPanel(); 41 42 private: 43 void CreateButtons(); 44 void LayoutButtons(); 45 46 // Updates the visibility of the pin/unpin buttons so that only one is visible 47 // at a time. 48 void UpdatePinButtons(); 49 50 // Overridden from views::ButtonListener: 51 virtual void ButtonPressed(views::Button* sender, 52 const ui::Event& event) OVERRIDE; 53 54 // Overridden from ExtensionUninstallDialog::Delegate: 55 virtual void ExtensionUninstallAccepted() OVERRIDE; 56 virtual void ExtensionUninstallCanceled() OVERRIDE; 57 58 // Create Shortcuts for the app. Must only be called if CanCreateShortcuts() 59 // returns true. 60 void CreateShortcuts(); 61 bool CanCreateShortcuts() const; 62 63 // Pins and unpins the app from the shelf. Must only be called if 64 // CanSetPinnedToShelf() returns true. 65 void SetPinnedToShelf(bool value); 66 bool CanSetPinnedToShelf() const; 67 68 // Uninstall the app. Must only be called if CanUninstallApp() returns true. 69 void UninstallApp(); 70 bool CanUninstallApp() const; 71 72 gfx::NativeWindow parent_window_; 73 74 // UI elements on the dialog. Elements are NULL if they are not displayed. 75 views::LabelButton* create_shortcuts_button_; 76 views::LabelButton* pin_to_shelf_button_; 77 views::LabelButton* unpin_from_shelf_button_; 78 views::LabelButton* remove_button_; 79 80 scoped_ptr<extensions::ExtensionUninstallDialog> extension_uninstall_dialog_; 81 82 base::WeakPtrFactory<AppInfoFooterPanel> weak_ptr_factory_; 83 84 DISALLOW_COPY_AND_ASSIGN(AppInfoFooterPanel); 85}; 86 87#endif // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_FOOTER_PANEL_H_ 88