OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_VIEWS_BOOKMARK_BAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_ |
6 #define CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_ |
7 | 7 |
8 #include "app/slide_animation.h" | 8 #include "app/slide_animation.h" |
9 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 9 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
10 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 // BookmarkBarView renders the BookmarkModel. Each starred entry on the | 31 // BookmarkBarView renders the BookmarkModel. Each starred entry on the |
32 // BookmarkBar is rendered as a MenuButton. An additional MenuButton aligned to | 32 // BookmarkBar is rendered as a MenuButton. An additional MenuButton aligned to |
33 // the right allows the user to quickly see recently starred entries. | 33 // the right allows the user to quickly see recently starred entries. |
34 // | 34 // |
35 // BookmarkBarView shows the bookmarks from a specific Profile. BookmarkBarView | 35 // BookmarkBarView shows the bookmarks from a specific Profile. BookmarkBarView |
36 // waits until the HistoryService for the profile has been loaded before | 36 // waits until the HistoryService for the profile has been loaded before |
37 // creating the BookmarkModel. | 37 // creating the BookmarkModel. |
38 class BookmarkBarView : public DetachableToolbarView, | 38 class BookmarkBarView : public DetachableToolbarView, |
39 #if defined(BROWSER_SYNC) | |
40 public ProfileSyncServiceObserver, | 39 public ProfileSyncServiceObserver, |
41 #endif | |
42 public BookmarkModelObserver, | 40 public BookmarkModelObserver, |
43 public views::ViewMenuDelegate, | 41 public views::ViewMenuDelegate, |
44 public views::ButtonListener, | 42 public views::ButtonListener, |
45 public NotificationObserver, | 43 public NotificationObserver, |
46 public views::ContextMenuController, | 44 public views::ContextMenuController, |
47 public views::DragController, | 45 public views::DragController, |
48 public AnimationDelegate, | 46 public AnimationDelegate, |
49 public BookmarkMenuController::Observer { | 47 public BookmarkMenuController::Observer { |
50 friend class ShowFolderMenuTask; | 48 friend class ShowFolderMenuTask; |
51 | 49 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 virtual bool AreDropTypesRequired(); | 109 virtual bool AreDropTypesRequired(); |
112 virtual bool CanDrop(const OSExchangeData& data); | 110 virtual bool CanDrop(const OSExchangeData& data); |
113 virtual void OnDragEntered(const views::DropTargetEvent& event); | 111 virtual void OnDragEntered(const views::DropTargetEvent& event); |
114 virtual int OnDragUpdated(const views::DropTargetEvent& event); | 112 virtual int OnDragUpdated(const views::DropTargetEvent& event); |
115 virtual void OnDragExited(); | 113 virtual void OnDragExited(); |
116 virtual int OnPerformDrop(const views::DropTargetEvent& event); | 114 virtual int OnPerformDrop(const views::DropTargetEvent& event); |
117 virtual bool GetAccessibleName(std::wstring* name); | 115 virtual bool GetAccessibleName(std::wstring* name); |
118 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | 116 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
119 virtual void SetAccessibleName(const std::wstring& name); | 117 virtual void SetAccessibleName(const std::wstring& name); |
120 | 118 |
121 #if defined(BROWSER_SYNC) | |
122 // ProfileSyncServiceObserver method. | 119 // ProfileSyncServiceObserver method. |
123 virtual void OnStateChanged(); | 120 virtual void OnStateChanged(); |
124 #endif | |
125 | 121 |
126 // Called when fullscreen mode toggles on or off; this affects our layout. | 122 // Called when fullscreen mode toggles on or off; this affects our layout. |
127 void OnFullscreenToggled(bool fullscreen); | 123 void OnFullscreenToggled(bool fullscreen); |
128 | 124 |
129 // Sets the model change listener to listener. | 125 // Sets the model change listener to listener. |
130 void SetModelChangedListener(ModelChangedListener* listener) { | 126 void SetModelChangedListener(ModelChangedListener* listener) { |
131 model_changed_listener_ = listener; | 127 model_changed_listener_ = listener; |
132 } | 128 } |
133 | 129 |
134 // If the ModelChangedListener is listener, ModelChangeListener is set to | 130 // If the ModelChangedListener is listener, ModelChangeListener is set to |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 407 |
412 // Updates the colors for all the child objects in the bookmarks bar. | 408 // Updates the colors for all the child objects in the bookmarks bar. |
413 void UpdateColors(); | 409 void UpdateColors(); |
414 | 410 |
415 // This method computes the bounds for the bookmark bar items. If | 411 // This method computes the bounds for the bookmark bar items. If |
416 // |compute_bounds_only| = TRUE, the bounds for the items are just computed, | 412 // |compute_bounds_only| = TRUE, the bounds for the items are just computed, |
417 // but are not set. This mode is used by GetPreferredSize() to obtain the | 413 // but are not set. This mode is used by GetPreferredSize() to obtain the |
418 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set. | 414 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set. |
419 gfx::Size LayoutItems(bool compute_bounds_only); | 415 gfx::Size LayoutItems(bool compute_bounds_only); |
420 | 416 |
421 #if defined(BROWSER_SYNC) | |
422 // Determines whether the sync error button should appear on the bookmarks | 417 // Determines whether the sync error button should appear on the bookmarks |
423 // bar. | 418 // bar. |
424 bool ShouldShowSyncErrorButton(); | 419 bool ShouldShowSyncErrorButton(); |
425 | 420 |
426 // Creates the sync error button and adds it as a child view. | 421 // Creates the sync error button and adds it as a child view. |
427 views::TextButton* CreateSyncErrorButton(); | 422 views::TextButton* CreateSyncErrorButton(); |
428 #endif | 423 |
429 NotificationRegistrar registrar_; | 424 NotificationRegistrar registrar_; |
430 | 425 |
431 Profile* profile_; | 426 Profile* profile_; |
432 | 427 |
433 // Used for opening urls. | 428 // Used for opening urls. |
434 PageNavigator* page_navigator_; | 429 PageNavigator* page_navigator_; |
435 | 430 |
436 // Model providing details as to the starred entries/groups that should be | 431 // Model providing details as to the starred entries/groups that should be |
437 // shown. This is owned by the Profile. | 432 // shown. This is owned by the Profile. |
438 BookmarkModel* model_; | 433 BookmarkModel* model_; |
(...skipping 12 matching lines...) Expand all Loading... |
451 | 446 |
452 // ModelChangeListener. | 447 // ModelChangeListener. |
453 ModelChangedListener* model_changed_listener_; | 448 ModelChangedListener* model_changed_listener_; |
454 | 449 |
455 // Task used to delay showing of the drop menu. | 450 // Task used to delay showing of the drop menu. |
456 ShowFolderDropMenuTask* show_folder_drop_menu_task_; | 451 ShowFolderDropMenuTask* show_folder_drop_menu_task_; |
457 | 452 |
458 // Used to track drops on the bookmark bar view. | 453 // Used to track drops on the bookmark bar view. |
459 scoped_ptr<DropInfo> drop_info_; | 454 scoped_ptr<DropInfo> drop_info_; |
460 | 455 |
461 #if defined(BROWSER_SYNC) | |
462 // The sync re-login indicator which appears when the user needs to re-enter | 456 // The sync re-login indicator which appears when the user needs to re-enter |
463 // credentials in order to continue syncing. | 457 // credentials in order to continue syncing. |
464 views::TextButton* sync_error_button_; | 458 views::TextButton* sync_error_button_; |
465 | 459 |
466 // A pointer to the ProfileSyncService instance if one exists. | 460 // A pointer to the ProfileSyncService instance if one exists. |
467 ProfileSyncService* sync_service_; | 461 ProfileSyncService* sync_service_; |
468 #endif | |
469 | 462 |
470 // Visible if not all the bookmark buttons fit. | 463 // Visible if not all the bookmark buttons fit. |
471 views::MenuButton* overflow_button_; | 464 views::MenuButton* overflow_button_; |
472 | 465 |
473 // If no bookmarks are visible, we show some text explaining the bar. | 466 // If no bookmarks are visible, we show some text explaining the bar. |
474 views::Label* instructions_; | 467 views::Label* instructions_; |
475 | 468 |
476 ButtonSeparatorView* bookmarks_separator_view_; | 469 ButtonSeparatorView* bookmarks_separator_view_; |
477 | 470 |
478 // Owning browser. This is NULL during testing. | 471 // Owning browser. This is NULL during testing. |
(...skipping 13 matching lines...) Expand all Loading... |
492 // Background for extension toolstrips. | 485 // Background for extension toolstrips. |
493 SkBitmap toolstrip_background_; | 486 SkBitmap toolstrip_background_; |
494 | 487 |
495 // Storage of strings needed for accessibility. | 488 // Storage of strings needed for accessibility. |
496 std::wstring accessible_name_; | 489 std::wstring accessible_name_; |
497 | 490 |
498 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); | 491 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); |
499 }; | 492 }; |
500 | 493 |
501 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_ | 494 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_ |
OLD | NEW |