| OLD | NEW |
| 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 "chrome/browser/ui/android/toolbar/toolbar_model_android.h" | 5 #include "chrome/browser/ui/android/toolbar/toolbar_model_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 10 #include "chrome/browser/search/search.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return base::android::ConvertUTF16ToJavaString(env, | 39 return base::android::ConvertUTF16ToJavaString(env, |
| 40 toolbar_model_->GetText()); | 40 toolbar_model_->GetText()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 content::WebContents* ToolbarModelAndroid::GetActiveWebContents() const { | 43 content::WebContents* ToolbarModelAndroid::GetActiveWebContents() const { |
| 44 JNIEnv* env = base::android::AttachCurrentThread(); | 44 JNIEnv* env = base::android::AttachCurrentThread(); |
| 45 ScopedJavaLocalRef<jobject> jdelegate = weak_java_delegate_.get(env); | 45 ScopedJavaLocalRef<jobject> jdelegate = weak_java_delegate_.get(env); |
| 46 if (!jdelegate.obj()) | 46 if (!jdelegate.obj()) |
| 47 return NULL; | 47 return NULL; |
| 48 ScopedJavaLocalRef<jobject> jweb_contents = | 48 ScopedJavaLocalRef<jobject> jweb_contents = |
| 49 Java_ToolbarModelDelegate_getActiveWebContents(env, jdelegate.obj()); | 49 Java_ToolbarModelDelegate_getActiveWebContents(env, jdelegate); |
| 50 return content::WebContents::FromJavaWebContents(jweb_contents.obj()); | 50 return content::WebContents::FromJavaWebContents(jweb_contents.obj()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 bool ToolbarModelAndroid::RegisterToolbarModelAndroid(JNIEnv* env) { | 54 bool ToolbarModelAndroid::RegisterToolbarModelAndroid(JNIEnv* env) { |
| 55 return RegisterNativesImpl(env); | 55 return RegisterNativesImpl(env); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 jlong Init(JNIEnv* env, | 59 jlong Init(JNIEnv* env, |
| 60 const JavaParamRef<jobject>& obj, | 60 const JavaParamRef<jobject>& obj, |
| 61 const JavaParamRef<jobject>& delegate) { | 61 const JavaParamRef<jobject>& delegate) { |
| 62 ToolbarModelAndroid* toolbar_model = new ToolbarModelAndroid(env, delegate); | 62 ToolbarModelAndroid* toolbar_model = new ToolbarModelAndroid(env, delegate); |
| 63 return reinterpret_cast<intptr_t>(toolbar_model); | 63 return reinterpret_cast<intptr_t>(toolbar_model); |
| 64 } | 64 } |
| OLD | NEW |