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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_
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"
17 namespace extensions {
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 {
40 virtual ~BookmarkAppBubbleView();
42 static void ShowBubble(views::View* anchor_view,
44 const WebApplicationInfo& web_app_info,
45 const std::string& extension_id);
48 // Creates a BookmarkAppBubbleView.
49 BookmarkAppBubbleView(views::View* anchor_view,
51 const WebApplicationInfo& web_app_info,
52 const std::string& extension_id);
54 // Overriden from views::BubbleDelegateView:
55 virtual void Init() OVERRIDE;
56 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
58 // Overridden from views::WidgetDelegate:
59 virtual void WindowClosing() OVERRIDE;
61 // Overridden from views::View:
62 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
63 virtual gfx::Size GetMinimumSize() const OVERRIDE;
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;
70 // Overridden from extensions::AppIconLoader::Delegate:
71 virtual void SetAppImage(const std::string& id,
72 const gfx::ImageSkia& image) OVERRIDE;
74 // Handle the message when the user presses a button.
75 void HandleButtonPressed(views::Button* sender);
77 // Sets the title and launch type of the app.
80 // The bookmark app bubble, if we're showing one.
81 static BookmarkAppBubbleView* bookmark_app_bubble_;
86 // The WebApplicationInfo being used to create the app.
87 const WebApplicationInfo web_app_info_;
89 // The extension id of the bookmark app.
90 const std::string extension_id_;
92 // Button for removing the bookmark.
93 views::LabelButton* add_button_;
95 // Button to close the window.
96 views::LabelButton* cancel_button_;
98 // Checkbox to launch as a tab.
99 views::Checkbox* open_as_tab_checkbox_;
101 // Textfield showing the title of the app.
102 views::Textfield* title_tf_;
104 // Image showing the icon of the app.
105 views::ImageView* icon_image_view_;
107 // When the destructor is invoked should the app be removed?
110 // Used to load the icon.
111 scoped_ptr<extensions::AppIconLoader> app_icon_loader_;
113 DISALLOW_COPY_AND_ASSIGN(BookmarkAppBubbleView);
116 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_