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

Side by Side Diff: components/renderer_context_menu/context_menu_delegate.cc

Issue 2842833003: Update SupportsUserData uses with unique_ptr. (Closed)
Patch Set: rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/renderer_context_menu/context_menu_delegate.h" 5 #include "components/renderer_context_menu/context_menu_delegate.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
8 9
9 namespace { 10 namespace {
10 11
11 const char kMenuDelegateUserDataKey[] = "RendererContextMenuMenuDelegate"; 12 const char kMenuDelegateUserDataKey[] = "RendererContextMenuMenuDelegate";
12 13
13 class ContextMenuDelegateUserData : public base::SupportsUserData::Data { 14 class ContextMenuDelegateUserData : public base::SupportsUserData::Data {
14 public: 15 public:
15 explicit ContextMenuDelegateUserData(ContextMenuDelegate* menu_delegate) 16 explicit ContextMenuDelegateUserData(ContextMenuDelegate* menu_delegate)
16 : menu_delegate_(menu_delegate) {} 17 : menu_delegate_(menu_delegate) {}
17 ~ContextMenuDelegateUserData() override {} 18 ~ContextMenuDelegateUserData() override {}
18 ContextMenuDelegate* menu_delegate() { return menu_delegate_; } 19 ContextMenuDelegate* menu_delegate() { return menu_delegate_; }
19 20
20 private: 21 private:
21 ContextMenuDelegate* menu_delegate_; // not owned by us. 22 ContextMenuDelegate* menu_delegate_; // not owned by us.
22 }; 23 };
23 24
24 } // namespace 25 } // namespace
25 26
26 ContextMenuDelegate::ContextMenuDelegate(content::WebContents* web_contents) { 27 ContextMenuDelegate::ContextMenuDelegate(content::WebContents* web_contents) {
27 web_contents->SetUserData(&kMenuDelegateUserDataKey, 28 web_contents->SetUserData(
28 new ContextMenuDelegateUserData(this)); 29 &kMenuDelegateUserDataKey,
30 base::MakeUnique<ContextMenuDelegateUserData>(this));
29 } 31 }
30 32
31 ContextMenuDelegate::~ContextMenuDelegate() { 33 ContextMenuDelegate::~ContextMenuDelegate() {
32 } 34 }
33 35
34 // static 36 // static
35 ContextMenuDelegate* ContextMenuDelegate::FromWebContents( 37 ContextMenuDelegate* ContextMenuDelegate::FromWebContents(
36 content::WebContents* web_contents) { 38 content::WebContents* web_contents) {
37 ContextMenuDelegateUserData* user_data = 39 ContextMenuDelegateUserData* user_data =
38 static_cast<ContextMenuDelegateUserData*>( 40 static_cast<ContextMenuDelegateUserData*>(
39 web_contents->GetUserData(&kMenuDelegateUserDataKey)); 41 web_contents->GetUserData(&kMenuDelegateUserDataKey));
40 return user_data ? user_data->menu_delegate() : NULL; 42 return user_data ? user_data->menu_delegate() : NULL;
41 } 43 }
OLDNEW
« no previous file with comments | « components/pdf/browser/pdf_web_contents_helper.cc ('k') | components/safe_browsing/base_ui_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698