OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/contextualsearch/contextual_search_tab_helper.h
" | 5 #include "chrome/browser/android/contextualsearch/contextual_search_tab_helper.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 "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_android.h" | 10 #include "chrome/browser/profiles/profile_android.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 weak_factory_.GetWeakPtr())); | 28 weak_factory_.GetWeakPtr())); |
29 } | 29 } |
30 | 30 |
31 ContextualSearchTabHelper::~ContextualSearchTabHelper() { | 31 ContextualSearchTabHelper::~ContextualSearchTabHelper() { |
32 pref_change_registrar_->RemoveAll(); | 32 pref_change_registrar_->RemoveAll(); |
33 } | 33 } |
34 | 34 |
35 void ContextualSearchTabHelper::OnContextualSearchPrefChanged() { | 35 void ContextualSearchTabHelper::OnContextualSearchPrefChanged() { |
36 JNIEnv* env = base::android::AttachCurrentThread(); | 36 JNIEnv* env = base::android::AttachCurrentThread(); |
37 ScopedJavaLocalRef<jobject> jobj = weak_java_ref_.get(env); | 37 ScopedJavaLocalRef<jobject> jobj = weak_java_ref_.get(env); |
38 Java_ContextualSearchTabHelper_onContextualSearchPrefChanged(env, jobj.obj()); | 38 Java_ContextualSearchTabHelper_onContextualSearchPrefChanged(env, jobj); |
39 } | 39 } |
40 | 40 |
41 void ContextualSearchTabHelper::Destroy(JNIEnv* env, | 41 void ContextualSearchTabHelper::Destroy(JNIEnv* env, |
42 const JavaParamRef<jobject>& obj) { | 42 const JavaParamRef<jobject>& obj) { |
43 delete this; | 43 delete this; |
44 } | 44 } |
45 | 45 |
46 static jlong Init(JNIEnv* env, | 46 static jlong Init(JNIEnv* env, |
47 const JavaParamRef<jobject>& obj, | 47 const JavaParamRef<jobject>& obj, |
48 const JavaParamRef<jobject>& java_profile) { | 48 const JavaParamRef<jobject>& java_profile) { |
49 Profile* profile = ProfileAndroid::FromProfileAndroid(java_profile); | 49 Profile* profile = ProfileAndroid::FromProfileAndroid(java_profile); |
50 CHECK(profile); | 50 CHECK(profile); |
51 ContextualSearchTabHelper* tab = new ContextualSearchTabHelper( | 51 ContextualSearchTabHelper* tab = new ContextualSearchTabHelper( |
52 env, obj, profile); | 52 env, obj, profile); |
53 return reinterpret_cast<intptr_t>(tab); | 53 return reinterpret_cast<intptr_t>(tab); |
54 } | 54 } |
55 | 55 |
56 bool RegisterContextualSearchTabHelper(JNIEnv* env) { | 56 bool RegisterContextualSearchTabHelper(JNIEnv* env) { |
57 return RegisterNativesImpl(env); | 57 return RegisterNativesImpl(env); |
58 } | 58 } |
OLD | NEW |