| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" |
| 11 #include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" | 14 #include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" |
| 12 #include "ui/views/bubble/bubble_delegate.h" | 15 #include "ui/views/bubble/bubble_delegate.h" |
| 13 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/controls/combobox/combobox_listener.h" | 17 #include "ui/views/controls/combobox/combobox_listener.h" |
| 15 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 16 | 19 |
| 17 class BookmarkBubbleViewObserver; | 20 class BookmarkBubbleViewObserver; |
| 18 class Profile; | 21 class Profile; |
| 19 | 22 |
| 20 namespace views { | 23 namespace views { |
| 21 class LabelButton; | 24 class LabelButton; |
| 22 class Textfield; | 25 class Textfield; |
| 23 } | 26 } |
| 24 | 27 |
| 25 // BookmarkBubbleView is a view intended to be used as the content of an | 28 // BookmarkBubbleView is a view intended to be used as the content of an |
| 26 // Bubble. BookmarkBubbleView provides views for unstarring and editing the | 29 // Bubble. BookmarkBubbleView provides views for unstarring and editing the |
| 27 // bookmark it is created with. Don't create a BookmarkBubbleView directly, | 30 // bookmark it is created with. Don't create a BookmarkBubbleView directly, |
| 28 // instead use the static Show method. | 31 // instead use the static Show method. |
| 29 class BookmarkBubbleView : public views::BubbleDelegateView, | 32 class BookmarkBubbleView : public views::BubbleDelegateView, |
| 30 public views::ButtonListener, | 33 public views::ButtonListener, |
| 31 public views::ComboboxListener { | 34 public views::ComboboxListener { |
| 32 public: | 35 public: |
| 33 static void ShowBubble(views::View* anchor_view, | 36 static void ShowBubble(views::View* anchor_view, |
| 34 BookmarkBubbleViewObserver* observer, | 37 BookmarkBubbleViewObserver* observer, |
| 38 scoped_ptr<BookmarkBubbleDelegate> delegate, |
| 35 Profile* profile, | 39 Profile* profile, |
| 36 const GURL& url, | 40 const GURL& url, |
| 37 bool newly_bookmarked); | 41 bool newly_bookmarked); |
| 38 | 42 |
| 39 static bool IsShowing(); | 43 static bool IsShowing(); |
| 40 | 44 |
| 41 static void Hide(); | 45 static void Hide(); |
| 42 | 46 |
| 43 virtual ~BookmarkBubbleView(); | 47 virtual ~BookmarkBubbleView(); |
| 44 | 48 |
| 45 // views::BubbleDelegateView method. | 49 // views::BubbleDelegateView method. |
| 46 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 50 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
| 47 | 51 |
| 48 // views::WidgetDelegate method. | 52 // views::WidgetDelegate method. |
| 49 virtual void WindowClosing() OVERRIDE; | 53 virtual void WindowClosing() OVERRIDE; |
| 50 | 54 |
| 51 // views::View method. | 55 // views::View method. |
| 52 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 56 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 53 | 57 |
| 54 protected: | 58 protected: |
| 55 // views::BubbleDelegateView method. | 59 // views::BubbleDelegateView method. |
| 56 virtual void Init() OVERRIDE; | 60 virtual void Init() OVERRIDE; |
| 57 | 61 |
| 58 private: | 62 private: |
| 63 friend class BookmarkBubbleViewTest; |
| 64 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoSignedIn); |
| 65 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoNotSignedIn); |
| 66 |
| 59 // Creates a BookmarkBubbleView. | 67 // Creates a BookmarkBubbleView. |
| 60 BookmarkBubbleView(views::View* anchor_view, | 68 BookmarkBubbleView(views::View* anchor_view, |
| 61 BookmarkBubbleViewObserver* observer, | 69 BookmarkBubbleViewObserver* observer, |
| 70 scoped_ptr<BookmarkBubbleDelegate> delegate, |
| 62 Profile* profile, | 71 Profile* profile, |
| 63 const GURL& url, | 72 const GURL& url, |
| 64 bool newly_bookmarked); | 73 bool newly_bookmarked); |
| 65 | 74 |
| 66 // Returns the title to display. | 75 // Returns the title to display. |
| 67 string16 GetTitle(); | 76 string16 GetTitle(); |
| 68 | 77 |
| 69 // Overridden from views::View: | 78 // Overridden from views::View: |
| 70 virtual gfx::Size GetMinimumSize() OVERRIDE; | 79 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 71 | 80 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 85 | 94 |
| 86 // Sets the title and parent of the node. | 95 // Sets the title and parent of the node. |
| 87 void ApplyEdits(); | 96 void ApplyEdits(); |
| 88 | 97 |
| 89 // The bookmark bubble, if we're showing one. | 98 // The bookmark bubble, if we're showing one. |
| 90 static BookmarkBubbleView* bookmark_bubble_; | 99 static BookmarkBubbleView* bookmark_bubble_; |
| 91 | 100 |
| 92 // Our observer, to notify when the bubble shows or hides. | 101 // Our observer, to notify when the bubble shows or hides. |
| 93 BookmarkBubbleViewObserver* observer_; | 102 BookmarkBubbleViewObserver* observer_; |
| 94 | 103 |
| 104 // Delegate, to handle clicks on the sign in link. |
| 105 scoped_ptr<BookmarkBubbleDelegate> delegate_; |
| 106 |
| 95 // The profile. | 107 // The profile. |
| 96 Profile* profile_; | 108 Profile* profile_; |
| 97 | 109 |
| 98 // The bookmark URL. | 110 // The bookmark URL. |
| 99 const GURL url_; | 111 const GURL url_; |
| 100 | 112 |
| 101 // If true, the page was just bookmarked. | 113 // If true, the page was just bookmarked. |
| 102 const bool newly_bookmarked_; | 114 const bool newly_bookmarked_; |
| 103 | 115 |
| 104 RecentlyUsedFoldersComboModel parent_model_; | 116 RecentlyUsedFoldersComboModel parent_model_; |
| 105 | 117 |
| 106 // Button for removing the bookmark. | 118 // Button for removing the bookmark. |
| 107 views::LabelButton* remove_button_; | 119 views::LabelButton* remove_button_; |
| 108 | 120 |
| 109 // Button to bring up the editor. | 121 // Button to bring up the editor. |
| 110 views::LabelButton* edit_button_; | 122 views::LabelButton* edit_button_; |
| 111 | 123 |
| 112 // Button to close the window. | 124 // Button to close the window. |
| 113 views::LabelButton* close_button_; | 125 views::LabelButton* close_button_; |
| 114 | 126 |
| 115 // Textfield showing the title of the bookmark. | 127 // Textfield showing the title of the bookmark. |
| 116 views::Textfield* title_tf_; | 128 views::Textfield* title_tf_; |
| 117 | 129 |
| 118 // Combobox showing a handful of folders the user can choose from, including | 130 // Combobox showing a handful of folders the user can choose from, including |
| 119 // the current parent. | 131 // the current parent. |
| 120 views::Combobox* parent_combobox_; | 132 views::Combobox* parent_combobox_; |
| 121 | 133 |
| 134 // Bookmark sync promo view, if displayed. |
| 135 views::View* sync_promo_view_; |
| 136 |
| 122 // When the destructor is invoked should the bookmark be removed? | 137 // When the destructor is invoked should the bookmark be removed? |
| 123 bool remove_bookmark_; | 138 bool remove_bookmark_; |
| 124 | 139 |
| 125 // When the destructor is invoked should edits be applied? | 140 // When the destructor is invoked should edits be applied? |
| 126 bool apply_edits_; | 141 bool apply_edits_; |
| 127 | 142 |
| 128 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); | 143 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); |
| 129 }; | 144 }; |
| 130 | 145 |
| 131 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ | 146 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ |
| OLD | NEW |