| 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 <memory> |
| 9 |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 9 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" | 14 #include "chrome/browser/ui/bookmarks/recently_used_folders_combo_model.h" |
| 14 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" | 15 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" |
| 15 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view
.h" | 16 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view
.h" |
| 16 #include "ui/views/controls/button/button.h" | 17 #include "ui/views/controls/button/button.h" |
| 17 #include "ui/views/controls/combobox/combobox_listener.h" | 18 #include "ui/views/controls/combobox/combobox_listener.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| 20 class Profile; | 21 class Profile; |
| 21 | 22 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 // bookmark it is created with. Don't create a BookmarkBubbleView directly, | 34 // bookmark it is created with. Don't create a BookmarkBubbleView directly, |
| 34 // instead use the static Show method. | 35 // instead use the static Show method. |
| 35 class BookmarkBubbleView : public LocationBarBubbleDelegateView, | 36 class BookmarkBubbleView : public LocationBarBubbleDelegateView, |
| 36 public views::ButtonListener, | 37 public views::ButtonListener, |
| 37 public views::ComboboxListener { | 38 public views::ComboboxListener { |
| 38 public: | 39 public: |
| 39 // If |anchor_view| is null, |anchor_rect| is used to anchor the bubble and | 40 // If |anchor_view| is null, |anchor_rect| is used to anchor the bubble and |
| 40 // |parent_window| is used to ensure the bubble closes if the parent closes. | 41 // |parent_window| is used to ensure the bubble closes if the parent closes. |
| 41 // Returns the newly created bubble's Widget or nullptr in case when the | 42 // Returns the newly created bubble's Widget or nullptr in case when the |
| 42 // bubble already exists. | 43 // bubble already exists. |
| 43 static views::Widget* ShowBubble(views::View* anchor_view, | 44 static views::Widget* ShowBubble( |
| 44 const gfx::Rect& anchor_rect, | 45 views::View* anchor_view, |
| 45 gfx::NativeView parent_window, | 46 const gfx::Rect& anchor_rect, |
| 46 bookmarks::BookmarkBubbleObserver* observer, | 47 gfx::NativeView parent_window, |
| 47 scoped_ptr<BubbleSyncPromoDelegate> delegate, | 48 bookmarks::BookmarkBubbleObserver* observer, |
| 48 Profile* profile, | 49 std::unique_ptr<BubbleSyncPromoDelegate> delegate, |
| 49 const GURL& url, | 50 Profile* profile, |
| 50 bool already_bookmarked); | 51 const GURL& url, |
| 52 bool already_bookmarked); |
| 51 | 53 |
| 52 static void Hide(); | 54 static void Hide(); |
| 53 | 55 |
| 54 static BookmarkBubbleView* bookmark_bubble() { return bookmark_bubble_; } | 56 static BookmarkBubbleView* bookmark_bubble() { return bookmark_bubble_; } |
| 55 | 57 |
| 56 ~BookmarkBubbleView() override; | 58 ~BookmarkBubbleView() override; |
| 57 | 59 |
| 58 // views::WidgetDelegate: | 60 // views::WidgetDelegate: |
| 59 void WindowClosing() override; | 61 void WindowClosing() override; |
| 60 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 62 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 61 | 63 |
| 62 protected: | 64 protected: |
| 63 // views::BubbleDelegateView method. | 65 // views::BubbleDelegateView method. |
| 64 void Init() override; | 66 void Init() override; |
| 65 base::string16 GetWindowTitle() const override; | 67 base::string16 GetWindowTitle() const override; |
| 66 | 68 |
| 67 private: | 69 private: |
| 68 friend class BookmarkBubbleViewTest; | 70 friend class BookmarkBubbleViewTest; |
| 69 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoSignedIn); | 71 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoSignedIn); |
| 70 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoNotSignedIn); | 72 FRIEND_TEST_ALL_PREFIXES(BookmarkBubbleViewTest, SyncPromoNotSignedIn); |
| 71 | 73 |
| 72 // views::BubbleDelegateView: | 74 // views::BubbleDelegateView: |
| 73 const char* GetClassName() const override; | 75 const char* GetClassName() const override; |
| 74 View* GetInitiallyFocusedView() override; | 76 View* GetInitiallyFocusedView() override; |
| 75 View* CreateFootnoteView() override; | 77 View* CreateFootnoteView() override; |
| 76 | 78 |
| 77 // Creates a BookmarkBubbleView. | 79 // Creates a BookmarkBubbleView. |
| 78 BookmarkBubbleView(views::View* anchor_view, | 80 BookmarkBubbleView(views::View* anchor_view, |
| 79 bookmarks::BookmarkBubbleObserver* observer, | 81 bookmarks::BookmarkBubbleObserver* observer, |
| 80 scoped_ptr<BubbleSyncPromoDelegate> delegate, | 82 std::unique_ptr<BubbleSyncPromoDelegate> delegate, |
| 81 Profile* profile, | 83 Profile* profile, |
| 82 const GURL& url, | 84 const GURL& url, |
| 83 bool newly_bookmarked); | 85 bool newly_bookmarked); |
| 84 | 86 |
| 85 // Returns the title to display. | 87 // Returns the title to display. |
| 86 base::string16 GetTitle(); | 88 base::string16 GetTitle(); |
| 87 | 89 |
| 88 // Overridden from views::View: | 90 // Overridden from views::View: |
| 89 void GetAccessibleState(ui::AXViewState* state) override; | 91 void GetAccessibleState(ui::AXViewState* state) override; |
| 90 | 92 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 104 // Sets the title and parent of the node. | 106 // Sets the title and parent of the node. |
| 105 void ApplyEdits(); | 107 void ApplyEdits(); |
| 106 | 108 |
| 107 // The bookmark bubble, if we're showing one. | 109 // The bookmark bubble, if we're showing one. |
| 108 static BookmarkBubbleView* bookmark_bubble_; | 110 static BookmarkBubbleView* bookmark_bubble_; |
| 109 | 111 |
| 110 // Our observer, to notify when the bubble shows or hides. | 112 // Our observer, to notify when the bubble shows or hides. |
| 111 bookmarks::BookmarkBubbleObserver* observer_; | 113 bookmarks::BookmarkBubbleObserver* observer_; |
| 112 | 114 |
| 113 // Delegate, to handle clicks on the sign in link. | 115 // Delegate, to handle clicks on the sign in link. |
| 114 scoped_ptr<BubbleSyncPromoDelegate> delegate_; | 116 std::unique_ptr<BubbleSyncPromoDelegate> delegate_; |
| 115 | 117 |
| 116 // The profile. | 118 // The profile. |
| 117 Profile* profile_; | 119 Profile* profile_; |
| 118 | 120 |
| 119 // The bookmark URL. | 121 // The bookmark URL. |
| 120 const GURL url_; | 122 const GURL url_; |
| 121 | 123 |
| 122 // If true, the page was just bookmarked. | 124 // If true, the page was just bookmarked. |
| 123 const bool newly_bookmarked_; | 125 const bool newly_bookmarked_; |
| 124 | 126 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 143 // When the destructor is invoked should the bookmark be removed? | 145 // When the destructor is invoked should the bookmark be removed? |
| 144 bool remove_bookmark_; | 146 bool remove_bookmark_; |
| 145 | 147 |
| 146 // When the destructor is invoked should edits be applied? | 148 // When the destructor is invoked should edits be applied? |
| 147 bool apply_edits_; | 149 bool apply_edits_; |
| 148 | 150 |
| 149 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); | 151 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); |
| 150 }; | 152 }; |
| 151 | 153 |
| 152 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ | 154 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ |
| OLD | NEW |