app_info_header_panel.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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_HEADER_PANEL_H_
6#define CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_HEADER_PANEL_H_
7
8#include "base/memory/weak_ptr.h"
9#include "chrome/browser/ui/views/apps/app_info_dialog/app_info_panel.h"
10#include "ui/views/controls/link_listener.h"
11
12class Profile;
13namespace extensions {
14class Extension;
15}
16
17namespace gfx {
18class Image;
19}
20
21namespace views {
22class ImageView;
23class Label;
24class Link;
25class View;
26}
27
28// A small summary panel with the app's name, icon, version, and various links
29// that is displayed at the top of the app info dialog.
30class AppInfoHeaderPanel : public AppInfoPanel,
31                           public views::LinkListener,
32                           public base::SupportsWeakPtr<AppInfoHeaderPanel> {
33 public:
34  AppInfoHeaderPanel(Profile* profile, const extensions::Extension* app);
35  virtual ~AppInfoHeaderPanel();
36
37 private:
38  void CreateControls();
39  void LayoutAppNameAndVersionInto(views::View* parent_view);
40  void LayoutControls();
41
42  // Overridden from views::LinkListener:
43  virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
44
45  // Load the app icon asynchronously. For the response, check OnAppImageLoaded.
46  void LoadAppImageAsync();
47  // Called when the app's icon is loaded.
48  void OnAppImageLoaded(const gfx::Image& image);
49
50  // Opens the app in the web store. Must only be called if
51  // CanShowAppInWebStore() returns true.
52  void ShowAppInWebStore() const;
53  bool CanShowAppInWebStore() const;
54
55  // Displays the licenses for the app. Must only be called if
56  // CanDisplayLicenses() returns true.
57  void DisplayLicenses();
58  bool CanDisplayLicenses();
59
60  // UI elements on the dialog. Elements are NULL if they are not displayed.
61  views::ImageView* app_icon_;
62  views::Label* app_name_label_;
63  views::Label* app_version_label_;
64  views::Link* view_in_store_link_;
65  views::Link* licenses_link_;
66
67  base::WeakPtrFactory<AppInfoHeaderPanel> weak_ptr_factory_;
68
69  DISALLOW_COPY_AND_ASSIGN(AppInfoHeaderPanel);
70};
71
72#endif  // CHROME_BROWSER_UI_VIEWS_APPS_APP_INFO_DIALOG_APP_INFO_HEADER_PANEL_H_
73