1 // Copyright (c) 2012 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_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h"
14 #include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h"
15 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/combobox/combobox_listener.h"
20 class BookmarkBubbleViewObserver
;
28 // BookmarkBubbleView is a view intended to be used as the content of an
29 // Bubble. BookmarkBubbleView provides views for unstarring and editing the
30 // bookmark it is created with. Don't create a BookmarkBubbleView directly,
31 // instead use the static Show method.
32 class BookmarkBubbleView
: public views::BubbleDelegateView
,
33 public views::ButtonListener
,
34 public views::ComboboxListener
{
36 static void ShowBubble(views::View
* anchor_view
,
37 BookmarkBubbleViewObserver
* observer
,
38 scoped_ptr
<BookmarkBubbleDelegate
> delegate
,
41 bool newly_bookmarked
);
43 static bool IsShowing();
47 ~BookmarkBubbleView() override
;
49 // views::WidgetDelegate:
50 void WindowClosing() override
;
51 bool AcceleratorPressed(const ui::Accelerator
& accelerator
) override
;
54 // views::BubbleDelegateView method.
58 friend class BookmarkBubbleViewTest
;
59 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest
, SyncPromoSignedIn
);
60 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest
, SyncPromoNotSignedIn
);
62 // views::BubbleDelegateView:
63 const char* GetClassName() const override
;
64 views::View
* GetInitiallyFocusedView() override
;
66 // Creates a BookmarkBubbleView.
67 BookmarkBubbleView(views::View
* anchor_view
,
68 BookmarkBubbleViewObserver
* observer
,
69 scoped_ptr
<BookmarkBubbleDelegate
> delegate
,
72 bool newly_bookmarked
);
74 // Returns the title to display.
75 base::string16
GetTitle();
77 // Overridden from views::View:
78 void GetAccessibleState(ui::AXViewState
* state
) override
;
80 // Overridden from views::ButtonListener:
81 // Closes the bubble or opens the edit dialog.
82 void ButtonPressed(views::Button
* sender
, const ui::Event
& event
) override
;
84 // Overridden from views::ComboboxListener:
85 void OnPerformAction(views::Combobox
* combobox
) override
;
87 // Handle the message when the user presses a button.
88 void HandleButtonPressed(views::Button
* sender
);
90 // Shows the BookmarkEditor.
93 // Sets the title and parent of the node.
96 // The bookmark bubble, if we're showing one.
97 static BookmarkBubbleView
* bookmark_bubble_
;
99 // Our observer, to notify when the bubble shows or hides.
100 BookmarkBubbleViewObserver
* observer_
;
102 // Delegate, to handle clicks on the sign in link.
103 scoped_ptr
<BookmarkBubbleDelegate
> delegate_
;
111 // If true, the page was just bookmarked.
112 const bool newly_bookmarked_
;
114 RecentlyUsedFoldersComboModel parent_model_
;
116 // Button for removing the bookmark.
117 views::LabelButton
* remove_button_
;
119 // Button to bring up the editor.
120 views::LabelButton
* edit_button_
;
122 // Button to close the window.
123 views::LabelButton
* close_button_
;
125 // Textfield showing the title of the bookmark.
126 views::Textfield
* title_tf_
;
128 // Combobox showing a handful of folders the user can choose from, including
129 // the current parent.
130 views::Combobox
* parent_combobox_
;
132 // Bookmark sync promo view, if displayed.
133 views::View
* sync_promo_view_
;
135 // When the destructor is invoked should the bookmark be removed?
136 bool remove_bookmark_
;
138 // When the destructor is invoked should edits be applied?
141 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView
);
144 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_