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" |
11 #include "chrome/browser/extensions/extensions_service.h" | 11 #include "chrome/browser/extensions/extensions_service.h" |
12 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
13 #include "chrome/browser/views/bookmark_menu_controller_views.h" | 13 #include "chrome/browser/views/bookmark_menu_controller_views.h" |
| 14 #include "chrome/browser/views/detachable_toolbar_view.h" |
14 #include "chrome/common/notification_registrar.h" | 15 #include "chrome/common/notification_registrar.h" |
15 #include "views/controls/button/menu_button.h" | 16 #include "views/controls/button/menu_button.h" |
16 #include "views/controls/label.h" | 17 #include "views/controls/label.h" |
17 #include "views/controls/menu/view_menu_delegate.h" | 18 #include "views/controls/menu/view_menu_delegate.h" |
18 #include "views/view.h" | 19 #include "views/view.h" |
19 #include "third_party/skia/include/core/SkRect.h" | 20 #include "third_party/skia/include/core/SkRect.h" |
20 | 21 |
21 class Browser; | 22 class Browser; |
22 class PageNavigator; | 23 class PageNavigator; |
23 class PrefService; | 24 class PrefService; |
24 | 25 |
25 namespace views { | 26 namespace views { |
26 class MenuItemView; | 27 class MenuItemView; |
27 } | 28 } |
28 | 29 |
29 // BookmarkBarView renders the BookmarkModel. Each starred entry on the | 30 // BookmarkBarView renders the BookmarkModel. Each starred entry on the |
30 // BookmarkBar is rendered as a MenuButton. An additional MenuButton aligned to | 31 // BookmarkBar is rendered as a MenuButton. An additional MenuButton aligned to |
31 // the right allows the user to quickly see recently starred entries. | 32 // the right allows the user to quickly see recently starred entries. |
32 // | 33 // |
33 // BookmarkBarView shows the bookmarks from a specific Profile. BookmarkBarView | 34 // BookmarkBarView shows the bookmarks from a specific Profile. BookmarkBarView |
34 // waits until the HistoryService for the profile has been loaded before | 35 // waits until the HistoryService for the profile has been loaded before |
35 // creating the BookmarkModel. | 36 // creating the BookmarkModel. |
36 class BookmarkBarView : public views::View, | 37 class BookmarkBarView : public DetachableToolbarView, |
37 #ifdef CHROME_PERSONALIZATION | 38 #ifdef CHROME_PERSONALIZATION |
38 public ProfileSyncServiceObserver, | 39 public ProfileSyncServiceObserver, |
39 #endif | 40 #endif |
40 public BookmarkModelObserver, | 41 public BookmarkModelObserver, |
41 public views::ViewMenuDelegate, | 42 public views::ViewMenuDelegate, |
42 public views::ButtonListener, | 43 public views::ButtonListener, |
43 public NotificationObserver, | 44 public NotificationObserver, |
44 public views::ContextMenuController, | 45 public views::ContextMenuController, |
45 public views::DragController, | 46 public views::DragController, |
46 public AnimationDelegate, | 47 public AnimationDelegate, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Returns the current profile. | 82 // Returns the current profile. |
82 Profile* GetProfile() { return profile_; } | 83 Profile* GetProfile() { return profile_; } |
83 | 84 |
84 // Returns the current browser. | 85 // Returns the current browser. |
85 Browser* browser() const { return browser_; } | 86 Browser* browser() const { return browser_; } |
86 | 87 |
87 // Sets the PageNavigator that is used when the user selects an entry on | 88 // Sets the PageNavigator that is used when the user selects an entry on |
88 // the bookmark bar. | 89 // the bookmark bar. |
89 void SetPageNavigator(PageNavigator* navigator); | 90 void SetPageNavigator(PageNavigator* navigator); |
90 | 91 |
| 92 // DetachableToolbarView methods: |
| 93 virtual bool IsDetached() const; |
| 94 virtual bool IsOnTop() const; |
| 95 virtual double GetAnimationValue() const { |
| 96 return size_animation_->GetCurrentValue(); |
| 97 } |
| 98 |
91 // View methods: | 99 // View methods: |
92 virtual gfx::Size GetPreferredSize(); | 100 virtual gfx::Size GetPreferredSize(); |
93 virtual gfx::Size GetMinimumSize(); | 101 virtual gfx::Size GetMinimumSize(); |
94 virtual void Layout(); | 102 virtual void Layout(); |
95 virtual void DidChangeBounds(const gfx::Rect& previous, | 103 virtual void DidChangeBounds(const gfx::Rect& previous, |
96 const gfx::Rect& current); | 104 const gfx::Rect& current); |
97 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); | 105 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); |
98 virtual void PaintChildren(gfx::Canvas* canvas); | 106 virtual void PaintChildren(gfx::Canvas* canvas); |
99 virtual bool GetDropFormats( | 107 virtual bool GetDropFormats( |
100 int* formats, | 108 int* formats, |
101 std::set<OSExchangeData::CustomFormat>* custom_formats); | 109 std::set<OSExchangeData::CustomFormat>* custom_formats); |
102 virtual bool AreDropTypesRequired(); | 110 virtual bool AreDropTypesRequired(); |
103 virtual bool CanDrop(const OSExchangeData& data); | 111 virtual bool CanDrop(const OSExchangeData& data); |
104 virtual void OnDragEntered(const views::DropTargetEvent& event); | 112 virtual void OnDragEntered(const views::DropTargetEvent& event); |
105 virtual int OnDragUpdated(const views::DropTargetEvent& event); | 113 virtual int OnDragUpdated(const views::DropTargetEvent& event); |
106 virtual void OnDragExited(); | 114 virtual void OnDragExited(); |
107 virtual int OnPerformDrop(const views::DropTargetEvent& event); | 115 virtual int OnPerformDrop(const views::DropTargetEvent& event); |
108 virtual bool GetAccessibleName(std::wstring* name); | 116 virtual bool GetAccessibleName(std::wstring* name); |
109 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | 117 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
110 virtual void SetAccessibleName(const std::wstring& name); | 118 virtual void SetAccessibleName(const std::wstring& name); |
111 double GetSizeAnimationValue() const { | |
112 return size_animation_->GetCurrentValue(); | |
113 } | |
114 | 119 |
115 #ifdef CHROME_PERSONALIZATION | 120 #ifdef CHROME_PERSONALIZATION |
116 // ProfileSyncServiceObserver method. | 121 // ProfileSyncServiceObserver method. |
117 virtual void OnStateChanged(); | 122 virtual void OnStateChanged(); |
118 #endif | 123 #endif |
119 | 124 |
120 // Called when fullscreen mode toggles on or off; this affects our layout. | 125 // Called when fullscreen mode toggles on or off; this affects our layout. |
121 void OnFullscreenToggled(bool fullscreen); | 126 void OnFullscreenToggled(bool fullscreen); |
122 | 127 |
123 // Sets the model change listener to listener. | 128 // Sets the model change listener to listener. |
(...skipping 12 matching lines...) Expand all Loading... |
136 ModelChangedListener* GetModelChangedListener() { | 141 ModelChangedListener* GetModelChangedListener() { |
137 return model_changed_listener_; | 142 return model_changed_listener_; |
138 } | 143 } |
139 | 144 |
140 // Returns the page navigator. | 145 // Returns the page navigator. |
141 PageNavigator* GetPageNavigator() { return page_navigator_; } | 146 PageNavigator* GetPageNavigator() { return page_navigator_; } |
142 | 147 |
143 // Returns the model. | 148 // Returns the model. |
144 BookmarkModel* GetModel() { return model_; } | 149 BookmarkModel* GetModel() { return model_; } |
145 | 150 |
146 // Returns true if the bookmark bar is drawn detached from the toolbar. This | |
147 // can only be true when OnNewTabPage() is true (see below). | |
148 bool IsDetachedStyle(); | |
149 | |
150 // Returns true if the bookmarks bar preference is set to 'always show'. | 151 // Returns true if the bookmarks bar preference is set to 'always show'. |
151 bool IsAlwaysShown(); | 152 bool IsAlwaysShown() const; |
152 | 153 |
153 // True if we're on a page where the bookmarks bar is always visible. | 154 // True if we're on a page where the bookmarks bar is always visible. |
154 bool OnNewTabPage(); | 155 bool OnNewTabPage() const; |
155 | 156 |
156 // How much we want the bookmark bar to overlap the toolbar. If |return_max| | 157 // How much we want the bookmark bar to overlap the toolbar. If |return_max| |
157 // is true, we return the maximum overlap rather than the current overlap. | 158 // is true, we return the maximum overlap rather than the current overlap. |
158 int GetToolbarOverlap(bool return_max); | 159 int GetToolbarOverlap(bool return_max); |
159 | 160 |
160 // Whether or not we are animating. | 161 // Whether or not we are animating. |
161 bool IsAnimating() { return size_animation_->IsAnimating(); } | 162 bool IsAnimating() { return size_animation_->IsAnimating(); } |
162 | 163 |
163 // SlideAnimationDelegate implementation. | 164 // SlideAnimationDelegate implementation. |
164 void AnimationProgressed(const Animation* animation); | 165 void AnimationProgressed(const Animation* animation); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // Background for extension toolstrips. | 478 // Background for extension toolstrips. |
478 SkBitmap toolstrip_background_; | 479 SkBitmap toolstrip_background_; |
479 | 480 |
480 // Storage of strings needed for accessibility. | 481 // Storage of strings needed for accessibility. |
481 std::wstring accessible_name_; | 482 std::wstring accessible_name_; |
482 | 483 |
483 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); | 484 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); |
484 }; | 485 }; |
485 | 486 |
486 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_ | 487 #endif // CHROME_BROWSER_VIEWS_BOOKMARK_BAR_VIEW_H_ |
OLD | NEW |