| Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view.h
|
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h
|
| index 4ec60e30c8c43d980524c252661cf3bbbb9ee075..eb6016d3f132ab1d22262ed95a9a4100a15fbf14 100644
|
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h
|
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.h
|
| @@ -53,8 +53,6 @@ class BookmarkBarView : public DetachableToolbarView,
|
| public ui::AnimationDelegate,
|
| public BookmarkMenuController::Observer,
|
| public BookmarkBarInstructionsView::Delegate {
|
| - friend class ShowFolderMenuTask;
|
| -
|
| public:
|
| // Constants used in Browser View, as well as here.
|
| // How inset the bookmarks bar is when displayed on the new tab page.
|
| @@ -64,27 +62,6 @@ class BookmarkBarView : public DetachableToolbarView,
|
| // Maximum size of buttons on the bookmark bar.
|
| static const int kMaxButtonWidth;
|
|
|
| - // Interface implemented by controllers/views that need to be notified any
|
| - // time the model changes, typically to cancel an operation that is showing
|
| - // data from the model such as a menu. This isn't intended as a general
|
| - // way to be notified of changes, rather for cases where a controller/view is
|
| - // showing data from the model in a modal like setting and needs to cleanly
|
| - // exit the modal loop if the model changes out from under it.
|
| - //
|
| - // A controller/view that needs this notification should install itself as the
|
| - // ModelChangeListener via the SetModelChangedListener method when shown and
|
| - // reset the ModelChangeListener of the BookmarkBarView when it closes by way
|
| - // of either the SetModelChangedListener method or the
|
| - // ClearModelChangedListenerIfEquals method.
|
| - class ModelChangedListener {
|
| - public:
|
| - virtual ~ModelChangedListener() {}
|
| -
|
| - // Invoked when the model changes. Should cancel the edit and close any
|
| - // dialogs.
|
| - virtual void ModelChanged() = 0;
|
| - };
|
| -
|
| static const int kNewtabBarHeight;
|
|
|
| BookmarkBarView(Profile* profile, Browser* browser);
|
| @@ -104,70 +81,21 @@ class BookmarkBarView : public DetachableToolbarView,
|
| // the bookmark bar.
|
| void SetPageNavigator(PageNavigator* navigator);
|
|
|
| + // Returns the page navigator.
|
| + PageNavigator* GetPageNavigator() { return page_navigator_; }
|
| +
|
| // Sets whether the containing browser is showing an infobar. This affects
|
| // layout during animation.
|
| void set_infobar_visible(bool infobar_visible) {
|
| infobar_visible_ = infobar_visible;
|
| }
|
|
|
| - virtual bool IsOnTop() const;
|
| -
|
| - // DetachableToolbarView methods:
|
| - virtual bool IsDetached() const OVERRIDE;
|
| - virtual double GetAnimationValue() const OVERRIDE;
|
| - virtual int GetToolbarOverlap() const OVERRIDE;
|
| -
|
| - // View methods:
|
| - virtual gfx::Size GetPreferredSize() OVERRIDE;
|
| - virtual gfx::Size GetMinimumSize() OVERRIDE;
|
| - virtual void Layout() OVERRIDE;
|
| - virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child)
|
| - OVERRIDE;
|
| - virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
|
| - virtual bool GetDropFormats(
|
| - int* formats,
|
| - std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
|
| - virtual bool AreDropTypesRequired() OVERRIDE;
|
| - virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE;
|
| - virtual void OnDragEntered(const views::DropTargetEvent& event) OVERRIDE;
|
| - virtual int OnDragUpdated(const views::DropTargetEvent& event) OVERRIDE;
|
| - virtual void OnDragExited() OVERRIDE;
|
| - virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE;
|
| - virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture)
|
| - OVERRIDE;
|
| -
|
| - // AccessiblePaneView methods:
|
| - virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
|
| -
|
| - // ProfileSyncServiceObserver method.
|
| - virtual void OnStateChanged();
|
| + // Returns the model.
|
| + BookmarkModel* GetModel() { return model_; }
|
|
|
| // Called when fullscreen mode toggles on or off; this affects our layout.
|
| void OnFullscreenToggled(bool fullscreen);
|
|
|
| - // Sets the model change listener to listener.
|
| - void SetModelChangedListener(ModelChangedListener* listener) {
|
| - model_changed_listener_ = listener;
|
| - }
|
| -
|
| - // If the ModelChangedListener is listener, ModelChangeListener is set to
|
| - // NULL.
|
| - void ClearModelChangedListenerIfEquals(ModelChangedListener* listener) {
|
| - if (model_changed_listener_ == listener)
|
| - model_changed_listener_ = NULL;
|
| - }
|
| -
|
| - // Returns the model change listener.
|
| - ModelChangedListener* GetModelChangedListener() {
|
| - return model_changed_listener_;
|
| - }
|
| -
|
| - // Returns the page navigator.
|
| - PageNavigator* GetPageNavigator() { return page_navigator_; }
|
| -
|
| - // Returns the model.
|
| - BookmarkModel* GetModel() { return model_; }
|
| -
|
| // Returns true if the bookmarks bar preference is set to 'always show'.
|
| bool IsAlwaysShown() const;
|
|
|
| @@ -181,34 +109,14 @@ class BookmarkBarView : public DetachableToolbarView,
|
| // Whether or not we are animating.
|
| bool is_animating();
|
|
|
| - // SlideAnimationDelegate implementation.
|
| - virtual void AnimationProgressed(const ui::Animation* animation);
|
| - virtual void AnimationEnded(const ui::Animation* animation);
|
| -
|
| - // BookmarkMenuController::Observer
|
| - virtual void BookmarkMenuDeleted(BookmarkMenuController* controller);
|
| + // Returns the number of buttons corresponding to starred urls/folders. This
|
| + // is equivalent to the number of children the bookmark bar node from the
|
| + // bookmark bar model has.
|
| + int GetBookmarkButtonCount();
|
|
|
| // Returns the button at the specified index.
|
| views::TextButton* GetBookmarkButton(int index);
|
|
|
| - // Returns the button responsible for showing bookmarks in the other bookmark
|
| - // folder.
|
| - views::MenuButton* other_bookmarked_button() const {
|
| - return other_bookmarked_button_;
|
| - }
|
| -
|
| - // Returns the active MenuItemView, or NULL if a menu isn't showing.
|
| - views::MenuItemView* GetMenu();
|
| -
|
| - // Returns the drop MenuItemView, or NULL if a menu isn't showing.
|
| - views::MenuItemView* GetDropMenu();
|
| -
|
| - // Returns the context menu, or null if one isn't showing.
|
| - views::MenuItemView* GetContextMenu();
|
| -
|
| - // Returns the button used when not all the items on the bookmark bar fit.
|
| - views::MenuButton* overflow_button() const { return overflow_button_; }
|
| -
|
| // If |loc| is over a bookmark button the node is returned corresponding
|
| // to the button and |start_index| is set to 0. If a overflow button is
|
| // showing and |loc| is over the overflow button, the bookmark bar node is
|
| @@ -227,19 +135,29 @@ class BookmarkBarView : public DetachableToolbarView,
|
| views::MenuItemView::AnchorPosition* anchor,
|
| int* start_index);
|
|
|
| - // BookmarkBarInstructionsView::Delegate.
|
| - virtual void ShowImportDialog();
|
| + // Returns the button responsible for showing bookmarks in the other bookmark
|
| + // folder.
|
| + views::MenuButton* other_bookmarked_button() const {
|
| + return other_bookmarked_button_;
|
| + }
|
| +
|
| + // Returns the button used when not all the items on the bookmark bar fit.
|
| + views::MenuButton* overflow_button() const { return overflow_button_; }
|
| +
|
| + // Returns the active MenuItemView, or NULL if a menu isn't showing.
|
| + views::MenuItemView* GetMenu();
|
| +
|
| + // Returns the context menu, or null if one isn't showing.
|
| + views::MenuItemView* GetContextMenu();
|
| +
|
| + // Returns the drop MenuItemView, or NULL if a menu isn't showing.
|
| + views::MenuItemView* GetDropMenu();
|
|
|
| // If a button is currently throbbing, it is stopped. If immediate is true
|
| // the throb stops immediately, otherwise it stops after a couple more
|
| // throbs.
|
| void StopThrobbing(bool immediate);
|
|
|
| - // Returns the number of buttons corresponding to starred urls/folders. This
|
| - // is equivalent to the number of children the bookmark bar node from the
|
| - // bookmark bar model has.
|
| - int GetBookmarkButtonCount();
|
| -
|
| // Returns the tooltip text for the specified url and title. The returned
|
| // text is clipped to fit within the bounds of the monitor.
|
| //
|
| @@ -251,6 +169,99 @@ class BookmarkBarView : public DetachableToolbarView,
|
| const std::wstring& title,
|
| Profile* profile);
|
|
|
| + // DetachableToolbarView methods:
|
| + virtual bool IsDetached() const OVERRIDE;
|
| + virtual double GetAnimationValue() const OVERRIDE;
|
| + virtual int GetToolbarOverlap() const OVERRIDE;
|
| +
|
| + // View methods:
|
| + virtual gfx::Size GetPreferredSize() OVERRIDE;
|
| + virtual gfx::Size GetMinimumSize() OVERRIDE;
|
| + virtual void Layout() OVERRIDE;
|
| + virtual void ViewHierarchyChanged(bool
|
| + is_add,
|
| + View* parent,
|
| + View* child) OVERRIDE;
|
| + virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
|
| + virtual bool GetDropFormats(
|
| + int* formats,
|
| + std::set<ui::OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
|
| + virtual bool AreDropTypesRequired() OVERRIDE;
|
| + virtual bool CanDrop(const ui::OSExchangeData& data) OVERRIDE;
|
| + virtual void OnDragEntered(const views::DropTargetEvent& event) OVERRIDE;
|
| + virtual int OnDragUpdated(const views::DropTargetEvent& event) OVERRIDE;
|
| + virtual void OnDragExited() OVERRIDE;
|
| + virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE;
|
| + virtual void ShowContextMenu(const gfx::Point& p,
|
| + bool is_mouse_gesture) OVERRIDE;
|
| + virtual void OnThemeChanged() OVERRIDE;
|
| +
|
| + // AccessiblePaneView methods:
|
| + virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
|
| +
|
| + // ProfileSyncServiceObserver method.
|
| + virtual void OnStateChanged() OVERRIDE;
|
| +
|
| + // SlideAnimationDelegate implementation.
|
| + virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
|
| + virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
|
| +
|
| + // BookmarkMenuController::Observer
|
| + virtual void BookmarkMenuDeleted(
|
| + BookmarkMenuController* controller) OVERRIDE;
|
| +
|
| + // BookmarkBarInstructionsView::Delegate.
|
| + virtual void ShowImportDialog() OVERRIDE;
|
| +
|
| + // BookmarkModelObserver:
|
| + virtual void Loaded(BookmarkModel* model) OVERRIDE;
|
| + virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE;
|
| + virtual void BookmarkNodeMoved(BookmarkModel* model,
|
| + const BookmarkNode* old_parent,
|
| + int old_index,
|
| + const BookmarkNode* new_parent,
|
| + int new_index) OVERRIDE;
|
| + virtual void BookmarkNodeAdded(BookmarkModel* model,
|
| + const BookmarkNode* parent,
|
| + int index) OVERRIDE;
|
| + virtual void BookmarkNodeRemoved(BookmarkModel* model,
|
| + const BookmarkNode* parent,
|
| + int old_index,
|
| + const BookmarkNode* node) OVERRIDE;
|
| + virtual void BookmarkNodeChanged(BookmarkModel* model,
|
| + const BookmarkNode* node) OVERRIDE;
|
| + virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
|
| + const BookmarkNode* node) OVERRIDE;
|
| + virtual void BookmarkNodeFaviconLoaded(BookmarkModel* model,
|
| + const BookmarkNode* node) OVERRIDE;
|
| +
|
| + // DragController:
|
| + virtual void WriteDragDataForView(views::View* sender,
|
| + const gfx::Point& press_pt,
|
| + ui::OSExchangeData* data) OVERRIDE;
|
| + virtual int GetDragOperationsForView(views::View* sender,
|
| + const gfx::Point& p) OVERRIDE;
|
| + virtual bool CanStartDragForView(views::View* sender,
|
| + const gfx::Point& press_pt,
|
| + const gfx::Point& p) OVERRIDE;
|
| +
|
| + // ViewMenuDelegate:
|
| + virtual void RunMenu(views::View* view, const gfx::Point& pt) OVERRIDE;
|
| +
|
| + // ButtonListener:
|
| + virtual void ButtonPressed(views::Button* sender,
|
| + const views::Event& event) OVERRIDE;
|
| +
|
| + // ContextMenuController
|
| + virtual void ShowContextMenuForView(views::View* source,
|
| + const gfx::Point& p,
|
| + bool is_mouse_gesture) OVERRIDE;
|
| +
|
| + // NotificationService:
|
| + virtual void Observe(NotificationType type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details) OVERRIDE;
|
| +
|
| // If true we're running tests. This short circuits a couple of animations.
|
| static bool testing_;
|
|
|
| @@ -297,120 +308,30 @@ class BookmarkBarView : public DetachableToolbarView,
|
| // Creates the button used when not all bookmark buttons fit.
|
| views::MenuButton* CreateOverflowButton();
|
|
|
| - // Invoked when the bookmark bar model has finished loading. Creates a button
|
| - // for each of the children of the root node from the model.
|
| - virtual void Loaded(BookmarkModel* model);
|
| -
|
| - // Invoked when the model is being deleted.
|
| - virtual void BookmarkModelBeingDeleted(BookmarkModel* model);
|
| + // Creates the sync error button and adds it as a child view.
|
| + views::TextButton* CreateSyncErrorButton();
|
|
|
| - // Invokes added followed by removed.
|
| - virtual void BookmarkNodeMoved(BookmarkModel* model,
|
| - const BookmarkNode* old_parent,
|
| - int old_index,
|
| - const BookmarkNode* new_parent,
|
| - int new_index);
|
| + // Creates the button for rendering the specified bookmark node.
|
| + views::View* CreateBookmarkButton(const BookmarkNode* node);
|
|
|
| - // Notifies ModelChangeListener of change.
|
| - // If the node was added to the root node, a button is created and added to
|
| - // this bookmark bar view.
|
| - virtual void BookmarkNodeAdded(BookmarkModel* model,
|
| - const BookmarkNode* parent,
|
| - int index);
|
| + // COnfigures the button from the specified node. This sets the text,
|
| + // and icon.
|
| + void ConfigureButton(const BookmarkNode* node, views::TextButton* button);
|
|
|
| // Implementation for BookmarkNodeAddedImpl.
|
| void BookmarkNodeAddedImpl(BookmarkModel* model,
|
| const BookmarkNode* parent,
|
| int index);
|
|
|
| - // Notifies ModelChangeListener of change.
|
| - // If the node was a child of the root node, the button corresponding to it
|
| - // is removed.
|
| - virtual void BookmarkNodeRemoved(BookmarkModel* model,
|
| - const BookmarkNode* parent,
|
| - int old_index,
|
| - const BookmarkNode* node);
|
| -
|
| // Implementation for BookmarkNodeRemoved.
|
| void BookmarkNodeRemovedImpl(BookmarkModel* model,
|
| const BookmarkNode* parent,
|
| int index);
|
|
|
| - // Notifies ModelChangedListener and invokes BookmarkNodeChangedImpl.
|
| - virtual void BookmarkNodeChanged(BookmarkModel* model,
|
| - const BookmarkNode* node);
|
| -
|
| // If the node is a child of the root node, the button is updated
|
| // appropriately.
|
| void BookmarkNodeChangedImpl(BookmarkModel* model, const BookmarkNode* node);
|
|
|
| - virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
|
| - const BookmarkNode* node);
|
| -
|
| - // Invoked when the favicon is available. If the node is a child of the
|
| - // root node, the appropriate button is updated. If a menu is showing, the
|
| - // call is forwarded to the menu to allow for it to update the icon.
|
| - virtual void BookmarkNodeFaviconLoaded(BookmarkModel* model,
|
| - const BookmarkNode* node);
|
| -
|
| - // DragController method. Determines the node representing sender and invokes
|
| - // WriteDragData to write the actual data.
|
| - virtual void WriteDragDataForView(views::View* sender,
|
| - const gfx::Point& press_pt,
|
| - ui::OSExchangeData* data) OVERRIDE;
|
| -
|
| - virtual int GetDragOperationsForView(views::View* sender,
|
| - const gfx::Point& p) OVERRIDE;
|
| -
|
| - virtual bool CanStartDragForView(views::View* sender,
|
| - const gfx::Point& press_pt,
|
| - const gfx::Point& p) OVERRIDE;
|
| -
|
| - // Writes a BookmarkNodeData for node to data.
|
| - void WriteBookmarkDragData(const BookmarkNode* node,
|
| - ui::OSExchangeData* data);
|
| -
|
| - // ViewMenuDelegate method. Ends up creating a BookmarkMenuController to
|
| - // show the menu.
|
| - virtual void RunMenu(views::View* view, const gfx::Point& pt);
|
| -
|
| - // Invoked when a star entry corresponding to a URL on the bookmark bar is
|
| - // pressed. Forwards to the PageNavigator to open the URL.
|
| - virtual void ButtonPressed(views::Button* sender, const views::Event& event);
|
| -
|
| - // Invoked for this View, one of the buttons or the 'other' button. Shows the
|
| - // appropriate context menu.
|
| - virtual void ShowContextMenuForView(views::View* source,
|
| - const gfx::Point& p,
|
| - bool is_mouse_gesture);
|
| -
|
| - // Creates the button for rendering the specified bookmark node.
|
| - views::View* CreateBookmarkButton(const BookmarkNode* node);
|
| -
|
| - // COnfigures the button from the specified node. This sets the text,
|
| - // and icon.
|
| - void ConfigureButton(const BookmarkNode* node, views::TextButton* button);
|
| -
|
| - // Used when showing the menu allowing the user to choose when the bar is
|
| - // visible. Return value corresponds to the users preference for when the
|
| - // bar is visible.
|
| - virtual bool IsItemChecked(int id) const;
|
| -
|
| - // Used when showing the menu allowing the user to choose when the bar is
|
| - // visible. Updates the preferences to match the users choice as appropriate.
|
| - virtual void ExecuteCommand(int id);
|
| -
|
| - // NotificationService method.
|
| - virtual void Observe(NotificationType type,
|
| - const NotificationSource& source,
|
| - const NotificationDetails& details);
|
| -
|
| - // Overridden from views::View.
|
| - virtual void OnThemeChanged();
|
| -
|
| - // If the ModelChangedListener is non-null, ModelChanged is invoked on it.
|
| - void NotifyModelChanged();
|
| -
|
| // Shows the menu used during drag and drop for the specified node.
|
| void ShowDropFolderForNode(const BookmarkNode* node);
|
|
|
| @@ -429,6 +350,10 @@ class BookmarkBarView : public DetachableToolbarView,
|
| bool* is_over_overflow,
|
| bool* is_over_other);
|
|
|
| + // Writes a BookmarkNodeData for node to data.
|
| + void WriteBookmarkDragData(const BookmarkNode* node,
|
| + ui::OSExchangeData* data);
|
| +
|
| // Returns the index of the first hidden bookmark button. If all buttons are
|
| // visible, this returns GetBookmarkButtonCount().
|
| int GetFirstHiddenNodeIndex();
|
| @@ -459,9 +384,6 @@ class BookmarkBarView : public DetachableToolbarView,
|
| // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set.
|
| gfx::Size LayoutItems(bool compute_bounds_only);
|
|
|
| - // Creates the sync error button and adds it as a child view.
|
| - views::TextButton* CreateSyncErrorButton();
|
| -
|
| NotificationRegistrar registrar_;
|
|
|
| Profile* profile_;
|
| @@ -485,9 +407,6 @@ class BookmarkBarView : public DetachableToolbarView,
|
| // Shows the other bookmark entries.
|
| views::MenuButton* other_bookmarked_button_;
|
|
|
| - // ModelChangeListener.
|
| - ModelChangedListener* model_changed_listener_;
|
| -
|
| // Task used to delay showing of the drop menu.
|
| ShowFolderDropMenuTask* show_folder_drop_menu_task_;
|
|
|
|
|