Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2471)

Unified Diff: chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc

Issue 10945010: Switch BookmarkTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
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 83ab25e59e97f5b970bcc825a5f3f97d5b568e85..f26d502ecc7fdb1f86180982915c1ca254e4c102 100644
--- a/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
+++ b/chrome/browser/tab_contents/web_drag_bookmark_handler_gtk.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/dragdrop/gtk_dnd_util.h"
@@ -17,7 +16,8 @@
using content::WebContents;
WebDragBookmarkHandlerGtk::WebDragBookmarkHandlerGtk()
- : tab_(NULL) {
+ : bookmark_tab_helper_(NULL),
+ web_contents_(NULL) {
}
WebDragBookmarkHandlerGtk::~WebDragBookmarkHandlerGtk() {}
@@ -25,13 +25,13 @@ WebDragBookmarkHandlerGtk::~WebDragBookmarkHandlerGtk() {}
void WebDragBookmarkHandlerGtk::DragInitialize(WebContents* contents) {
bookmark_drag_data_.Clear();
- // Ideally we would want to initialize the the TabContents member in
+ // Ideally we would want to initialize the the BookmarkTabHelper member in
// the constructor. We cannot do that as the WebDragDestGtk object is
// created during the construction of the WebContents object. The
- // TabContents is created much later.
- DCHECK(tab_ ? (tab_->web_contents() == contents) : true);
- if (!tab_)
- tab_ = TabContents::FromWebContents(contents);
+ // BookmarkTabHelper is created much later.
+ web_contents_ = contents;
+ if (!bookmark_tab_helper_)
+ bookmark_tab_helper_ = BookmarkTabHelper::FromWebContents(contents);
}
GdkAtom WebDragBookmarkHandlerGtk::GetBookmarkTargetAtom() const {
@@ -42,15 +42,14 @@ GdkAtom WebDragBookmarkHandlerGtk::GetBookmarkTargetAtom() const {
}
void WebDragBookmarkHandlerGtk::OnReceiveDataFromGtk(GtkSelectionData* data) {
- if (tab_) {
- Profile* profile = tab_->profile();
- bookmark_drag_data_.ReadFromVector(
- bookmark_utils::GetNodesFromSelection(
- NULL, data,
- ui::CHROME_BOOKMARK_ITEM,
- profile, NULL, NULL));
- bookmark_drag_data_.SetOriginatingProfile(profile);
- }
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext());
+ bookmark_drag_data_.ReadFromVector(
+ bookmark_utils::GetNodesFromSelection(
+ NULL, data,
+ ui::CHROME_BOOKMARK_ITEM,
+ profile, NULL, NULL));
+ bookmark_drag_data_.SetOriginatingProfile(profile);
}
void WebDragBookmarkHandlerGtk::OnReceiveProcessedData(const GURL& url,
@@ -59,17 +58,17 @@ void WebDragBookmarkHandlerGtk::OnReceiveProcessedData(const GURL& url,
}
void WebDragBookmarkHandlerGtk::OnDragOver() {
- if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
- tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragOver(
bookmark_drag_data_);
}
}
void WebDragBookmarkHandlerGtk::OnDragEnter() {
- // This is non-null if tab_contents_ is showing an ExtensionWebUI with
+ // This is non-null if the web_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
- if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
- tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragEnter(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragEnter(
bookmark_drag_data_);
}
}
@@ -77,23 +76,22 @@ void WebDragBookmarkHandlerGtk::OnDragEnter() {
void WebDragBookmarkHandlerGtk::OnDrop() {
// This is non-null if tab_contents_ is showing an ExtensionWebUI with
// support for (at the moment experimental) drag and drop extensions.
- if (tab_) {
- if (tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
- tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDrop(
+ if (bookmark_tab_helper_) {
+ if (bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDrop(
bookmark_drag_data_);
}
// Focus the target browser.
- Browser* browser = browser::FindBrowserWithWebContents(
- tab_->web_contents());
+ Browser* browser = browser::FindBrowserWithWebContents(web_contents_);
if (browser)
browser->window()->Show();
}
}
void WebDragBookmarkHandlerGtk::OnDragLeave() {
- if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()) {
- tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave(
+ if (bookmark_tab_helper_ && bookmark_tab_helper_->GetBookmarkDragDelegate()) {
+ bookmark_tab_helper_->GetBookmarkDragDelegate()->OnDragLeave(
bookmark_drag_data_);
}
}

Powered by Google App Engine
This is Rietveld 408576698