Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / bookmarks / bookmark_bubble_view.h
blobc7391aa7edb0a53d90c8a2d4b6ff210b890980c2
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"
18 #include "url/gurl.h"
20 class BookmarkBubbleViewObserver;
21 class Profile;
23 namespace views {
24 class LabelButton;
25 class Textfield;
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 {
35 public:
36 static void ShowBubble(views::View* anchor_view,
37 BookmarkBubbleViewObserver* observer,
38 scoped_ptr<BookmarkBubbleDelegate> delegate,
39 Profile* profile,
40 const GURL& url,
41 bool newly_bookmarked);
43 static bool IsShowing();
45 static void Hide();
47 virtual ~BookmarkBubbleView();
49 // views::BubbleDelegateView method.
50 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
52 // views::WidgetDelegate method.
53 virtual void WindowClosing() OVERRIDE;
55 // views::View method.
56 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
58 protected:
59 // views::BubbleDelegateView method.
60 virtual void Init() OVERRIDE;
62 private:
63 friend class BookmarkBubbleViewTest;
64 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoSignedIn);
65 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoNotSignedIn);
67 // Creates a BookmarkBubbleView.
68 BookmarkBubbleView(views::View* anchor_view,
69 BookmarkBubbleViewObserver* observer,
70 scoped_ptr<BookmarkBubbleDelegate> delegate,
71 Profile* profile,
72 const GURL& url,
73 bool newly_bookmarked);
75 // Returns the title to display.
76 base::string16 GetTitle();
78 // Overridden from views::View:
79 virtual gfx::Size GetMinimumSize() OVERRIDE;
80 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
82 // Overridden from views::ButtonListener:
83 // Closes the bubble or opens the edit dialog.
84 virtual void ButtonPressed(views::Button* sender,
85 const ui::Event& event) OVERRIDE;
87 // Overridden from views::ComboboxListener:
88 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE;
90 // Handle the message when the user presses a button.
91 void HandleButtonPressed(views::Button* sender);
93 // Shows the BookmarkEditor.
94 void ShowEditor();
96 // Sets the title and parent of the node.
97 void ApplyEdits();
99 // The bookmark bubble, if we're showing one.
100 static BookmarkBubbleView* bookmark_bubble_;
102 // Our observer, to notify when the bubble shows or hides.
103 BookmarkBubbleViewObserver* observer_;
105 // Delegate, to handle clicks on the sign in link.
106 scoped_ptr<BookmarkBubbleDelegate> delegate_;
108 // The profile.
109 Profile* profile_;
111 // The bookmark URL.
112 const GURL url_;
114 // If true, the page was just bookmarked.
115 const bool newly_bookmarked_;
117 RecentlyUsedFoldersComboModel parent_model_;
119 // Button for removing the bookmark.
120 views::LabelButton* remove_button_;
122 // Button to bring up the editor.
123 views::LabelButton* edit_button_;
125 // Button to close the window.
126 views::LabelButton* close_button_;
128 // Textfield showing the title of the bookmark.
129 views::Textfield* title_tf_;
131 // Combobox showing a handful of folders the user can choose from, including
132 // the current parent.
133 views::Combobox* parent_combobox_;
135 // Bookmark sync promo view, if displayed.
136 views::View* sync_promo_view_;
138 // When the destructor is invoked should the bookmark be removed?
139 bool remove_bookmark_;
141 // When the destructor is invoked should edits be applied?
142 bool apply_edits_;
144 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView);
147 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_