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