| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int GetFullyDetachedToolbarOverlap() const; | 106 int GetFullyDetachedToolbarOverlap() const; |
| 107 | 107 |
| 108 // Whether or not we are animating. | 108 // Whether or not we are animating. |
| 109 bool is_animating(); | 109 bool is_animating(); |
| 110 | 110 |
| 111 // If |loc| is over a bookmark button the node is returned corresponding to | 111 // If |loc| is over a bookmark button the node is returned corresponding to |
| 112 // the button and |model_start_index| is set to 0. If a overflow button is | 112 // the button and |model_start_index| is set to 0. If a overflow button is |
| 113 // showing and |loc| is over the overflow button, the bookmark bar node is | 113 // showing and |loc| is over the overflow button, the bookmark bar node is |
| 114 // returned and |model_start_index| is set to the index of the first node | 114 // returned and |model_start_index| is set to the index of the first node |
| 115 // contained in the overflow menu. | 115 // contained in the overflow menu. |
| 116 const BookmarkNode* GetNodeForButtonAtModelIndex(const gfx::Point& loc, | 116 const bookmarks::BookmarkNode* GetNodeForButtonAtModelIndex( |
| 117 int* model_start_index); | 117 const gfx::Point& loc, |
| 118 int* model_start_index); |
| 118 | 119 |
| 119 // Returns the MenuButton for node. | 120 // Returns the MenuButton for node. |
| 120 views::MenuButton* GetMenuButtonForNode(const BookmarkNode* node); | 121 views::MenuButton* GetMenuButtonForNode(const bookmarks::BookmarkNode* node); |
| 121 | 122 |
| 122 // Returns the position to anchor the menu for |button| at. | 123 // Returns the position to anchor the menu for |button| at. |
| 123 void GetAnchorPositionForButton(views::MenuButton* button, | 124 void GetAnchorPositionForButton(views::MenuButton* button, |
| 124 views::MenuAnchorPosition* anchor); | 125 views::MenuAnchorPosition* anchor); |
| 125 | 126 |
| 126 // Returns the button responsible for showing bookmarks in the | 127 // Returns the button responsible for showing bookmarks in the |
| 127 // "Other Bookmarks" folder. | 128 // "Other Bookmarks" folder. |
| 128 views::MenuButton* other_bookmarks_button() const { | 129 views::MenuButton* other_bookmarks_button() const { |
| 129 return other_bookmarks_button_; | 130 return other_bookmarks_button_; |
| 130 } | 131 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 206 |
| 206 // BookmarkBubbleViewObserver: | 207 // BookmarkBubbleViewObserver: |
| 207 void OnBookmarkBubbleShown(const GURL& url) override; | 208 void OnBookmarkBubbleShown(const GURL& url) override; |
| 208 void OnBookmarkBubbleHidden() override; | 209 void OnBookmarkBubbleHidden() override; |
| 209 | 210 |
| 210 // bookmarks::BookmarkModelObserver: | 211 // bookmarks::BookmarkModelObserver: |
| 211 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, | 212 void BookmarkModelLoaded(bookmarks::BookmarkModel* model, |
| 212 bool ids_reassigned) override; | 213 bool ids_reassigned) override; |
| 213 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override; | 214 void BookmarkModelBeingDeleted(bookmarks::BookmarkModel* model) override; |
| 214 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, | 215 void BookmarkNodeMoved(bookmarks::BookmarkModel* model, |
| 215 const BookmarkNode* old_parent, | 216 const bookmarks::BookmarkNode* old_parent, |
| 216 int old_index, | 217 int old_index, |
| 217 const BookmarkNode* new_parent, | 218 const bookmarks::BookmarkNode* new_parent, |
| 218 int new_index) override; | 219 int new_index) override; |
| 219 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, | 220 void BookmarkNodeAdded(bookmarks::BookmarkModel* model, |
| 220 const BookmarkNode* parent, | 221 const bookmarks::BookmarkNode* parent, |
| 221 int index) override; | 222 int index) override; |
| 222 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, | 223 void BookmarkNodeRemoved(bookmarks::BookmarkModel* model, |
| 223 const BookmarkNode* parent, | 224 const bookmarks::BookmarkNode* parent, |
| 224 int old_index, | 225 int old_index, |
| 225 const BookmarkNode* node, | 226 const bookmarks::BookmarkNode* node, |
| 226 const std::set<GURL>& removed_urls) override; | 227 const std::set<GURL>& removed_urls) override; |
| 227 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, | 228 void BookmarkAllUserNodesRemoved(bookmarks::BookmarkModel* model, |
| 228 const std::set<GURL>& removed_urls) override; | 229 const std::set<GURL>& removed_urls) override; |
| 229 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, | 230 void BookmarkNodeChanged(bookmarks::BookmarkModel* model, |
| 230 const BookmarkNode* node) override; | 231 const bookmarks::BookmarkNode* node) override; |
| 231 void BookmarkNodeChildrenReordered(bookmarks::BookmarkModel* model, | 232 void BookmarkNodeChildrenReordered( |
| 232 const BookmarkNode* node) override; | 233 bookmarks::BookmarkModel* model, |
| 234 const bookmarks::BookmarkNode* node) override; |
| 233 void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel* model, | 235 void BookmarkNodeFaviconChanged(bookmarks::BookmarkModel* model, |
| 234 const BookmarkNode* node) override; | 236 const bookmarks::BookmarkNode* node) override; |
| 235 | 237 |
| 236 // views::DragController: | 238 // views::DragController: |
| 237 void WriteDragDataForView(views::View* sender, | 239 void WriteDragDataForView(views::View* sender, |
| 238 const gfx::Point& press_pt, | 240 const gfx::Point& press_pt, |
| 239 ui::OSExchangeData* data) override; | 241 ui::OSExchangeData* data) override; |
| 240 int GetDragOperationsForView(views::View* sender, | 242 int GetDragOperationsForView(views::View* sender, |
| 241 const gfx::Point& p) override; | 243 const gfx::Point& p) override; |
| 242 bool CanStartDragForView(views::View* sender, | 244 bool CanStartDragForView(views::View* sender, |
| 243 const gfx::Point& press_pt, | 245 const gfx::Point& press_pt, |
| 244 const gfx::Point& p) override; | 246 const gfx::Point& p) override; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // Creates the button showing the "Other Bookmarks" folder. | 303 // Creates the button showing the "Other Bookmarks" folder. |
| 302 views::MenuButton* CreateOtherBookmarksButton(); | 304 views::MenuButton* CreateOtherBookmarksButton(); |
| 303 | 305 |
| 304 // Creates the button showing the "Managed Bookmarks" folder. | 306 // Creates the button showing the "Managed Bookmarks" folder. |
| 305 views::MenuButton* CreateManagedBookmarksButton(); | 307 views::MenuButton* CreateManagedBookmarksButton(); |
| 306 | 308 |
| 307 // Creates the button used when not all bookmark buttons fit. | 309 // Creates the button used when not all bookmark buttons fit. |
| 308 views::MenuButton* CreateOverflowButton(); | 310 views::MenuButton* CreateOverflowButton(); |
| 309 | 311 |
| 310 // Creates the button for rendering the specified bookmark node. | 312 // Creates the button for rendering the specified bookmark node. |
| 311 views::View* CreateBookmarkButton(const BookmarkNode* node); | 313 views::View* CreateBookmarkButton(const bookmarks::BookmarkNode* node); |
| 312 | 314 |
| 313 // Creates the button for rendering the apps page shortcut. | 315 // Creates the button for rendering the apps page shortcut. |
| 314 views::LabelButton* CreateAppsPageShortcutButton(); | 316 views::LabelButton* CreateAppsPageShortcutButton(); |
| 315 | 317 |
| 316 // Configures the button from the specified node. This sets the text, | 318 // Configures the button from the specified node. This sets the text, |
| 317 // and icon. | 319 // and icon. |
| 318 void ConfigureButton(const BookmarkNode* node, views::LabelButton* button); | 320 void ConfigureButton(const bookmarks::BookmarkNode* node, |
| 321 views::LabelButton* button); |
| 319 | 322 |
| 320 // Implementation for BookmarkNodeAddedImpl. Returns true if LayoutAndPaint() | 323 // Implementation for BookmarkNodeAddedImpl. Returns true if LayoutAndPaint() |
| 321 // is required. | 324 // is required. |
| 322 bool BookmarkNodeAddedImpl(bookmarks::BookmarkModel* model, | 325 bool BookmarkNodeAddedImpl(bookmarks::BookmarkModel* model, |
| 323 const BookmarkNode* parent, | 326 const bookmarks::BookmarkNode* parent, |
| 324 int index); | 327 int index); |
| 325 | 328 |
| 326 // Implementation for BookmarkNodeRemoved. Returns true if LayoutAndPaint() is | 329 // Implementation for BookmarkNodeRemoved. Returns true if LayoutAndPaint() is |
| 327 // required. | 330 // required. |
| 328 bool BookmarkNodeRemovedImpl(bookmarks::BookmarkModel* model, | 331 bool BookmarkNodeRemovedImpl(bookmarks::BookmarkModel* model, |
| 329 const BookmarkNode* parent, | 332 const bookmarks::BookmarkNode* parent, |
| 330 int index); | 333 int index); |
| 331 | 334 |
| 332 // If the node is a child of the root node, the button is updated | 335 // If the node is a child of the root node, the button is updated |
| 333 // appropriately. | 336 // appropriately. |
| 334 void BookmarkNodeChangedImpl(bookmarks::BookmarkModel* model, | 337 void BookmarkNodeChangedImpl(bookmarks::BookmarkModel* model, |
| 335 const BookmarkNode* node); | 338 const bookmarks::BookmarkNode* node); |
| 336 | 339 |
| 337 // Shows the menu used during drag and drop for the specified node. | 340 // Shows the menu used during drag and drop for the specified node. |
| 338 void ShowDropFolderForNode(const BookmarkNode* node); | 341 void ShowDropFolderForNode(const bookmarks::BookmarkNode* node); |
| 339 | 342 |
| 340 // Cancels the timer used to show a drop menu. | 343 // Cancels the timer used to show a drop menu. |
| 341 void StopShowFolderDropMenuTimer(); | 344 void StopShowFolderDropMenuTimer(); |
| 342 | 345 |
| 343 // Stars the timer used to show a drop menu for node. | 346 // Stars the timer used to show a drop menu for node. |
| 344 void StartShowFolderDropMenuTimer(const BookmarkNode* node); | 347 void StartShowFolderDropMenuTimer(const bookmarks::BookmarkNode* node); |
| 345 | 348 |
| 346 // Calculates the location for the drop in |location|. | 349 // Calculates the location for the drop in |location|. |
| 347 void CalculateDropLocation(const ui::DropTargetEvent& event, | 350 void CalculateDropLocation(const ui::DropTargetEvent& event, |
| 348 const bookmarks::BookmarkNodeData& data, | 351 const bookmarks::BookmarkNodeData& data, |
| 349 DropLocation* location); | 352 DropLocation* location); |
| 350 | 353 |
| 351 // Writes a BookmarkNodeData for node to data. | 354 // Writes a BookmarkNodeData for node to data. |
| 352 void WriteBookmarkDragData(const BookmarkNode* node, | 355 void WriteBookmarkDragData(const bookmarks::BookmarkNode* node, |
| 353 ui::OSExchangeData* data); | 356 ui::OSExchangeData* data); |
| 354 | 357 |
| 355 // This determines which view should throb and starts it | 358 // This determines which view should throb and starts it |
| 356 // throbbing (e.g when the bookmark bubble is showing). | 359 // throbbing (e.g when the bookmark bubble is showing). |
| 357 // If |overflow_only| is true, start throbbing only if |node| is hidden in | 360 // If |overflow_only| is true, start throbbing only if |node| is hidden in |
| 358 // the overflow menu. | 361 // the overflow menu. |
| 359 void StartThrobbing(const BookmarkNode* node, bool overflow_only); | 362 void StartThrobbing(const bookmarks::BookmarkNode* node, bool overflow_only); |
| 360 | 363 |
| 361 // Returns the view to throb when a node is removed. |parent| is the parent of | 364 // Returns the view to throb when a node is removed. |parent| is the parent of |
| 362 // the node that was removed, and |old_index| the index of the node that was | 365 // the node that was removed, and |old_index| the index of the node that was |
| 363 // removed. | 366 // removed. |
| 364 views::CustomButton* DetermineViewToThrobFromRemove( | 367 views::CustomButton* DetermineViewToThrobFromRemove( |
| 365 const BookmarkNode* parent, | 368 const bookmarks::BookmarkNode* parent, |
| 366 int old_index); | 369 int old_index); |
| 367 | 370 |
| 368 // Updates the colors for all the child objects in the bookmarks bar. | 371 // Updates the colors for all the child objects in the bookmarks bar. |
| 369 void UpdateColors(); | 372 void UpdateColors(); |
| 370 | 373 |
| 371 // Updates the visibility of |other_bookmarks_button_| and | 374 // Updates the visibility of |other_bookmarks_button_| and |
| 372 // |managed_bookmarks_button_|. Also shows or hides the separator if required. | 375 // |managed_bookmarks_button_|. Also shows or hides the separator if required. |
| 373 // Returns true if something changed and a LayoutAndPaint() is needed. | 376 // Returns true if something changed and a LayoutAndPaint() is needed. |
| 374 bool UpdateOtherAndManagedButtonsVisibility(); | 377 bool UpdateOtherAndManagedButtonsVisibility(); |
| 375 | 378 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 457 |
| 455 ObserverList<BookmarkBarViewObserver> observers_; | 458 ObserverList<BookmarkBarViewObserver> observers_; |
| 456 | 459 |
| 457 // Factory used to delay showing of the drop menu. | 460 // Factory used to delay showing of the drop menu. |
| 458 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_; | 461 base::WeakPtrFactory<BookmarkBarView> show_folder_method_factory_; |
| 459 | 462 |
| 460 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); | 463 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); |
| 461 }; | 464 }; |
| 462 | 465 |
| 463 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ | 466 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ |
| OLD | NEW |