| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 public ProfileSyncServiceObserver, | 46 public ProfileSyncServiceObserver, |
| 47 public BookmarkModelObserver, | 47 public BookmarkModelObserver, |
| 48 public views::ViewMenuDelegate, | 48 public views::ViewMenuDelegate, |
| 49 public views::ButtonListener, | 49 public views::ButtonListener, |
| 50 public NotificationObserver, | 50 public NotificationObserver, |
| 51 public views::ContextMenuController, | 51 public views::ContextMenuController, |
| 52 public views::DragController, | 52 public views::DragController, |
| 53 public ui::AnimationDelegate, | 53 public ui::AnimationDelegate, |
| 54 public BookmarkMenuController::Observer, | 54 public BookmarkMenuController::Observer, |
| 55 public BookmarkBarInstructionsView::Delegate { | 55 public BookmarkBarInstructionsView::Delegate { |
| 56 friend class ShowFolderMenuTask; | |
| 57 | |
| 58 public: | 56 public: |
| 59 // Constants used in Browser View, as well as here. | 57 // Constants used in Browser View, as well as here. |
| 60 // How inset the bookmarks bar is when displayed on the new tab page. | 58 // How inset the bookmarks bar is when displayed on the new tab page. |
| 61 static const int kNewtabHorizontalPadding; | 59 static const int kNewtabHorizontalPadding; |
| 62 static const int kNewtabVerticalPadding; | 60 static const int kNewtabVerticalPadding; |
| 63 | 61 |
| 64 // Maximum size of buttons on the bookmark bar. | 62 // Maximum size of buttons on the bookmark bar. |
| 65 static const int kMaxButtonWidth; | 63 static const int kMaxButtonWidth; |
| 66 | 64 |
| 67 // Interface implemented by controllers/views that need to be notified any | |
| 68 // time the model changes, typically to cancel an operation that is showing | |
| 69 // data from the model such as a menu. This isn't intended as a general | |
| 70 // way to be notified of changes, rather for cases where a controller/view is | |
| 71 // showing data from the model in a modal like setting and needs to cleanly | |
| 72 // exit the modal loop if the model changes out from under it. | |
| 73 // | |
| 74 // A controller/view that needs this notification should install itself as the | |
| 75 // ModelChangeListener via the SetModelChangedListener method when shown and | |
| 76 // reset the ModelChangeListener of the BookmarkBarView when it closes by way | |
| 77 // of either the SetModelChangedListener method or the | |
| 78 // ClearModelChangedListenerIfEquals method. | |
| 79 class ModelChangedListener { | |
| 80 public: | |
| 81 virtual ~ModelChangedListener() {} | |
| 82 | |
| 83 // Invoked when the model changes. Should cancel the edit and close any | |
| 84 // dialogs. | |
| 85 virtual void ModelChanged() = 0; | |
| 86 }; | |
| 87 | |
| 88 static const int kNewtabBarHeight; | 65 static const int kNewtabBarHeight; |
| 89 | 66 |
| 90 BookmarkBarView(Profile* profile, Browser* browser); | 67 BookmarkBarView(Profile* profile, Browser* browser); |
| 91 virtual ~BookmarkBarView(); | 68 virtual ~BookmarkBarView(); |
| 92 | 69 |
| 93 // Resets the profile. This removes any buttons for the current profile and | 70 // Resets the profile. This removes any buttons for the current profile and |
| 94 // recreates the models. | 71 // recreates the models. |
| 95 void SetProfile(Profile* profile); | 72 void SetProfile(Profile* profile); |
| 96 | 73 |
| 97 // Returns the current profile. | 74 // Returns the current profile. |
| 98 Profile* GetProfile() { return profile_; } | 75 Profile* GetProfile() { return profile_; } |
| 99 | 76 |
| 100 // Returns the current browser. | 77 // Returns the current browser. |
| 101 Browser* browser() const { return browser_; } | 78 Browser* browser() const { return browser_; } |
| 102 | 79 |
| 103 // Sets the PageNavigator that is used when the user selects an entry on | 80 // Sets the PageNavigator that is used when the user selects an entry on |
| 104 // the bookmark bar. | 81 // the bookmark bar. |
| 105 void SetPageNavigator(PageNavigator* navigator); | 82 void SetPageNavigator(PageNavigator* navigator); |
| 106 | 83 |
| 84 // Returns the page navigator. |
| 85 PageNavigator* GetPageNavigator() { return page_navigator_; } |
| 86 |
| 107 // Sets whether the containing browser is showing an infobar. This affects | 87 // Sets whether the containing browser is showing an infobar. This affects |
| 108 // layout during animation. | 88 // layout during animation. |
| 109 void set_infobar_visible(bool infobar_visible) { | 89 void set_infobar_visible(bool infobar_visible) { |
| 110 infobar_visible_ = infobar_visible; | 90 infobar_visible_ = infobar_visible; |
| 111 } | 91 } |
| 112 | 92 |
| 113 virtual bool IsOnTop() const; | 93 // Returns the model. |
| 114 | 94 BookmarkModel* GetModel() { return model_; } |
| 115 // DetachableToolbarView methods: | |
| 116 virtual bool IsDetached() const OVERRIDE; | |
| 117 virtual double GetAnimationValue() const OVERRIDE; | |
| 118 virtual int GetToolbarOverlap() const OVERRIDE; | |
| 119 | |
| 120 // View methods: | |
| 121 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 122 virtual gfx::Size GetMinimumSize() OVERRIDE; | |
| 123 virtual void Layout() OVERRIDE; | |
| 124 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) | |
| 125 OVERRIDE; | |
| 126 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; | |
| 127 virtual bool GetDropFormats( | |
| 128 int* formats, | |
| 129 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; | |
| 130 virtual bool AreDropTypesRequired() OVERRIDE; | |
| 131 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; | |
| 132 virtual void OnDragEntered(const views::DropTargetEvent& event) OVERRIDE; | |
| 133 virtual int OnDragUpdated(const views::DropTargetEvent& event) OVERRIDE; | |
| 134 virtual void OnDragExited() OVERRIDE; | |
| 135 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE; | |
| 136 virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) | |
| 137 OVERRIDE; | |
| 138 | |
| 139 // AccessiblePaneView methods: | |
| 140 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | |
| 141 | |
| 142 // ProfileSyncServiceObserver method. | |
| 143 virtual void OnStateChanged(); | |
| 144 | 95 |
| 145 // Called when fullscreen mode toggles on or off; this affects our layout. | 96 // Called when fullscreen mode toggles on or off; this affects our layout. |
| 146 void OnFullscreenToggled(bool fullscreen); | 97 void OnFullscreenToggled(bool fullscreen); |
| 147 | 98 |
| 148 // Sets the model change listener to listener. | |
| 149 void SetModelChangedListener(ModelChangedListener* listener) { | |
| 150 model_changed_listener_ = listener; | |
| 151 } | |
| 152 | |
| 153 // If the ModelChangedListener is listener, ModelChangeListener is set to | |
| 154 // NULL. | |
| 155 void ClearModelChangedListenerIfEquals(ModelChangedListener* listener) { | |
| 156 if (model_changed_listener_ == listener) | |
| 157 model_changed_listener_ = NULL; | |
| 158 } | |
| 159 | |
| 160 // Returns the model change listener. | |
| 161 ModelChangedListener* GetModelChangedListener() { | |
| 162 return model_changed_listener_; | |
| 163 } | |
| 164 | |
| 165 // Returns the page navigator. | |
| 166 PageNavigator* GetPageNavigator() { return page_navigator_; } | |
| 167 | |
| 168 // Returns the model. | |
| 169 BookmarkModel* GetModel() { return model_; } | |
| 170 | |
| 171 // Returns true if the bookmarks bar preference is set to 'always show'. | 99 // Returns true if the bookmarks bar preference is set to 'always show'. |
| 172 bool IsAlwaysShown() const; | 100 bool IsAlwaysShown() const; |
| 173 | 101 |
| 174 // True if we're on a page where the bookmarks bar is always visible. | 102 // True if we're on a page where the bookmarks bar is always visible. |
| 175 bool OnNewTabPage() const; | 103 bool OnNewTabPage() const; |
| 176 | 104 |
| 177 // How much we want the bookmark bar to overlap the toolbar. If |return_max| | 105 // How much we want the bookmark bar to overlap the toolbar. If |return_max| |
| 178 // is true, we return the maximum overlap rather than the current overlap. | 106 // is true, we return the maximum overlap rather than the current overlap. |
| 179 int GetToolbarOverlap(bool return_max) const; | 107 int GetToolbarOverlap(bool return_max) const; |
| 180 | 108 |
| 181 // Whether or not we are animating. | 109 // Whether or not we are animating. |
| 182 bool is_animating(); | 110 bool is_animating(); |
| 183 | 111 |
| 184 // SlideAnimationDelegate implementation. | 112 // Returns the number of buttons corresponding to starred urls/folders. This |
| 185 virtual void AnimationProgressed(const ui::Animation* animation); | 113 // is equivalent to the number of children the bookmark bar node from the |
| 186 virtual void AnimationEnded(const ui::Animation* animation); | 114 // bookmark bar model has. |
| 187 | 115 int GetBookmarkButtonCount(); |
| 188 // BookmarkMenuController::Observer | |
| 189 virtual void BookmarkMenuDeleted(BookmarkMenuController* controller); | |
| 190 | 116 |
| 191 // Returns the button at the specified index. | 117 // Returns the button at the specified index. |
| 192 views::TextButton* GetBookmarkButton(int index); | 118 views::TextButton* GetBookmarkButton(int index); |
| 193 | 119 |
| 194 // Returns the button responsible for showing bookmarks in the other bookmark | |
| 195 // folder. | |
| 196 views::MenuButton* other_bookmarked_button() const { | |
| 197 return other_bookmarked_button_; | |
| 198 } | |
| 199 | |
| 200 // Returns the active MenuItemView, or NULL if a menu isn't showing. | |
| 201 views::MenuItemView* GetMenu(); | |
| 202 | |
| 203 // Returns the drop MenuItemView, or NULL if a menu isn't showing. | |
| 204 views::MenuItemView* GetDropMenu(); | |
| 205 | |
| 206 // Returns the context menu, or null if one isn't showing. | |
| 207 views::MenuItemView* GetContextMenu(); | |
| 208 | |
| 209 // Returns the button used when not all the items on the bookmark bar fit. | |
| 210 views::MenuButton* overflow_button() const { return overflow_button_; } | |
| 211 | |
| 212 // If |loc| is over a bookmark button the node is returned corresponding | 120 // If |loc| is over a bookmark button the node is returned corresponding |
| 213 // to the button and |start_index| is set to 0. If a overflow button is | 121 // to the button and |start_index| is set to 0. If a overflow button is |
| 214 // showing and |loc| is over the overflow button, the bookmark bar node is | 122 // showing and |loc| is over the overflow button, the bookmark bar node is |
| 215 // returned and |start_index| is set to the index of the first node | 123 // returned and |start_index| is set to the index of the first node |
| 216 // contained in the overflow menu. | 124 // contained in the overflow menu. |
| 217 const BookmarkNode* GetNodeForButtonAt(const gfx::Point& loc, | 125 const BookmarkNode* GetNodeForButtonAt(const gfx::Point& loc, |
| 218 int* start_index); | 126 int* start_index); |
| 219 | 127 |
| 220 // Returns the MenuButton for node. | 128 // Returns the MenuButton for node. |
| 221 views::MenuButton* GetMenuButtonForNode(const BookmarkNode* node); | 129 views::MenuButton* GetMenuButtonForNode(const BookmarkNode* node); |
| 222 | 130 |
| 223 // Returns the position to anchor the menu for |button| at, the index of the | 131 // Returns the position to anchor the menu for |button| at, the index of the |
| 224 // first child of the node to build the menu from. | 132 // first child of the node to build the menu from. |
| 225 void GetAnchorPositionAndStartIndexForButton( | 133 void GetAnchorPositionAndStartIndexForButton( |
| 226 views::MenuButton* button, | 134 views::MenuButton* button, |
| 227 views::MenuItemView::AnchorPosition* anchor, | 135 views::MenuItemView::AnchorPosition* anchor, |
| 228 int* start_index); | 136 int* start_index); |
| 229 | 137 |
| 230 // BookmarkBarInstructionsView::Delegate. | 138 // Returns the button responsible for showing bookmarks in the other bookmark |
| 231 virtual void ShowImportDialog(); | 139 // folder. |
| 140 views::MenuButton* other_bookmarked_button() const { |
| 141 return other_bookmarked_button_; |
| 142 } |
| 143 |
| 144 // Returns the button used when not all the items on the bookmark bar fit. |
| 145 views::MenuButton* overflow_button() const { return overflow_button_; } |
| 146 |
| 147 // Returns the active MenuItemView, or NULL if a menu isn't showing. |
| 148 views::MenuItemView* GetMenu(); |
| 149 |
| 150 // Returns the context menu, or null if one isn't showing. |
| 151 views::MenuItemView* GetContextMenu(); |
| 152 |
| 153 // Returns the drop MenuItemView, or NULL if a menu isn't showing. |
| 154 views::MenuItemView* GetDropMenu(); |
| 232 | 155 |
| 233 // If a button is currently throbbing, it is stopped. If immediate is true | 156 // If a button is currently throbbing, it is stopped. If immediate is true |
| 234 // the throb stops immediately, otherwise it stops after a couple more | 157 // the throb stops immediately, otherwise it stops after a couple more |
| 235 // throbs. | 158 // throbs. |
| 236 void StopThrobbing(bool immediate); | 159 void StopThrobbing(bool immediate); |
| 237 | 160 |
| 238 // Returns the number of buttons corresponding to starred urls/folders. This | |
| 239 // is equivalent to the number of children the bookmark bar node from the | |
| 240 // bookmark bar model has. | |
| 241 int GetBookmarkButtonCount(); | |
| 242 | |
| 243 // Returns the tooltip text for the specified url and title. The returned | 161 // Returns the tooltip text for the specified url and title. The returned |
| 244 // text is clipped to fit within the bounds of the monitor. | 162 // text is clipped to fit within the bounds of the monitor. |
| 245 // | 163 // |
| 246 // Note that we adjust the direction of both the URL and the title based on | 164 // Note that we adjust the direction of both the URL and the title based on |
| 247 // the locale so that pure LTR strings are displayed properly in RTL locales. | 165 // the locale so that pure LTR strings are displayed properly in RTL locales. |
| 248 static std::wstring CreateToolTipForURLAndTitle( | 166 static std::wstring CreateToolTipForURLAndTitle( |
| 249 const gfx::Point& screen_loc, | 167 const gfx::Point& screen_loc, |
| 250 const GURL& url, | 168 const GURL& url, |
| 251 const std::wstring& title, | 169 const std::wstring& title, |
| 252 Profile* profile); | 170 Profile* profile); |
| 253 | 171 |
| 172 // DetachableToolbarView methods: |
| 173 virtual bool IsDetached() const OVERRIDE; |
| 174 virtual double GetAnimationValue() const OVERRIDE; |
| 175 virtual int GetToolbarOverlap() const OVERRIDE; |
| 176 |
| 177 // View methods: |
| 178 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 179 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 180 virtual void Layout() OVERRIDE; |
| 181 virtual void ViewHierarchyChanged(bool |
| 182 is_add, |
| 183 View* parent, |
| 184 View* child) OVERRIDE; |
| 185 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; |
| 186 virtual bool GetDropFormats( |
| 187 int* formats, |
| 188 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; |
| 189 virtual bool AreDropTypesRequired() OVERRIDE; |
| 190 virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE; |
| 191 virtual void OnDragEntered(const views::DropTargetEvent& event) OVERRIDE; |
| 192 virtual int OnDragUpdated(const views::DropTargetEvent& event) OVERRIDE; |
| 193 virtual void OnDragExited() OVERRIDE; |
| 194 virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE; |
| 195 virtual void ShowContextMenu(const gfx::Point& p, |
| 196 bool is_mouse_gesture) OVERRIDE; |
| 197 virtual void OnThemeChanged() OVERRIDE; |
| 198 |
| 199 // AccessiblePaneView methods: |
| 200 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 201 |
| 202 // ProfileSyncServiceObserver method. |
| 203 virtual void OnStateChanged() OVERRIDE; |
| 204 |
| 205 // SlideAnimationDelegate implementation. |
| 206 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 207 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
| 208 |
| 209 // BookmarkMenuController::Observer |
| 210 virtual void BookmarkMenuDeleted( |
| 211 BookmarkMenuController* controller) OVERRIDE; |
| 212 |
| 213 // BookmarkBarInstructionsView::Delegate. |
| 214 virtual void ShowImportDialog() OVERRIDE; |
| 215 |
| 216 // BookmarkModelObserver: |
| 217 virtual void Loaded(BookmarkModel* model) OVERRIDE; |
| 218 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; |
| 219 virtual void BookmarkNodeMoved(BookmarkModel* model, |
| 220 const BookmarkNode* old_parent, |
| 221 int old_index, |
| 222 const BookmarkNode* new_parent, |
| 223 int new_index) OVERRIDE; |
| 224 virtual void BookmarkNodeAdded(BookmarkModel* model, |
| 225 const BookmarkNode* parent, |
| 226 int index) OVERRIDE; |
| 227 virtual void BookmarkNodeRemoved(BookmarkModel* model, |
| 228 const BookmarkNode* parent, |
| 229 int old_index, |
| 230 const BookmarkNode* node) OVERRIDE; |
| 231 virtual void BookmarkNodeChanged(BookmarkModel* model, |
| 232 const BookmarkNode* node) OVERRIDE; |
| 233 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, |
| 234 const BookmarkNode* node) OVERRIDE; |
| 235 virtual void BookmarkNodeFaviconLoaded(BookmarkModel* model, |
| 236 const BookmarkNode* node) OVERRIDE; |
| 237 |
| 238 // DragController: |
| 239 virtual void WriteDragDataForView(views::View* sender, |
| 240 const gfx::Point& press_pt, |
| 241 ui::OSExchangeData* data) OVERRIDE; |
| 242 virtual int GetDragOperationsForView(views::View* sender, |
| 243 const gfx::Point& p) OVERRIDE; |
| 244 virtual bool CanStartDragForView(views::View* sender, |
| 245 const gfx::Point& press_pt, |
| 246 const gfx::Point& p) OVERRIDE; |
| 247 |
| 248 // ViewMenuDelegate: |
| 249 virtual void RunMenu(views::View* view, const gfx::Point& pt) OVERRIDE; |
| 250 |
| 251 // ButtonListener: |
| 252 virtual void ButtonPressed(views::Button* sender, |
| 253 const views::Event& event) OVERRIDE; |
| 254 |
| 255 // ContextMenuController |
| 256 virtual void ShowContextMenuForView(views::View* source, |
| 257 const gfx::Point& p, |
| 258 bool is_mouse_gesture) OVERRIDE; |
| 259 |
| 260 // NotificationService: |
| 261 virtual void Observe(NotificationType type, |
| 262 const NotificationSource& source, |
| 263 const NotificationDetails& details) OVERRIDE; |
| 264 |
| 254 // If true we're running tests. This short circuits a couple of animations. | 265 // If true we're running tests. This short circuits a couple of animations. |
| 255 static bool testing_; | 266 static bool testing_; |
| 256 | 267 |
| 257 private: | 268 private: |
| 258 class ButtonSeparatorView; | 269 class ButtonSeparatorView; |
| 259 struct DropInfo; | 270 struct DropInfo; |
| 260 | 271 |
| 261 // Task that invokes ShowDropFolderForNode when run. ShowFolderDropMenuTask | 272 // Task that invokes ShowDropFolderForNode when run. ShowFolderDropMenuTask |
| 262 // deletes itself once run. | 273 // deletes itself once run. |
| 263 class ShowFolderDropMenuTask : public Task { | 274 class ShowFolderDropMenuTask : public Task { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 290 // Creates recent bookmark button and when visible button as well as | 301 // Creates recent bookmark button and when visible button as well as |
| 291 // calculating the preferred height. | 302 // calculating the preferred height. |
| 292 void Init(); | 303 void Init(); |
| 293 | 304 |
| 294 // Creates the button showing the other bookmarked items. | 305 // Creates the button showing the other bookmarked items. |
| 295 views::MenuButton* CreateOtherBookmarkedButton(); | 306 views::MenuButton* CreateOtherBookmarkedButton(); |
| 296 | 307 |
| 297 // Creates the button used when not all bookmark buttons fit. | 308 // Creates the button used when not all bookmark buttons fit. |
| 298 views::MenuButton* CreateOverflowButton(); | 309 views::MenuButton* CreateOverflowButton(); |
| 299 | 310 |
| 300 // Invoked when the bookmark bar model has finished loading. Creates a button | 311 // Creates the sync error button and adds it as a child view. |
| 301 // for each of the children of the root node from the model. | 312 views::TextButton* CreateSyncErrorButton(); |
| 302 virtual void Loaded(BookmarkModel* model); | |
| 303 | |
| 304 // Invoked when the model is being deleted. | |
| 305 virtual void BookmarkModelBeingDeleted(BookmarkModel* model); | |
| 306 | |
| 307 // Invokes added followed by removed. | |
| 308 virtual void BookmarkNodeMoved(BookmarkModel* model, | |
| 309 const BookmarkNode* old_parent, | |
| 310 int old_index, | |
| 311 const BookmarkNode* new_parent, | |
| 312 int new_index); | |
| 313 | |
| 314 // Notifies ModelChangeListener of change. | |
| 315 // If the node was added to the root node, a button is created and added to | |
| 316 // this bookmark bar view. | |
| 317 virtual void BookmarkNodeAdded(BookmarkModel* model, | |
| 318 const BookmarkNode* parent, | |
| 319 int index); | |
| 320 | |
| 321 // Implementation for BookmarkNodeAddedImpl. | |
| 322 void BookmarkNodeAddedImpl(BookmarkModel* model, | |
| 323 const BookmarkNode* parent, | |
| 324 int index); | |
| 325 | |
| 326 // Notifies ModelChangeListener of change. | |
| 327 // If the node was a child of the root node, the button corresponding to it | |
| 328 // is removed. | |
| 329 virtual void BookmarkNodeRemoved(BookmarkModel* model, | |
| 330 const BookmarkNode* parent, | |
| 331 int old_index, | |
| 332 const BookmarkNode* node); | |
| 333 | |
| 334 // Implementation for BookmarkNodeRemoved. | |
| 335 void BookmarkNodeRemovedImpl(BookmarkModel* model, | |
| 336 const BookmarkNode* parent, | |
| 337 int index); | |
| 338 | |
| 339 // Notifies ModelChangedListener and invokes BookmarkNodeChangedImpl. | |
| 340 virtual void BookmarkNodeChanged(BookmarkModel* model, | |
| 341 const BookmarkNode* node); | |
| 342 | |
| 343 // If the node is a child of the root node, the button is updated | |
| 344 // appropriately. | |
| 345 void BookmarkNodeChangedImpl(BookmarkModel* model, const BookmarkNode* node); | |
| 346 | |
| 347 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, | |
| 348 const BookmarkNode* node); | |
| 349 | |
| 350 // Invoked when the favicon is available. If the node is a child of the | |
| 351 // root node, the appropriate button is updated. If a menu is showing, the | |
| 352 // call is forwarded to the menu to allow for it to update the icon. | |
| 353 virtual void BookmarkNodeFaviconLoaded(BookmarkModel* model, | |
| 354 const BookmarkNode* node); | |
| 355 | |
| 356 // DragController method. Determines the node representing sender and invokes | |
| 357 // WriteDragData to write the actual data. | |
| 358 virtual void WriteDragDataForView(views::View* sender, | |
| 359 const gfx::Point& press_pt, | |
| 360 ui::OSExchangeData* data) OVERRIDE; | |
| 361 | |
| 362 virtual int GetDragOperationsForView(views::View* sender, | |
| 363 const gfx::Point& p) OVERRIDE; | |
| 364 | |
| 365 virtual bool CanStartDragForView(views::View* sender, | |
| 366 const gfx::Point& press_pt, | |
| 367 const gfx::Point& p) OVERRIDE; | |
| 368 | |
| 369 // Writes a BookmarkNodeData for node to data. | |
| 370 void WriteBookmarkDragData(const BookmarkNode* node, | |
| 371 ui::OSExchangeData* data); | |
| 372 | |
| 373 // ViewMenuDelegate method. Ends up creating a BookmarkMenuController to | |
| 374 // show the menu. | |
| 375 virtual void RunMenu(views::View* view, const gfx::Point& pt); | |
| 376 | |
| 377 // Invoked when a star entry corresponding to a URL on the bookmark bar is | |
| 378 // pressed. Forwards to the PageNavigator to open the URL. | |
| 379 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 380 | |
| 381 // Invoked for this View, one of the buttons or the 'other' button. Shows the | |
| 382 // appropriate context menu. | |
| 383 virtual void ShowContextMenuForView(views::View* source, | |
| 384 const gfx::Point& p, | |
| 385 bool is_mouse_gesture); | |
| 386 | 313 |
| 387 // Creates the button for rendering the specified bookmark node. | 314 // Creates the button for rendering the specified bookmark node. |
| 388 views::View* CreateBookmarkButton(const BookmarkNode* node); | 315 views::View* CreateBookmarkButton(const BookmarkNode* node); |
| 389 | 316 |
| 390 // COnfigures the button from the specified node. This sets the text, | 317 // COnfigures the button from the specified node. This sets the text, |
| 391 // and icon. | 318 // and icon. |
| 392 void ConfigureButton(const BookmarkNode* node, views::TextButton* button); | 319 void ConfigureButton(const BookmarkNode* node, views::TextButton* button); |
| 393 | 320 |
| 394 // Used when showing the menu allowing the user to choose when the bar is | 321 // Implementation for BookmarkNodeAddedImpl. |
| 395 // visible. Return value corresponds to the users preference for when the | 322 void BookmarkNodeAddedImpl(BookmarkModel* model, |
| 396 // bar is visible. | 323 const BookmarkNode* parent, |
| 397 virtual bool IsItemChecked(int id) const; | 324 int index); |
| 398 | 325 |
| 399 // Used when showing the menu allowing the user to choose when the bar is | 326 // Implementation for BookmarkNodeRemoved. |
| 400 // visible. Updates the preferences to match the users choice as appropriate. | 327 void BookmarkNodeRemovedImpl(BookmarkModel* model, |
| 401 virtual void ExecuteCommand(int id); | 328 const BookmarkNode* parent, |
| 329 int index); |
| 402 | 330 |
| 403 // NotificationService method. | 331 // If the node is a child of the root node, the button is updated |
| 404 virtual void Observe(NotificationType type, | 332 // appropriately. |
| 405 const NotificationSource& source, | 333 void BookmarkNodeChangedImpl(BookmarkModel* model, const BookmarkNode* node); |
| 406 const NotificationDetails& details); | |
| 407 | |
| 408 // Overridden from views::View. | |
| 409 virtual void OnThemeChanged(); | |
| 410 | |
| 411 // If the ModelChangedListener is non-null, ModelChanged is invoked on it. | |
| 412 void NotifyModelChanged(); | |
| 413 | 334 |
| 414 // Shows the menu used during drag and drop for the specified node. | 335 // Shows the menu used during drag and drop for the specified node. |
| 415 void ShowDropFolderForNode(const BookmarkNode* node); | 336 void ShowDropFolderForNode(const BookmarkNode* node); |
| 416 | 337 |
| 417 // Cancels the timer used to show a drop menu. | 338 // Cancels the timer used to show a drop menu. |
| 418 void StopShowFolderDropMenuTimer(); | 339 void StopShowFolderDropMenuTimer(); |
| 419 | 340 |
| 420 // Stars the timer used to show a drop menu for node. | 341 // Stars the timer used to show a drop menu for node. |
| 421 void StartShowFolderDropMenuTimer(const BookmarkNode* node); | 342 void StartShowFolderDropMenuTimer(const BookmarkNode* node); |
| 422 | 343 |
| 423 // Returns the drop operation and index for the drop based on the event | 344 // Returns the drop operation and index for the drop based on the event |
| 424 // and data. Returns ui::DragDropTypes::DRAG_NONE if not a valid location. | 345 // and data. Returns ui::DragDropTypes::DRAG_NONE if not a valid location. |
| 425 int CalculateDropOperation(const views::DropTargetEvent& event, | 346 int CalculateDropOperation(const views::DropTargetEvent& event, |
| 426 const BookmarkNodeData& data, | 347 const BookmarkNodeData& data, |
| 427 int* index, | 348 int* index, |
| 428 bool* drop_on, | 349 bool* drop_on, |
| 429 bool* is_over_overflow, | 350 bool* is_over_overflow, |
| 430 bool* is_over_other); | 351 bool* is_over_other); |
| 431 | 352 |
| 353 // Writes a BookmarkNodeData for node to data. |
| 354 void WriteBookmarkDragData(const BookmarkNode* node, |
| 355 ui::OSExchangeData* data); |
| 356 |
| 432 // Returns the index of the first hidden bookmark button. If all buttons are | 357 // Returns the index of the first hidden bookmark button. If all buttons are |
| 433 // visible, this returns GetBookmarkButtonCount(). | 358 // visible, this returns GetBookmarkButtonCount(). |
| 434 int GetFirstHiddenNodeIndex(); | 359 int GetFirstHiddenNodeIndex(); |
| 435 | 360 |
| 436 // This determines which view should throb and starts it | 361 // This determines which view should throb and starts it |
| 437 // throbbing (e.g when the bookmark bubble is showing). | 362 // throbbing (e.g when the bookmark bubble is showing). |
| 438 // If |overflow_only| is true, start throbbing only if |node| is hidden in | 363 // If |overflow_only| is true, start throbbing only if |node| is hidden in |
| 439 // the overflow menu. | 364 // the overflow menu. |
| 440 void StartThrobbing(const BookmarkNode* node, bool overflow_only); | 365 void StartThrobbing(const BookmarkNode* node, bool overflow_only); |
| 441 | 366 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 452 // Updates the visibility of |other_bookmarked_button_| and | 377 // Updates the visibility of |other_bookmarked_button_| and |
| 453 // |bookmarks_separator_view_|. | 378 // |bookmarks_separator_view_|. |
| 454 void UpdateOtherBookmarksVisibility(); | 379 void UpdateOtherBookmarksVisibility(); |
| 455 | 380 |
| 456 // This method computes the bounds for the bookmark bar items. If | 381 // This method computes the bounds for the bookmark bar items. If |
| 457 // |compute_bounds_only| = TRUE, the bounds for the items are just computed, | 382 // |compute_bounds_only| = TRUE, the bounds for the items are just computed, |
| 458 // but are not set. This mode is used by GetPreferredSize() to obtain the | 383 // but are not set. This mode is used by GetPreferredSize() to obtain the |
| 459 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set. | 384 // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set. |
| 460 gfx::Size LayoutItems(bool compute_bounds_only); | 385 gfx::Size LayoutItems(bool compute_bounds_only); |
| 461 | 386 |
| 462 // Creates the sync error button and adds it as a child view. | |
| 463 views::TextButton* CreateSyncErrorButton(); | |
| 464 | |
| 465 NotificationRegistrar registrar_; | 387 NotificationRegistrar registrar_; |
| 466 | 388 |
| 467 Profile* profile_; | 389 Profile* profile_; |
| 468 | 390 |
| 469 // Used for opening urls. | 391 // Used for opening urls. |
| 470 PageNavigator* page_navigator_; | 392 PageNavigator* page_navigator_; |
| 471 | 393 |
| 472 // Model providing details as to the starred entries/folders that should be | 394 // Model providing details as to the starred entries/folders that should be |
| 473 // shown. This is owned by the Profile. | 395 // shown. This is owned by the Profile. |
| 474 BookmarkModel* model_; | 396 BookmarkModel* model_; |
| 475 | 397 |
| 476 // Used to manage showing a Menu, either for the most recently bookmarked | 398 // Used to manage showing a Menu, either for the most recently bookmarked |
| 477 // entries, or for the starred folder. | 399 // entries, or for the starred folder. |
| 478 BookmarkMenuController* bookmark_menu_; | 400 BookmarkMenuController* bookmark_menu_; |
| 479 | 401 |
| 480 // Used when showing a menu for drag and drop. That is, if the user drags | 402 // Used when showing a menu for drag and drop. That is, if the user drags |
| 481 // over a folder this becomes non-null and manages the menu showing the | 403 // over a folder this becomes non-null and manages the menu showing the |
| 482 // contents of the node. | 404 // contents of the node. |
| 483 BookmarkMenuController* bookmark_drop_menu_; | 405 BookmarkMenuController* bookmark_drop_menu_; |
| 484 | 406 |
| 485 // Shows the other bookmark entries. | 407 // Shows the other bookmark entries. |
| 486 views::MenuButton* other_bookmarked_button_; | 408 views::MenuButton* other_bookmarked_button_; |
| 487 | 409 |
| 488 // ModelChangeListener. | |
| 489 ModelChangedListener* model_changed_listener_; | |
| 490 | |
| 491 // Task used to delay showing of the drop menu. | 410 // Task used to delay showing of the drop menu. |
| 492 ShowFolderDropMenuTask* show_folder_drop_menu_task_; | 411 ShowFolderDropMenuTask* show_folder_drop_menu_task_; |
| 493 | 412 |
| 494 // Used to track drops on the bookmark bar view. | 413 // Used to track drops on the bookmark bar view. |
| 495 scoped_ptr<DropInfo> drop_info_; | 414 scoped_ptr<DropInfo> drop_info_; |
| 496 | 415 |
| 497 // The sync re-login indicator which appears when the user needs to re-enter | 416 // The sync re-login indicator which appears when the user needs to re-enter |
| 498 // credentials in order to continue syncing. | 417 // credentials in order to continue syncing. |
| 499 views::TextButton* sync_error_button_; | 418 views::TextButton* sync_error_button_; |
| 500 | 419 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 524 // overflow_button_ or a button on the bar. | 443 // overflow_button_ or a button on the bar. |
| 525 views::CustomButton* throbbing_view_; | 444 views::CustomButton* throbbing_view_; |
| 526 | 445 |
| 527 // Background for extension toolstrips. | 446 // Background for extension toolstrips. |
| 528 SkBitmap toolstrip_background_; | 447 SkBitmap toolstrip_background_; |
| 529 | 448 |
| 530 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); | 449 DISALLOW_COPY_AND_ASSIGN(BookmarkBarView); |
| 531 }; | 450 }; |
| 532 | 451 |
| 533 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ | 452 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BAR_VIEW_H_ |
| OLD | NEW |