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"
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
{
35 ~BookmarkAppBubbleView() override
;
37 static void ShowBubble(
38 views::View
* anchor_view
,
39 const WebApplicationInfo
& web_app_info
,
40 const BrowserWindow::ShowBookmarkAppBubbleCallback
& callback
);
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:
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.
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.
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_