| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_BOOKMARKS_BOOKMARK_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_ |
| 6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/tab_contents/web_contents_user_data.h" |
| 8 #include "content/public/browser/notification_observer.h" | 9 #include "content/public/browser/notification_observer.h" |
| 9 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 11 | 12 |
| 13 struct BookmarkNodeData; |
| 12 class BookmarkTabHelperDelegate; | 14 class BookmarkTabHelperDelegate; |
| 13 class TabContents; | 15 |
| 14 struct BookmarkNodeData; | 16 namespace content { |
| 17 class WebContents; |
| 18 } |
| 15 | 19 |
| 16 // Per-tab class to manage bookmarks. | 20 // Per-tab class to manage bookmarks. |
| 17 class BookmarkTabHelper : public content::NotificationObserver, | 21 class BookmarkTabHelper : public content::NotificationObserver, |
| 18 public content::WebContentsObserver { | 22 public content::WebContentsObserver, |
| 23 public WebContentsUserData<BookmarkTabHelper> { |
| 19 public: | 24 public: |
| 20 // BookmarkDrag -------------------------------------------------------------- | 25 // BookmarkDrag -------------------------------------------------------------- |
| 21 // Interface for forwarding bookmark drag and drop to extenstions. | 26 // Interface for forwarding bookmark drag and drop to extenstions. |
| 22 class BookmarkDrag { | 27 class BookmarkDrag { |
| 23 public: | 28 public: |
| 24 virtual void OnDragEnter(const BookmarkNodeData& data) = 0; | 29 virtual void OnDragEnter(const BookmarkNodeData& data) = 0; |
| 25 virtual void OnDragOver(const BookmarkNodeData& data) = 0; | 30 virtual void OnDragOver(const BookmarkNodeData& data) = 0; |
| 26 virtual void OnDragLeave(const BookmarkNodeData& data) = 0; | 31 virtual void OnDragLeave(const BookmarkNodeData& data) = 0; |
| 27 virtual void OnDrop(const BookmarkNodeData& data) = 0; | 32 virtual void OnDrop(const BookmarkNodeData& data) = 0; |
| 28 | 33 |
| 29 protected: | 34 protected: |
| 30 virtual ~BookmarkDrag() {} | 35 virtual ~BookmarkDrag() {} |
| 31 }; | 36 }; |
| 32 | 37 |
| 33 explicit BookmarkTabHelper(TabContents* tab_contents); | |
| 34 virtual ~BookmarkTabHelper(); | 38 virtual ~BookmarkTabHelper(); |
| 35 | 39 |
| 36 bool is_starred() const { return is_starred_; } | 40 bool is_starred() const { return is_starred_; } |
| 37 | 41 |
| 38 BookmarkTabHelperDelegate* delegate() const { return delegate_; } | 42 BookmarkTabHelperDelegate* delegate() const { return delegate_; } |
| 39 void set_delegate(BookmarkTabHelperDelegate* d) { delegate_ = d; } | 43 void set_delegate(BookmarkTabHelperDelegate* d) { delegate_ = d; } |
| 40 | 44 |
| 41 // Returns true if the bookmark bar should be shown detached. | 45 // Returns true if the bookmark bar should be shown detached. |
| 42 bool ShouldShowBookmarkBar(); | 46 bool ShouldShowBookmarkBar(); |
| 43 | 47 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 // It is up to callers to call SetBookmarkDragDelegate(NULL) when | 58 // It is up to callers to call SetBookmarkDragDelegate(NULL) when |
| 55 // |bookmark_drag| is deleted since this class does not take ownership of | 59 // |bookmark_drag| is deleted since this class does not take ownership of |
| 56 // |bookmark_drag|. | 60 // |bookmark_drag|. |
| 57 void SetBookmarkDragDelegate( | 61 void SetBookmarkDragDelegate( |
| 58 BookmarkTabHelper::BookmarkDrag* bookmark_drag); | 62 BookmarkTabHelper::BookmarkDrag* bookmark_drag); |
| 59 // The BookmarkDragDelegate is used to forward bookmark drag and drop events | 63 // The BookmarkDragDelegate is used to forward bookmark drag and drop events |
| 60 // to extensions. | 64 // to extensions. |
| 61 BookmarkTabHelper::BookmarkDrag* GetBookmarkDragDelegate(); | 65 BookmarkTabHelper::BookmarkDrag* GetBookmarkDragDelegate(); |
| 62 | 66 |
| 63 private: | 67 private: |
| 68 explicit BookmarkTabHelper(content::WebContents* web_contents); |
| 69 static int kUserDataKey; |
| 70 friend class WebContentsUserData<BookmarkTabHelper>; |
| 71 |
| 64 // Updates the starred state from the bookmark bar model. If the state has | 72 // Updates the starred state from the bookmark bar model. If the state has |
| 65 // changed, the delegate is notified. | 73 // changed, the delegate is notified. |
| 66 void UpdateStarredStateForCurrentURL(); | 74 void UpdateStarredStateForCurrentURL(); |
| 67 | 75 |
| 68 // Whether the current URL is starred. | 76 // Whether the current URL is starred. |
| 69 bool is_starred_; | 77 bool is_starred_; |
| 70 | 78 |
| 71 // Registers and unregisters us for notifications. | 79 // Registers and unregisters us for notifications. |
| 72 content::NotificationRegistrar registrar_; | 80 content::NotificationRegistrar registrar_; |
| 73 | 81 |
| 74 // Owning TabContents. | |
| 75 TabContents* tab_contents_; | |
| 76 | |
| 77 // Delegate for notifying our owner (usually Browser) about stuff. Not owned | 82 // Delegate for notifying our owner (usually Browser) about stuff. Not owned |
| 78 // by us. | 83 // by us. |
| 79 BookmarkTabHelperDelegate* delegate_; | 84 BookmarkTabHelperDelegate* delegate_; |
| 80 | 85 |
| 81 // Handles drag and drop event forwarding to extensions. | 86 // Handles drag and drop event forwarding to extensions. |
| 82 BookmarkDrag* bookmark_drag_; | 87 BookmarkDrag* bookmark_drag_; |
| 83 | 88 |
| 84 DISALLOW_COPY_AND_ASSIGN(BookmarkTabHelper); | 89 DISALLOW_COPY_AND_ASSIGN(BookmarkTabHelper); |
| 85 }; | 90 }; |
| 86 | 91 |
| 87 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_ | 92 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_TAB_HELPER_H_ |
| OLD | NEW |