Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / extensions / bookmark_app_bubble_view.h
blob741a66eff0b42da9730345d527dc1e48e2968a4d
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/ui/browser_window.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 #include "ui/views/controls/textfield/textfield_controller.h"
16 namespace gfx {
17 class ImageSkia;
20 namespace views {
21 class Checkbox;
22 class ImageView;
23 class LabelButton;
24 class Textfield;
27 // BookmarkAppBubbleView is a view intended to be used as the content of a
28 // Bubble. BookmarkAppBubbleView provides views for editing the details to
29 // create a bookmark app with. Don't create a BookmarkAppBubbleView directly,
30 // instead use the static ShowBubble method.
31 class BookmarkAppBubbleView : public views::BubbleDelegateView,
32 public views::ButtonListener,
33 public views::TextfieldController {
34 public:
35 ~BookmarkAppBubbleView() override;
37 static void ShowBubble(
38 views::View* anchor_view,
39 const WebApplicationInfo& web_app_info,
40 const BrowserWindow::ShowBookmarkAppBubbleCallback& callback);
42 private:
43 // Creates a BookmarkAppBubbleView.
44 BookmarkAppBubbleView(
45 views::View* anchor_view,
46 const WebApplicationInfo& web_app_info,
47 const BrowserWindow::ShowBookmarkAppBubbleCallback& callback);
49 // Overriden from views::BubbleDelegateView:
50 void Init() override;
51 views::View* GetInitiallyFocusedView() override;
53 // Overridden from views::WidgetDelegate:
54 void WindowClosing() override;
56 // Overridden from views::View:
57 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
58 void GetAccessibleState(ui::AXViewState* state) override;
59 gfx::Size GetMinimumSize() const override;
61 // Overridden from views::ButtonListener:
62 // Closes the bubble or opens the edit dialog.
63 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
65 // Overridden from views::TextfieldController:
66 void ContentsChanged(views::Textfield* sender,
67 const base::string16& new_contents) override;
69 // Handle the message when the user presses a button.
70 void HandleButtonPressed(views::Button* sender);
72 // Update the state of the Add button.
73 void UpdateAddButtonState();
75 // Get the string ID to use for the bubble title.
76 int TitleStringId();
78 // Get the trimmed contents of the title text field.
79 base::string16 GetTrimmedTitle();
81 // The WebApplicationInfo that the user is editing.
82 WebApplicationInfo web_app_info_;
84 // Whether the user has accepted the dialog.
85 bool user_accepted_;
87 // The callback to be invoked when the dialog is completed.
88 BrowserWindow::ShowBookmarkAppBubbleCallback callback_;
90 // Button for removing the bookmark.
91 views::LabelButton* add_button_;
93 // Button to close the window.
94 views::LabelButton* cancel_button_;
96 // Checkbox to launch as a window.
97 views::Checkbox* open_as_window_checkbox_;
99 // Textfield showing the title of the app.
100 views::Textfield* title_tf_;
102 // Image showing the icon of the app.
103 views::ImageView* icon_image_view_;
105 DISALLOW_COPY_AND_ASSIGN(BookmarkAppBubbleView);
108 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BOOKMARK_APP_BUBBLE_VIEW_H_