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_manager.h" | 5 #include "chrome/browser/android/contextualsearch/contextual_search_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" | 13 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" |
14 #include "chrome/browser/android/contextualsearch/resolved_search_term.h" | 14 #include "chrome/browser/android/contextualsearch/resolved_search_term.h" |
15 #include "chrome/browser/android/tab_android.h" | 15 #include "chrome/browser/android/tab_android.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
18 #include "components/contextual_search/browser/contextual_search_js_api_service_
impl.h" | 18 #include "components/contextual_search/browser/contextual_search_js_api_service_
impl.h" |
19 #include "components/contextual_search/common/overlay_page_notifier_service.mojo
m.h" | 19 #include "components/contextual_search/common/overlay_page_notifier_service.mojo
m.h" |
20 #include "components/navigation_interception/intercept_navigation_delegate.h" | 20 #include "components/navigation_interception/intercept_navigation_delegate.h" |
21 #include "components/variations/variations_associated_data.h" | 21 #include "components/variations/variations_associated_data.h" |
22 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
25 #include "jni/ContextualSearchManager_jni.h" | 25 #include "jni/ContextualSearchManager_jni.h" |
26 #include "net/url_request/url_fetcher_impl.h" | 26 #include "net/url_request/url_fetcher_impl.h" |
27 #include "services/shell/public/cpp/interface_provider.h" | 27 #include "services/shell/public/cpp/interface_provider.h" |
28 #include "services/shell/public/cpp/interface_registry.h" | 28 #include "services/shell/public/cpp/interface_registry.h" |
29 | 29 |
| 30 using base::android::JavaParamRef; |
30 using content::WebContents; | 31 using content::WebContents; |
31 | 32 |
32 // This class manages the native behavior of the Contextual Search feature. | 33 // This class manages the native behavior of the Contextual Search feature. |
33 // Instances of this class are owned by the Java ContextualSearchManager. | 34 // Instances of this class are owned by the Java ContextualSearchManager. |
34 // Most of the work is actually done in an associated delegate to this class: | 35 // Most of the work is actually done in an associated delegate to this class: |
35 // the ContextualSearchDelegate. | 36 // the ContextualSearchDelegate. |
36 ContextualSearchManager::ContextualSearchManager(JNIEnv* env, jobject obj) { | 37 ContextualSearchManager::ContextualSearchManager(JNIEnv* env, jobject obj) { |
37 java_manager_.Reset(env, obj); | 38 java_manager_.Reset(env, obj); |
38 Java_ContextualSearchManager_setNativeManager( | 39 Java_ContextualSearchManager_setNativeManager( |
39 env, obj, reinterpret_cast<intptr_t>(this)); | 40 env, obj, reinterpret_cast<intptr_t>(this)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 201 } |
201 | 202 |
202 void ContextualSearchManager::SetCaption(std::string caption, | 203 void ContextualSearchManager::SetCaption(std::string caption, |
203 bool does_answer) { | 204 bool does_answer) { |
204 JNIEnv* env = base::android::AttachCurrentThread(); | 205 JNIEnv* env = base::android::AttachCurrentThread(); |
205 base::android::ScopedJavaLocalRef<jstring> j_caption = | 206 base::android::ScopedJavaLocalRef<jstring> j_caption = |
206 base::android::ConvertUTF8ToJavaString(env, caption.c_str()); | 207 base::android::ConvertUTF8ToJavaString(env, caption.c_str()); |
207 Java_ContextualSearchManager_onSetCaption(env, java_manager_.obj(), | 208 Java_ContextualSearchManager_onSetCaption(env, java_manager_.obj(), |
208 j_caption.obj(), does_answer); | 209 j_caption.obj(), does_answer); |
209 } | 210 } |
OLD | NEW |