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

Side by Side Diff: content/browser/android/context_selection_client.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/browser/android/context_selection_client.h" 5 #include "content/browser/android/context_selection_client.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/supports_user_data.h" 11 #include "base/supports_user_data.h"
11 #include "content/public/browser/render_frame_host.h" 12 #include "content/public/browser/render_frame_host.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 #include "jni/ContextSelectionClient_jni.h" 14 #include "jni/ContextSelectionClient_jni.h"
14 15
15 using base::android::AttachCurrentThread; 16 using base::android::AttachCurrentThread;
16 using base::android::ConvertUTF16ToJavaString; 17 using base::android::ConvertUTF16ToJavaString;
17 using base::android::JavaParamRef; 18 using base::android::JavaParamRef;
18 using base::android::ScopedJavaLocalRef; 19 using base::android::ScopedJavaLocalRef;
19 20
(...skipping 26 matching lines...) Expand all
46 } 47 }
47 48
48 ContextSelectionClient::ContextSelectionClient( 49 ContextSelectionClient::ContextSelectionClient(
49 JNIEnv* env, 50 JNIEnv* env,
50 const base::android::JavaRef<jobject>& obj, 51 const base::android::JavaRef<jobject>& obj,
51 WebContents* web_contents) 52 WebContents* web_contents)
52 : java_ref_(env, obj), 53 : java_ref_(env, obj),
53 web_contents_(web_contents), 54 web_contents_(web_contents),
54 weak_ptr_factory_(this) { 55 weak_ptr_factory_(this) {
55 DCHECK(!web_contents_->GetUserData(kContextSelectionClientUDKey)); 56 DCHECK(!web_contents_->GetUserData(kContextSelectionClientUDKey));
56 web_contents_->SetUserData(kContextSelectionClientUDKey, new UserData(this)); 57 web_contents_->SetUserData(kContextSelectionClientUDKey,
58 base::MakeUnique<UserData>(this));
57 } 59 }
58 60
59 ContextSelectionClient::~ContextSelectionClient() { 61 ContextSelectionClient::~ContextSelectionClient() {
60 JNIEnv* env = base::android::AttachCurrentThread(); 62 JNIEnv* env = base::android::AttachCurrentThread();
61 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 63 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
62 if (!j_obj.is_null()) { 64 if (!j_obj.is_null()) {
63 Java_ContextSelectionClient_onNativeSideDestroyed( 65 Java_ContextSelectionClient_onNativeSideDestroyed(
64 env, j_obj, reinterpret_cast<intptr_t>(this)); 66 env, j_obj, reinterpret_cast<intptr_t>(this));
65 } 67 }
66 } 68 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 Java_ContextSelectionClient_onSurroundingTextReceived( 102 Java_ContextSelectionClient_onSurroundingTextReceived(
101 env, obj, callback_data, j_text, start, end); 103 env, obj, callback_data, j_text, start, end);
102 } 104 }
103 } 105 }
104 106
105 bool RegisterContextSelectionClient(JNIEnv* env) { 107 bool RegisterContextSelectionClient(JNIEnv* env) {
106 return RegisterNativesImpl(env); 108 return RegisterNativesImpl(env);
107 } 109 }
108 110
109 } // namespace content 111 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.cc ('k') | content/browser/android/java/gin_java_bridge_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698