| 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/contextual_search_field_trial.
h" |
| 14 #include "chrome/browser/android/contextualsearch/resolved_search_term.h" | 15 #include "chrome/browser/android/contextualsearch/resolved_search_term.h" |
| 15 #include "chrome/browser/android/tab_android.h" | 16 #include "chrome/browser/android/tab_android.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 18 #include "components/contextual_search/browser/contextual_search_js_api_service_
impl.h" | 19 #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" | 20 #include "components/contextual_search/common/overlay_page_notifier_service.mojo
m.h" |
| 20 #include "components/navigation_interception/intercept_navigation_delegate.h" | 21 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 21 #include "components/variations/variations_associated_data.h" | 22 #include "components/variations/variations_associated_data.h" |
| 22 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 23 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 env, obj, reinterpret_cast<intptr_t>(this)); | 43 env, obj, reinterpret_cast<intptr_t>(this)); |
| 43 Profile* profile = ProfileManager::GetActiveUserProfile(); | 44 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 44 delegate_.reset(new ContextualSearchDelegate( | 45 delegate_.reset(new ContextualSearchDelegate( |
| 45 profile->GetRequestContext(), | 46 profile->GetRequestContext(), |
| 46 TemplateURLServiceFactory::GetForProfile(profile), | 47 TemplateURLServiceFactory::GetForProfile(profile), |
| 47 base::Bind(&ContextualSearchManager::OnSearchTermResolutionResponse, | 48 base::Bind(&ContextualSearchManager::OnSearchTermResolutionResponse, |
| 48 base::Unretained(this)), | 49 base::Unretained(this)), |
| 49 base::Bind(&ContextualSearchManager::OnSurroundingTextAvailable, | 50 base::Bind(&ContextualSearchManager::OnSurroundingTextAvailable, |
| 50 base::Unretained(this)), | 51 base::Unretained(this)), |
| 51 base::Bind(&ContextualSearchManager::OnIcingSelectionAvailable, | 52 base::Bind(&ContextualSearchManager::OnIcingSelectionAvailable, |
| 52 base::Unretained(this)))); | 53 base::Unretained(this)), |
| 54 std::unique_ptr<ContextualSearchFieldTrial>( |
| 55 new ContextualSearchFieldTrial()))); |
| 53 } | 56 } |
| 54 | 57 |
| 55 ContextualSearchManager::~ContextualSearchManager() { | 58 ContextualSearchManager::~ContextualSearchManager() { |
| 56 JNIEnv* env = base::android::AttachCurrentThread(); | 59 JNIEnv* env = base::android::AttachCurrentThread(); |
| 57 Java_ContextualSearchManager_clearNativeManager(env, java_manager_); | 60 Java_ContextualSearchManager_clearNativeManager(env, java_manager_); |
| 58 } | 61 } |
| 59 | 62 |
| 60 void ContextualSearchManager::Destroy(JNIEnv* env, | 63 void ContextualSearchManager::Destroy(JNIEnv* env, |
| 61 const JavaParamRef<jobject>& obj) { | 64 const JavaParamRef<jobject>& obj) { |
| 62 delete this; | 65 delete this; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 222 } |
| 220 | 223 |
| 221 void ContextualSearchManager::SetCaption(std::string caption, | 224 void ContextualSearchManager::SetCaption(std::string caption, |
| 222 bool does_answer) { | 225 bool does_answer) { |
| 223 JNIEnv* env = base::android::AttachCurrentThread(); | 226 JNIEnv* env = base::android::AttachCurrentThread(); |
| 224 base::android::ScopedJavaLocalRef<jstring> j_caption = | 227 base::android::ScopedJavaLocalRef<jstring> j_caption = |
| 225 base::android::ConvertUTF8ToJavaString(env, caption.c_str()); | 228 base::android::ConvertUTF8ToJavaString(env, caption.c_str()); |
| 226 Java_ContextualSearchManager_onSetCaption(env, java_manager_, j_caption, | 229 Java_ContextualSearchManager_onSetCaption(env, java_manager_, j_caption, |
| 227 does_answer); | 230 does_answer); |
| 228 } | 231 } |
| OLD | NEW |