• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_
7 
8 #include "base/basictypes.h"
9 #include "base/strings/string16.h"
10 #include "chrome/browser/extensions/app_icon_loader.h"
11 #include "chrome/common/web_application_info.h"
12 #include "ui/views/bubble/bubble_delegate.h"
13 #include "ui/views/controls/button/button.h"
14 
15 class Profile;
16 
17 namespace extensions {
18 class AppIconLoader;
19 }
20 
21 namespace gfx {
22 class ImageSkia;
23 }
24 
25 namespace views {
26 class Checkbox;
27 class ImageView;
28 class LabelButton;
29 class Textfield;
30 }
31 
32 // BookmarkAppBubbleView is a view intended to be used as the content of a
33 // Bubble. BookmarkAppBubbleView provides views for editing the bookmark app it
34 // is created with. Don't create a BookmarkAppBubbleView directly, instead use
35 // the static ShowBubble method.
36 class BookmarkAppBubbleView : public views::BubbleDelegateView,
37                               public views::ButtonListener,
38                               public extensions::AppIconLoader::Delegate {
39  public:
40   virtual ~BookmarkAppBubbleView();
41 
42   static void ShowBubble(views::View* anchor_view,
43                          Profile* profile,
44                          const WebApplicationInfo& web_app_info,
45                          const std::string& extension_id);
46 
47  private:
48   // Creates a BookmarkAppBubbleView.
49   BookmarkAppBubbleView(views::View* anchor_view,
50                         Profile* profile,
51                         const WebApplicationInfo& web_app_info,
52                         const std::string& extension_id);
53 
54   // Overriden from views::BubbleDelegateView:
55   virtual void Init() OVERRIDE;
56   virtual views::View* GetInitiallyFocusedView() OVERRIDE;
57 
58   // Overridden from views::WidgetDelegate:
59   virtual void WindowClosing() OVERRIDE;
60 
61   // Overridden from views::View:
62   virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
63   virtual gfx::Size GetMinimumSize() const OVERRIDE;
64 
65   // Overridden from views::ButtonListener:
66   // Closes the bubble or opens the edit dialog.
67   virtual void ButtonPressed(views::Button* sender,
68                              const ui::Event& event) OVERRIDE;
69 
70   // Overridden from extensions::AppIconLoader::Delegate:
71   virtual void SetAppImage(const std::string& id,
72                            const gfx::ImageSkia& image) OVERRIDE;
73 
74   // Handle the message when the user presses a button.
75   void HandleButtonPressed(views::Button* sender);
76 
77   // Sets the title and launch type of the app.
78   void ApplyEdits();
79 
80   // The bookmark app bubble, if we're showing one.
81   static BookmarkAppBubbleView* bookmark_app_bubble_;
82 
83   // The profile.
84   Profile* profile_;
85 
86   // The WebApplicationInfo being used to create the app.
87   const WebApplicationInfo web_app_info_;
88 
89   // The extension id of the bookmark app.
90   const std::string extension_id_;
91 
92   // Button for removing the bookmark.
93   views::LabelButton* add_button_;
94 
95   // Button to close the window.
96   views::LabelButton* cancel_button_;
97 
98   // Checkbox to launch as a tab.
99   views::Checkbox* open_as_tab_checkbox_;
100 
101   // Textfield showing the title of the app.
102   views::Textfield* title_tf_;
103 
104   // Image showing the icon of the app.
105   views::ImageView* icon_image_view_;
106 
107   // When the destructor is invoked should the app be removed?
108   bool remove_app_;
109 
110   // Used to load the icon.
111   scoped_ptr<extensions::AppIconLoader> app_icon_loader_;
112 
113   DISALLOW_COPY_AND_ASSIGN(BookmarkAppBubbleView);
114 };
115 
116 #endif  // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_
117