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

Side by Side Diff: chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc

Issue 2488203003: [Extensions] Don't remove the bookmark drag event router as delegate (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h" 5 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage r_private_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 event_router_.reset(new BookmarkManagerPrivateEventRouter( 284 event_router_.reset(new BookmarkManagerPrivateEventRouter(
285 browser_context_, 285 browser_context_,
286 BookmarkModelFactory::GetForBrowserContext(browser_context_))); 286 BookmarkModelFactory::GetForBrowserContext(browser_context_)));
287 } 287 }
288 288
289 BookmarkManagerPrivateDragEventRouter::BookmarkManagerPrivateDragEventRouter( 289 BookmarkManagerPrivateDragEventRouter::BookmarkManagerPrivateDragEventRouter(
290 content::WebContents* web_contents) 290 content::WebContents* web_contents)
291 : web_contents_(web_contents), 291 : web_contents_(web_contents),
292 profile_( 292 profile_(
293 Profile::FromBrowserContext(web_contents_->GetBrowserContext())) { 293 Profile::FromBrowserContext(web_contents_->GetBrowserContext())) {
294 // We need to guarantee the BookmarkTabHelper is created.
295 BookmarkTabHelper::CreateForWebContents(web_contents_);
294 BookmarkTabHelper* bookmark_tab_helper = 296 BookmarkTabHelper* bookmark_tab_helper =
295 BookmarkTabHelper::FromWebContents(web_contents_); 297 BookmarkTabHelper::FromWebContents(web_contents_);
296 bookmark_tab_helper->set_bookmark_drag_delegate(this); 298 bookmark_tab_helper->set_bookmark_drag_delegate(this);
297 } 299 }
298 300
299 BookmarkManagerPrivateDragEventRouter:: 301 BookmarkManagerPrivateDragEventRouter::
300 ~BookmarkManagerPrivateDragEventRouter() { 302 ~BookmarkManagerPrivateDragEventRouter() {
301 BookmarkTabHelper* bookmark_tab_helper = 303 // No need to remove ourselves as the BookmarkTabHelper's delegate, since they
302 BookmarkTabHelper::FromWebContents(web_contents_); 304 // are both WebContentsUserData and will be deleted at the same time.
303 if (bookmark_tab_helper->bookmark_drag_delegate() == this)
304 bookmark_tab_helper->set_bookmark_drag_delegate(NULL);
305 } 305 }
306 306
307 void BookmarkManagerPrivateDragEventRouter::MaybeCreateForWebContents( 307 void BookmarkManagerPrivateDragEventRouter::MaybeCreateForWebContents(
308 content::WebContents* web_contents) { 308 content::WebContents* web_contents) {
309 content::BrowserContext* context = web_contents->GetBrowserContext(); 309 content::BrowserContext* context = web_contents->GetBrowserContext();
310 const Extension* extension = 310 const Extension* extension =
311 ExtensionRegistry::Get(context) 311 ExtensionRegistry::Get(context)
312 ->enabled_extensions() 312 ->enabled_extensions()
313 .GetExtensionOrAppByURL( 313 .GetExtensionOrAppByURL(
314 web_contents->GetSiteInstance()->GetSiteURL()); 314 web_contents->GetSiteInstance()->GetSiteURL());
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 872
873 RedoInfo::Results::Result result; 873 RedoInfo::Results::Result result;
874 result.enabled = undo_manager->redo_count() > 0; 874 result.enabled = undo_manager->redo_count() > 0;
875 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel()); 875 result.label = base::UTF16ToUTF8(undo_manager->GetRedoLabel());
876 876
877 results_ = RedoInfo::Results::Create(result); 877 results_ = RedoInfo::Results::Create(result);
878 return true; 878 return true;
879 } 879 }
880 880
881 } // namespace extensions 881 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698