summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/bookmarks/bookmark_manager_extension_api.cc12
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc18
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc16
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm16
-rw-r--r--chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc16
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_tab_helper.cc50
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_tab_helper.h47
7 files changed, 83 insertions, 92 deletions
diff --git a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc
index 385e909..bfcd2be 100644
--- a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc
+++ b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc
@@ -163,18 +163,19 @@ BookmarkManagerExtensionEventRouter::BookmarkManagerExtensionEventRouter(
web_contents_(web_contents) {
BookmarkTabHelper* bookmark_tab_helper =
BookmarkTabHelper::FromWebContents(web_contents_);
- bookmark_tab_helper->SetBookmarkDragDelegate(this);
+ bookmark_tab_helper->set_bookmark_drag_delegate(this);
}
BookmarkManagerExtensionEventRouter::~BookmarkManagerExtensionEventRouter() {
BookmarkTabHelper* bookmark_tab_helper =
BookmarkTabHelper::FromWebContents(web_contents_);
- if (bookmark_tab_helper->GetBookmarkDragDelegate() == this)
- bookmark_tab_helper->SetBookmarkDragDelegate(NULL);
+ if (bookmark_tab_helper->bookmark_drag_delegate() == this)
+ bookmark_tab_helper->set_bookmark_drag_delegate(NULL);
}
void BookmarkManagerExtensionEventRouter::DispatchEvent(
- const char* event_name, scoped_ptr<ListValue> args) {
+ const char* event_name,
+ scoped_ptr<ListValue> args) {
if (!extensions::ExtensionSystem::Get(profile_)->event_router())
return;
@@ -185,7 +186,8 @@ void BookmarkManagerExtensionEventRouter::DispatchEvent(
}
void BookmarkManagerExtensionEventRouter::DispatchDragEvent(
- const BookmarkNodeData& data, const char* event_name) {
+ const BookmarkNodeData& data,
+ const char* event_name) {
if (data.size() == 0)
return;
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc b/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc
index c074236..0fa5f92 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_aura.cc
@@ -35,16 +35,16 @@ void WebDragBookmarkHandlerAura::DragInitialize(WebContents* contents) {
}
void WebDragBookmarkHandlerAura::OnDragOver() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
if (bookmark_drag_data_.is_valid())
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragOver(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragOver(
bookmark_drag_data_);
}
}
void WebDragBookmarkHandlerAura::OnReceiveDragData(
const ui::OSExchangeData& data) {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
// Read the bookmark drag data and save it for use in later events in this
// drag.
bookmark_drag_data_.Read(data);
@@ -52,18 +52,18 @@ void WebDragBookmarkHandlerAura::OnReceiveDragData(
}
void WebDragBookmarkHandlerAura::OnDragEnter() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
if (bookmark_drag_data_.is_valid())
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragEnter(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragEnter(
bookmark_drag_data_);
}
}
void WebDragBookmarkHandlerAura::OnDrop() {
if (bookmark_tab_helper_) {
- if (bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_->bookmark_drag_delegate()) {
if (bookmark_drag_data_.is_valid()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDrop(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDrop(
bookmark_drag_data_);
}
}
@@ -78,9 +78,9 @@ void WebDragBookmarkHandlerAura::OnDrop() {
}
void WebDragBookmarkHandlerAura::OnDragLeave() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
if (bookmark_drag_data_.is_valid())
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragLeave(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragLeave(
bookmark_drag_data_);
}
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc b/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
index e22fd1d..3496e04 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
@@ -58,8 +58,8 @@ void WebDragBookmarkHandlerGtk::OnReceiveProcessedData(const GURL& url,
}
void WebDragBookmarkHandlerGtk::OnDragOver() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragOver(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragOver(
bookmark_drag_data_);
}
}
@@ -67,8 +67,8 @@ void WebDragBookmarkHandlerGtk::OnDragOver() {
void WebDragBookmarkHandlerGtk::OnDragEnter() {
// This is non-null if the web_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragEnter(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragEnter(
bookmark_drag_data_);
}
}
@@ -77,8 +77,8 @@ void WebDragBookmarkHandlerGtk::OnDrop() {
// This is non-null if web_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
if (bookmark_tab_helper_) {
- if (bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDrop(
+ if (bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDrop(
bookmark_drag_data_);
}
@@ -90,8 +90,8 @@ void WebDragBookmarkHandlerGtk::OnDrop() {
}
void WebDragBookmarkHandlerGtk::OnDragLeave() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragLeave(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragLeave(
bookmark_drag_data_);
}
}
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm b/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm
index e7a9a7d..d1c7d91 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_mac.mm
@@ -28,15 +28,15 @@ void WebDragBookmarkHandlerMac::DragInitialize(WebContents* contents) {
}
void WebDragBookmarkHandlerMac::OnDragOver() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragOver(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragOver(
bookmark_drag_data_);
}
}
void WebDragBookmarkHandlerMac::OnDragEnter() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragEnter(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragEnter(
bookmark_drag_data_);
}
}
@@ -45,8 +45,8 @@ void WebDragBookmarkHandlerMac::OnDrop() {
// This is non-null if the web_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
if (bookmark_tab_helper_) {
- if (bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDrop(
+ if (bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDrop(
bookmark_drag_data_);
}
@@ -58,8 +58,8 @@ void WebDragBookmarkHandlerMac::OnDrop() {
}
void WebDragBookmarkHandlerMac::OnDragLeave() {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragLeave(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragLeave(
bookmark_drag_data_);
}
}
diff --git a/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc b/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc
index 37172a8..fe9a018 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_win.cc
@@ -37,12 +37,12 @@ void WebDragBookmarkHandlerWin::DragInitialize(WebContents* contents) {
}
void WebDragBookmarkHandlerWin::OnDragOver(IDataObject* data_object) {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data))
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragOver(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragOver(
bookmark_drag_data);
}
}
@@ -50,12 +50,12 @@ void WebDragBookmarkHandlerWin::OnDragOver(IDataObject* data_object) {
void WebDragBookmarkHandlerWin::OnDragEnter(IDataObject* data_object) {
// This is non-null if the web_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data))
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragEnter(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragEnter(
bookmark_drag_data);
}
}
@@ -64,12 +64,12 @@ void WebDragBookmarkHandlerWin::OnDrop(IDataObject* data_object) {
// This is non-null if the web_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
if (bookmark_tab_helper_) {
- if (bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_->bookmark_drag_delegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data)) {
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDrop(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDrop(
bookmark_drag_data);
}
}
@@ -82,12 +82,12 @@ void WebDragBookmarkHandlerWin::OnDrop(IDataObject* data_object) {
}
void WebDragBookmarkHandlerWin::OnDragLeave(IDataObject* data_object) {
- if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
ui::OSExchangeData os_exchange_data(
new ui::OSExchangeDataProviderWin(data_object));
BookmarkNodeData bookmark_drag_data;
if (bookmark_drag_data.Read(os_exchange_data))
- bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragLeave(
+ bookmark_tab_helper_->bookmark_drag_delegate()->OnDragLeave(
bookmark_drag_data);
}
}
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
index 33b84e8..d3245fd 100644
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
@@ -24,25 +24,12 @@ bool CanShowBookmarkBar(content::WebUI* ui) {
} // namespace
-BookmarkTabHelper::BookmarkTabHelper(content::WebContents* web_contents)
- : content::WebContentsObserver(web_contents),
- is_starred_(false),
- bookmark_model_(NULL),
- delegate_(NULL),
- bookmark_drag_(NULL) {
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
- bookmark_model_= BookmarkModelFactory::GetForProfile(profile);
- if (bookmark_model_)
- bookmark_model_->AddObserver(this);
-}
-
BookmarkTabHelper::~BookmarkTabHelper() {
if (bookmark_model_)
bookmark_model_->RemoveObserver(this);
}
-bool BookmarkTabHelper::ShouldShowBookmarkBar() {
+bool BookmarkTabHelper::ShouldShowBookmarkBar() const {
if (web_contents()->ShowingInterstitialPage())
return false;
@@ -61,20 +48,17 @@ bool BookmarkTabHelper::ShouldShowBookmarkBar() {
return CanShowBookmarkBar(web_contents()->GetWebUI());
}
-void BookmarkTabHelper::DidNavigateMainFrame(
- const content::LoadCommittedDetails& /*details*/,
- const content::FrameNavigateParams& /*params*/) {
- UpdateStarredStateForCurrentURL();
-}
-
-void BookmarkTabHelper::SetBookmarkDragDelegate(
- BookmarkTabHelper::BookmarkDrag* bookmark_drag) {
- bookmark_drag_ = bookmark_drag;
-}
-
-BookmarkTabHelper::BookmarkDrag*
- BookmarkTabHelper::GetBookmarkDragDelegate() {
- return bookmark_drag_;
+BookmarkTabHelper::BookmarkTabHelper(content::WebContents* web_contents)
+ : content::WebContentsObserver(web_contents),
+ is_starred_(false),
+ bookmark_model_(NULL),
+ delegate_(NULL),
+ bookmark_drag_(NULL) {
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ bookmark_model_= BookmarkModelFactory::GetForProfile(profile);
+ if (bookmark_model_)
+ bookmark_model_->AddObserver(this);
}
void BookmarkTabHelper::UpdateStarredStateForCurrentURL() {
@@ -82,8 +66,8 @@ void BookmarkTabHelper::UpdateStarredStateForCurrentURL() {
is_starred_ = (bookmark_model_ &&
bookmark_model_->IsBookmarked(web_contents()->GetURL()));
- if (is_starred_ != old_state && delegate())
- delegate()->URLStarredChanged(web_contents(), is_starred_);
+ if (is_starred_ != old_state && delegate_)
+ delegate_->URLStarredChanged(web_contents(), is_starred_);
}
void BookmarkTabHelper::BookmarkModelChanged() {
@@ -110,3 +94,9 @@ void BookmarkTabHelper::BookmarkNodeChanged(BookmarkModel* model,
const BookmarkNode* node) {
UpdateStarredStateForCurrentURL();
}
+
+void BookmarkTabHelper::DidNavigateMainFrame(
+ const content::LoadCommittedDetails& /*details*/,
+ const content::FrameNavigateParams& /*params*/) {
+ UpdateStarredStateForCurrentURL();
+}
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.h b/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
index 4cb683a..757bcd3 100644
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
@@ -22,7 +22,6 @@ class BookmarkTabHelper
public content::WebContentsObserver,
public content::WebContentsUserData<BookmarkTabHelper> {
public:
- // BookmarkDrag --------------------------------------------------------------
// Interface for forwarding bookmark drag and drop to extenstions.
class BookmarkDrag {
public:
@@ -37,35 +36,30 @@ class BookmarkTabHelper
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;
+ void set_delegate(BookmarkTabHelperDelegate* delegate) {
+ delegate_ = delegate;
+ }
- // It is up to callers to call SetBookmarkDragDelegate(NULL) when
+ // It is up to callers to call set_bookmark_drag_delegate(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();
+ void set_bookmark_drag_delegate(BookmarkDrag* bookmark_drag) {
+ bookmark_drag_ = bookmark_drag;
+ }
+ BookmarkDrag* bookmark_drag_delegate() { return bookmark_drag_; }
+
+ bool is_starred() const { return is_starred_; }
+
+ // Returns true if the bookmark bar should be shown detached.
+ bool ShouldShowBookmarkBar() const;
private:
friend class content::WebContentsUserData<BookmarkTabHelper>;
explicit BookmarkTabHelper(content::WebContents* web_contents);
- // Updates the starred state from the bookmark bar model. If the state has
- // changed, the delegate is notified.
+ // Updates the starred state from the BookmarkModel. If the state has changed,
+ // the delegate is notified.
void UpdateStarredStateForCurrentURL();
// Overridden from BaseBookmarkModelObserver:
@@ -81,16 +75,21 @@ class BookmarkTabHelper
virtual void BookmarkNodeChanged(BookmarkModel* model,
const BookmarkNode* node) OVERRIDE;
+ // Overridden from content::WebContentsObserver:
+ virtual void DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) OVERRIDE;
+
// Whether the current URL is starred.
bool is_starred_;
BookmarkModel* bookmark_model_;
- // Delegate for notifying our owner (usually Browser) about stuff. Not owned
- // by us.
+ // Our delegate, to notify when the url starred changed.
BookmarkTabHelperDelegate* delegate_;
- // Handles drag and drop event forwarding to extensions.
+ // The BookmarkDrag is used to forward bookmark drag and drop events to
+ // extensions.
BookmarkDrag* bookmark_drag_;
DISALLOW_COPY_AND_ASSIGN(BookmarkTabHelper);