Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / android / toolbar / toolbar_model_android.cc
blob9c7241cabb40915f8811334d58136a28618901ff
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/android/toolbar/toolbar_model_android.h"
7 #include "base/android/jni_string.h"
8 #include "base/metrics/field_trial.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/search.h"
11 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
12 #include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
13 #include "content/public/browser/cert_store.h"
14 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/ssl_status.h"
17 #include "jni/ToolbarModel_jni.h"
18 #include "net/cert/x509_certificate.h"
20 using base::android::ScopedJavaLocalRef;
22 ToolbarModelAndroid::ToolbarModelAndroid(JNIEnv* env, jobject jdelegate)
23 : toolbar_model_(new ToolbarModelImpl(this)),
24 weak_java_delegate_(env, jdelegate) {
27 ToolbarModelAndroid::~ToolbarModelAndroid() {
30 void ToolbarModelAndroid::Destroy(JNIEnv* env, jobject obj) {
31 delete this;
34 ScopedJavaLocalRef<jstring> ToolbarModelAndroid::GetText(JNIEnv* env,
35 jobject obj) {
36 return base::android::ConvertUTF16ToJavaString(env,
37 toolbar_model_->GetText());
40 ScopedJavaLocalRef<jstring> ToolbarModelAndroid::GetCorpusChipText(
41 JNIEnv* env,
42 jobject obj) {
43 return base::android::ConvertUTF16ToJavaString(
44 env,
45 toolbar_model_->GetCorpusNameForMobile());
48 jboolean ToolbarModelAndroid::WouldReplaceURL(JNIEnv* env, jobject obj) {
49 return toolbar_model_->WouldReplaceURL();
52 content::WebContents* ToolbarModelAndroid::GetActiveWebContents() const {
53 JNIEnv* env = base::android::AttachCurrentThread();
54 ScopedJavaLocalRef<jobject> jdelegate = weak_java_delegate_.get(env);
55 if (!jdelegate.obj())
56 return NULL;
57 ScopedJavaLocalRef<jobject> jweb_contents =
58 Java_ToolbarModelDelegate_getActiveWebContents(env, jdelegate.obj());
59 return content::WebContents::FromJavaWebContents(jweb_contents.obj());
62 // static
63 bool ToolbarModelAndroid::RegisterToolbarModelAndroid(JNIEnv* env) {
64 return RegisterNativesImpl(env);
67 // static
68 jlong Init(JNIEnv* env,
69 const JavaParamRef<jobject>& obj,
70 const JavaParamRef<jobject>& delegate) {
71 ToolbarModelAndroid* toolbar_model = new ToolbarModelAndroid(env, delegate);
72 return reinterpret_cast<intptr_t>(toolbar_model);