Home | History | Annotate | Download | only in app_info_dialog
      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_PERMISSIONS_PANEL_H_
      6 #define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_PERMISSIONS_PANEL_H_
      7 
      8 #include <vector>
      9 
     10 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_panel.h"
     11 #include "ui/gfx/text_constants.h"
     12 #include "ui/views/controls/button/button.h"
     13 
     14 class Profile;
     15 
     16 namespace extensions {
     17 class Extension;
     18 }
     19 
     20 namespace ui {
     21 class Event;
     22 }
     23 
     24 namespace views {
     25 class Label;
     26 class LabelButton;
     27 class View;
     28 }
     29 
     30 // The summary panel of the app info dialog, which provides basic information
     31 // and controls related to the app.
     32 class AppInfoPermissionsPanel : public AppInfoPanel,
     33                                 public views::ButtonListener {
     34  public:
     35   AppInfoPermissionsPanel(Profile* profile, const extensions::Extension* app);
     36 
     37   virtual ~AppInfoPermissionsPanel();
     38 
     39  private:
     40   FRIEND_TEST_ALL_PREFIXES(AppInfoPermissionsPanelTest,
     41                            NoPermissionsObtainedCorrectly);
     42   FRIEND_TEST_ALL_PREFIXES(AppInfoPermissionsPanelTest,
     43                            RequiredPermissionsObtainedCorrectly);
     44   FRIEND_TEST_ALL_PREFIXES(AppInfoPermissionsPanelTest,
     45                            OptionalPermissionsObtainedCorrectly);
     46   FRIEND_TEST_ALL_PREFIXES(AppInfoPermissionsPanelTest,
     47                            RetainedFilePermissionsObtainedCorrectly);
     48 
     49   // Given a list of strings, returns a view containing a list of these strings
     50   // as bulleted items with the given |elide_behavior|. If |allow_multiline| is
     51   // true, allow multi-lined bulleted items and ignore the |elide_behavior|.
     52   views::View* CreateBulletedListView(
     53       const std::vector<base::string16>& messages,
     54       bool allow_multiline,
     55       gfx::ElideBehavior elide_behavior);
     56 
     57   // Internal initialisation methods.
     58   void CreateActivePermissionsControl();
     59   void CreateRetainedFilesControl();
     60 
     61   void LayoutActivePermissionsControl();
     62   void LayoutRetainedFilesControl();
     63 
     64   // Overridden from views::ButtonListener.
     65   virtual void ButtonPressed(views::Button* sender,
     66                              const ui::Event& event) OVERRIDE;
     67 
     68   const std::vector<base::string16> GetActivePermissionMessages() const;
     69   const std::vector<base::string16> GetRetainedFilePaths() const;
     70   void RevokeFilePermissions();
     71 
     72   // UI elements on the dialog.
     73   views::Label* active_permissions_heading_;
     74   views::View* active_permissions_list_;
     75 
     76   views::Label* retained_files_heading_;
     77   views::View* retained_files_list_;
     78   views::LabelButton* revoke_file_permissions_button_;
     79 
     80   DISALLOW_COPY_AND_ASSIGN(AppInfoPermissionsPanel);
     81 };
     82 
     83 #endif  // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_PERMISSIONS_PANEL_H_
     84