| 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_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 static const int kNewtabHorizontalPadding; | 78 static const int kNewtabHorizontalPadding; |
| 79 | 79 |
| 80 // Maximum size of buttons on the bookmark bar. | 80 // Maximum size of buttons on the bookmark bar. |
| 81 static const int kMaxButtonWidth; | 81 static const int kMaxButtonWidth; |
| 82 | 82 |
| 83 // Number of pixels the attached bookmark bar overlaps with the toolbar. | 83 // Number of pixels the attached bookmark bar overlaps with the toolbar. |
| 84 static const int kToolbarAttachedBookmarkBarOverlap; | 84 static const int kToolbarAttachedBookmarkBarOverlap; |
| 85 | 85 |
| 86 // |browser_view| can be NULL during tests. | 86 // |browser_view| can be NULL during tests. |
| 87 BookmarkBarView(Browser* browser, BrowserView* browser_view); | 87 BookmarkBarView(Browser* browser, BrowserView* browser_view); |
| 88 virtual ~BookmarkBarView(); | 88 ~BookmarkBarView() override; |
| 89 | 89 |
| 90 static void DisableAnimationsForTesting(bool disabled); | 90 static void DisableAnimationsForTesting(bool disabled); |
| 91 | 91 |
| 92 // Returns the current browser. | 92 // Returns the current browser. |
| 93 Browser* browser() const { return browser_; } | 93 Browser* browser() const { return browser_; } |
| 94 | 94 |
| 95 void AddObserver(BookmarkBarViewObserver* observer); | 95 void AddObserver(BookmarkBarViewObserver* observer); |
| 96 void RemoveObserver(BookmarkBarViewObserver* observer); | 96 void RemoveObserver(BookmarkBarViewObserver* observer); |
| 97 | 97 |
| 98 // Sets the PageNavigator that is used when the user selects an entry on | 98 // Sets the PageNavigator that is used when the user selects an entry on |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // | 159 // |
| 160 // Note that we adjust the direction of both the URL and the title based on | 160 // Note that we adjust the direction of both the URL and the title based on |
| 161 // the locale so that pure LTR strings are displayed properly in RTL locales. | 161 // the locale so that pure LTR strings are displayed properly in RTL locales. |
| 162 static base::string16 CreateToolTipForURLAndTitle(const views::Widget* widget, | 162 static base::string16 CreateToolTipForURLAndTitle(const views::Widget* widget, |
| 163 const gfx::Point& screen_loc, | 163 const gfx::Point& screen_loc, |
| 164 const GURL& url, | 164 const GURL& url, |
| 165 const base::string16& title, | 165 const base::string16& title, |
| 166 Profile* profile); | 166 Profile* profile); |
| 167 | 167 |
| 168 // DetachableToolbarView methods: | 168 // DetachableToolbarView methods: |
| 169 virtual bool IsDetached() const override; | 169 bool IsDetached() const override; |
| 170 virtual double GetAnimationValue() const override; | 170 double GetAnimationValue() const override; |
| 171 virtual int GetToolbarOverlap() const override; | 171 int GetToolbarOverlap() const override; |
| 172 | 172 |
| 173 // View methods: | 173 // View methods: |
| 174 virtual gfx::Size GetPreferredSize() const override; | 174 gfx::Size GetPreferredSize() const override; |
| 175 virtual gfx::Size GetMinimumSize() const override; | 175 gfx::Size GetMinimumSize() const override; |
| 176 virtual bool CanProcessEventsWithinSubtree() const override; | 176 bool CanProcessEventsWithinSubtree() const override; |
| 177 virtual void Layout() override; | 177 void Layout() override; |
| 178 virtual void ViewHierarchyChanged( | 178 void ViewHierarchyChanged( |
| 179 const ViewHierarchyChangedDetails& details) override; | 179 const ViewHierarchyChangedDetails& details) override; |
| 180 virtual void PaintChildren(gfx::Canvas* canvas, | 180 void PaintChildren(gfx::Canvas* canvas, |
| 181 const views::CullSet& cull_set) override; | 181 const views::CullSet& cull_set) override; |
| 182 virtual bool GetDropFormats( | 182 bool GetDropFormats( |
| 183 int* formats, | 183 int* formats, |
| 184 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; | 184 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) override; |
| 185 virtual bool AreDropTypesRequired() override; | 185 bool AreDropTypesRequired() override; |
| 186 virtual bool CanDrop(const ui::OSExchangeData& data) override; | 186 bool CanDrop(const ui::OSExchangeData& data) override; |
| 187 virtual void OnDragEntered(const ui::DropTargetEvent& event) override; | 187 void OnDragEntered(const ui::DropTargetEvent& event) override; |
| 188 virtual int OnDragUpdated(const ui::DropTargetEvent& event) override; | 188 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
| 189 virtual void OnDragExited() override; | 189 void OnDragExited() override; |
| 190 virtual int OnPerformDrop(const ui::DropTargetEvent& event) override; | 190 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
| 191 virtual void OnThemeChanged() override; | 191 void OnThemeChanged() override; |
| 192 virtual const char* GetClassName() const override; | 192 const char* GetClassName() const override; |
| 193 virtual void SetVisible(bool visible) override; | 193 void SetVisible(bool visible) override; |
| 194 | 194 |
| 195 // AccessiblePaneView: | 195 // AccessiblePaneView: |
| 196 virtual void GetAccessibleState(ui::AXViewState* state) override; | 196 void GetAccessibleState(ui::AXViewState* state) override; |
| 197 | 197 |
| 198 // gfx::AnimationDelegate: | 198 // gfx::AnimationDelegate: |
| 199 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 199 void AnimationProgressed(const gfx::Animation* animation) override; |
| 200 virtual void AnimationEnded(const gfx::Animation* animation) override; | 200 void AnimationEnded(const gfx::Animation* animation) override; |
| 201 | 201 |
| 202 // BookmarkMenuControllerObserver: | 202 // BookmarkMenuControllerObserver: |
| 203 virtual void BookmarkMenuControllerDeleted( | 203 void BookmarkMenuControllerDeleted( |
| 204 BookmarkMenuController* controller) override; | 204 BookmarkMenuController* controller) override; |
| 205 | 205 |
| 206 // BookmarkBarInstructionsDelegate: | 206 // BookmarkBarInstructionsDelegate: |
| 207 virtual void ShowImportDialog() override; | 207 void ShowImportDialog() override; |
| 208 | 208 |
| 209 // BookmarkBubbleViewObserver: | 209 // BookmarkBubbleViewObserver: |
| 210 virtual void OnBookmarkBubbleShown(const GURL& url) override; | 210 void OnBookmarkBubbleShown(const GURL& url) override; |
| 211 virtual void OnBookmarkBubbleHidden() override; | 211 void OnBookmarkBubbleHidden() override; |
| 212 | 212 |
| 213 // BookmarkModelObserver: | 213 // BookmarkModelObserver: |
| 214 virtual void BookmarkModelLoaded(BookmarkModel* model, | 214 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override; |
| 215 bool ids_reassigned) override; | 215 void BookmarkModelBeingDeleted(BookmarkModel* model) override; |
| 216 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) override; | 216 void BookmarkNodeMoved(BookmarkModel* model, |
| 217 virtual void BookmarkNodeMoved(BookmarkModel* model, | 217 const BookmarkNode* old_parent, |
| 218 const BookmarkNode* old_parent, | 218 int old_index, |
| 219 int old_index, | 219 const BookmarkNode* new_parent, |
| 220 const BookmarkNode* new_parent, | 220 int new_index) override; |
| 221 int new_index) override; | 221 void BookmarkNodeAdded(BookmarkModel* model, |
| 222 virtual void BookmarkNodeAdded(BookmarkModel* model, | 222 const BookmarkNode* parent, |
| 223 const BookmarkNode* parent, | 223 int index) override; |
| 224 int index) override; | 224 void BookmarkNodeRemoved(BookmarkModel* model, |
| 225 virtual void BookmarkNodeRemoved(BookmarkModel* model, | 225 const BookmarkNode* parent, |
| 226 const BookmarkNode* parent, | 226 int old_index, |
| 227 int old_index, | 227 const BookmarkNode* node, |
| 228 const BookmarkNode* node, | 228 const std::set<GURL>& removed_urls) override; |
| 229 void BookmarkAllUserNodesRemoved(BookmarkModel* model, |
| 229 const std::set<GURL>& removed_urls) override; | 230 const std::set<GURL>& removed_urls) override; |
| 230 virtual void BookmarkAllUserNodesRemoved( | 231 void BookmarkNodeChanged(BookmarkModel* model, |
| 231 BookmarkModel* model, | 232 const BookmarkNode* node) override; |
| 232 const std::set<GURL>& removed_urls) override; | 233 void BookmarkNodeChildrenReordered(BookmarkModel* model, |
| 233 virtual void BookmarkNodeChanged(BookmarkModel* model, | 234 const BookmarkNode* node) override; |
| 234 const BookmarkNode* node) override; | 235 void BookmarkNodeFaviconChanged(BookmarkModel* model, |
| 235 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, | 236 const BookmarkNode* node) override; |
| 236 const BookmarkNode* node) override; | |
| 237 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, | |
| 238 const BookmarkNode* node) override; | |
| 239 | 237 |
| 240 // views::DragController: | 238 // views::DragController: |
| 241 virtual void WriteDragDataForView(views::View* sender, | 239 void WriteDragDataForView(views::View* sender, |
| 242 const gfx::Point& press_pt, | 240 const gfx::Point& press_pt, |
| 243 ui::OSExchangeData* data) override; | 241 ui::OSExchangeData* data) override; |
| 244 virtual int GetDragOperationsForView(views::View* sender, | 242 int GetDragOperationsForView(views::View* sender, |
| 245 const gfx::Point& p) override; | 243 const gfx::Point& p) override; |
| 246 virtual bool CanStartDragForView(views::View* sender, | 244 bool CanStartDragForView(views::View* sender, |
| 247 const gfx::Point& press_pt, | 245 const gfx::Point& press_pt, |
| 248 const gfx::Point& p) override; | 246 const gfx::Point& p) override; |
| 249 | 247 |
| 250 // views::MenuButtonListener: | 248 // views::MenuButtonListener: |
| 251 virtual void OnMenuButtonClicked(views::View* view, | 249 void OnMenuButtonClicked(views::View* view, const gfx::Point& point) override; |
| 252 const gfx::Point& point) override; | |
| 253 | 250 |
| 254 // views::ButtonListener: | 251 // views::ButtonListener: |
| 255 virtual void ButtonPressed(views::Button* sender, | 252 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 256 const ui::Event& event) override; | |
| 257 | 253 |
| 258 // views::ContextMenuController: | 254 // views::ContextMenuController: |
| 259 virtual void ShowContextMenuForView(views::View* source, | 255 void ShowContextMenuForView(views::View* source, |
| 260 const gfx::Point& point, | 256 const gfx::Point& point, |
| 261 ui::MenuSourceType source_type) override; | 257 ui::MenuSourceType source_type) override; |
| 262 | 258 |
| 263 private: | 259 private: |
| 264 class ButtonSeparatorView; | 260 class ButtonSeparatorView; |
| 265 struct DropInfo; | 261 struct DropInfo; |
| 266 struct DropLocation; | 262 struct DropLocation; |
| 267 | 263 |
| 268 friend class BookmarkBarViewTestHelper; | 264 friend class BookmarkBarViewTestHelper; |
| 269 friend class BookmarkBarViewEventTestBase; | 265 friend class BookmarkBarViewEventTestBase; |
| 270 | 266 |
| 271 // Used to identify what the user is dropping onto. | 267 // Used to identify what the user is dropping onto. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 453 |
| 458 ObserverList<BookmarkBarViewObserver> observers_; | 454 ObserverList<BookmarkBarViewObserver> observers_; |
| 459 | 455 |
| 460 // Factory used to delay showing of the drop menu. | 456 // Factory used to delay showing of the drop menu. |
| 461 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_; | 457 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_; |
| 462 | 458 |
| 463 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); | 459 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); |
| 464 }; | 460 }; |
| 465 | 461 |
| 466 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ | 462 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ |
| OLD | NEW |