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. 4 5 #ifndef CHROME_BROWSER_UI_ANDROID_TOOLBAR_TOOLBAR_MODEL_ANDROID_H_ 6 #define CHROME_BROWSER_UI_ANDROID_TOOLBAR_TOOLBAR_MODEL_ANDROID_H_ 7 8 #include "base/android/jni_android.h" 9 #include "base/android/jni_weak_ref.h" 10 #include "base/android/scoped_java_ref.h" 11 #include "base/basictypes.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "chrome/browser/ui/toolbar/toolbar_model.h" 14 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h" 15 16 namespace content { 17 class WebContents; 18 } // content 19 20 // Owns a ToolbarModel and provides a way for Java to interact with it. 21 class ToolbarModelAndroid : public ToolbarModelDelegate { 22 public: 23 explicit ToolbarModelAndroid(JNIEnv* env, jobject jdelegate); 24 virtual ~ToolbarModelAndroid(); 25 26 void Destroy(JNIEnv* env, jobject obj); 27 base::android::ScopedJavaLocalRef<jstring> GetText( 28 JNIEnv* env, 29 jobject obj); 30 base::android::ScopedJavaLocalRef<jstring> GetQueryExtractionParam( 31 JNIEnv* env, 32 jobject obj); 33 base::android::ScopedJavaLocalRef<jstring> GetCorpusChipText( 34 JNIEnv* env, 35 jobject obj); 36 37 // ToolbarDelegate: 38 virtual content::WebContents* GetActiveWebContents() const OVERRIDE; 39 virtual bool InTabbedBrowser() const OVERRIDE; 40 41 static bool RegisterToolbarModelAndroid(JNIEnv* env); 42 43 private: 44 scoped_ptr<ToolbarModel> toolbar_model_; 45 JavaObjectWeakGlobalRef weak_java_delegate_; 46 47 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarModelAndroid); 48 }; 49 50 #endif // CHROME_BROWSER_UI_ANDROID_TOOLBAR_TOOLBAR_MODEL_ANDROID_H_ 51