Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / bookmarks / bookmark_tab_helper.h
blob6a16a0a9dded724c291c8031cc46b853e26261f5
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_
8 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_contents_user_data.h"
12 struct BookmarkNodeData;
13 class BookmarkTabHelperDelegate;
15 namespace content {
16 class WebContents;
19 // Per-tab class to manage bookmarks.
20 class BookmarkTabHelper
21 : public BaseBookmarkModelObserver,
22 public content::WebContentsObserver,
23 public content::WebContentsUserData<BookmarkTabHelper> {
24 public:
25 // Interface for forwarding bookmark drag and drop to extenstions.
26 class BookmarkDrag {
27 public:
28 virtual void OnDragEnter(const BookmarkNodeData& data) = 0;
29 virtual void OnDragOver(const BookmarkNodeData& data) = 0;
30 virtual void OnDragLeave(const BookmarkNodeData& data) = 0;
31 virtual void OnDrop(const BookmarkNodeData& data) = 0;
33 protected:
34 virtual ~BookmarkDrag() {}
37 virtual ~BookmarkTabHelper();
39 void set_delegate(BookmarkTabHelperDelegate* delegate) {
40 delegate_ = delegate;
43 // It is up to callers to call set_bookmark_drag_delegate(NULL) when
44 // |bookmark_drag| is deleted since this class does not take ownership of
45 // |bookmark_drag|.
46 void set_bookmark_drag_delegate(BookmarkDrag* bookmark_drag) {
47 bookmark_drag_ = bookmark_drag;
49 BookmarkDrag* bookmark_drag_delegate() { return bookmark_drag_; }
51 bool is_starred() const { return is_starred_; }
53 // Returns true if the bookmark bar should be shown detached.
54 bool ShouldShowBookmarkBar() const;
56 private:
57 friend class content::WebContentsUserData<BookmarkTabHelper>;
59 explicit BookmarkTabHelper(content::WebContents* web_contents);
61 // Updates the starred state from the BookmarkModel. If the state has changed,
62 // the delegate is notified.
63 void UpdateStarredStateForCurrentURL();
65 // Overridden from BaseBookmarkModelObserver:
66 virtual void BookmarkModelChanged() OVERRIDE;
67 virtual void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE;
68 virtual void BookmarkNodeAdded(BookmarkModel* model,
69 const BookmarkNode* parent,
70 int index) OVERRIDE;
71 virtual void BookmarkNodeRemoved(BookmarkModel* model,
72 const BookmarkNode* parent,
73 int old_index,
74 const BookmarkNode* node) OVERRIDE;
75 virtual void BookmarkAllNodesRemoved(BookmarkModel* model) OVERRIDE;
77 virtual void BookmarkNodeChanged(BookmarkModel* model,
78 const BookmarkNode* node) OVERRIDE;
80 // Overridden from content::WebContentsObserver:
81 virtual void DidNavigateMainFrame(
82 const content::LoadCommittedDetails& details,
83 const content::FrameNavigateParams& params) OVERRIDE;
85 // Whether the current URL is starred.
86 bool is_starred_;
88 BookmarkModel* bookmark_model_;
90 // Our delegate, to notify when the url starred changed.
91 BookmarkTabHelperDelegate* delegate_;
93 // The BookmarkDrag is used to forward bookmark drag and drop events to
94 // extensions.
95 BookmarkDrag* bookmark_drag_;
97 DISALLOW_COPY_AND_ASSIGN(BookmarkTabHelper);
100 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_