Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/android/contextualsearch/contextual_search_manager.h

Issue 1532743002: [Contextual Search] Use Mojo API for Quick Answers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed methods all the way through to our component. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_
6 #define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_ 6 #define CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/task/cancelable_task_tracker.h" 12 #include "base/task/cancelable_task_tracker.h"
13 #include "chrome/browser/android/contextualsearch/contextual_search_context.h" 13 #include "chrome/browser/android/contextualsearch/contextual_search_context.h"
14 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" 14 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h"
15 #include "components/contextual_search/browser/contextual_search_js_api_handler. h"
15 16
16 // Manages the native extraction and request logic for Contextual Search, 17 // Manages the native extraction and request logic for Contextual Search,
17 // and interacts with the Java ContextualSearchManager for UX. 18 // and interacts with the Java ContextualSearchManager for UX.
18 // Most of the work is done by the associated ContextualSearchDelegate. 19 // Most of the work is done by the associated ContextualSearchDelegate.
19 class ContextualSearchManager { 20 class ContextualSearchManager
21 : public contextual_search::ContextualSearchJsApiHandler {
20 public: 22 public:
21 // Constructs a native manager associated with the Java manager. 23 // Constructs a native manager associated with the Java manager.
22 ContextualSearchManager(JNIEnv* env, jobject obj); 24 ContextualSearchManager(JNIEnv* env, jobject obj);
23 virtual ~ContextualSearchManager(); 25 ~ContextualSearchManager() override;
24 26
25 // Called by the Java ContextualSearchManager when it is being destroyed. 27 // Called by the Java ContextualSearchManager when it is being destroyed.
26 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 28 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
27 29
28 // Starts the request to get the search terms to use for the given selection, 30 // Starts the request to get the search terms to use for the given selection,
29 // by accessing our server with the content of the page (from the given 31 // by accessing our server with the content of the page (from the given
30 // content view core object). 32 // content view core object).
31 // Any outstanding server requests are canceled. 33 // Any outstanding server requests are canceled.
32 // When the server responds with the search term, the Java object is notified 34 // When the server responds with the search term, the Java object is notified
33 // by 35 // by
(...skipping 19 matching lines...) Expand all
53 // Gets the target language for translation purposes. 55 // Gets the target language for translation purposes.
54 base::android::ScopedJavaLocalRef<jstring> GetTargetLanguage( 56 base::android::ScopedJavaLocalRef<jstring> GetTargetLanguage(
55 JNIEnv* env, 57 JNIEnv* env,
56 const base::android::JavaParamRef<jobject>& obj); 58 const base::android::JavaParamRef<jobject>& obj);
57 59
58 // Gets the accept-languages preference string. 60 // Gets the accept-languages preference string.
59 base::android::ScopedJavaLocalRef<jstring> GetAcceptLanguages( 61 base::android::ScopedJavaLocalRef<jstring> GetAcceptLanguages(
60 JNIEnv* env, 62 JNIEnv* env,
61 const base::android::JavaParamRef<jobject>& obj); 63 const base::android::JavaParamRef<jobject>& obj);
62 64
65 // Enables the Contextual Search JS API for the given |ContentViewCore|.
66 void AddViewForContextualSearchJsApi(JNIEnv* env,
mdjones 2016/01/09 00:59:38 I would consider renaming to something like "enabl
Donn Denman 2016/01/11 20:31:34 Done.
67 jobject obj,
68 jobject j_overlay_content_view_core);
69
70 // ContextualSearchJsApiHandler overrides:
71 void SetCaption(std::string caption, bool does_answer) override;
72
63 private: 73 private:
64 void OnSearchTermResolutionResponse( 74 void OnSearchTermResolutionResponse(
65 const ResolvedSearchTerm& resolved_search_term); 75 const ResolvedSearchTerm& resolved_search_term);
66 76
67 // Calls back to Java with the surrounding text to be displayed. 77 // Calls back to Java with the surrounding text to be displayed.
68 void OnSurroundingTextAvailable(const std::string& after_text); 78 void OnSurroundingTextAvailable(const std::string& after_text);
69 79
70 // Calls back to Java with notification for Icing selection. 80 // Calls back to Java with notification for Icing selection.
71 void OnIcingSelectionAvailable(const std::string& encoding, 81 void OnIcingSelectionAvailable(const std::string& encoding,
72 const base::string16& surrounding_text, 82 const base::string16& surrounding_text,
73 size_t start_offset, 83 size_t start_offset,
74 size_t end_offset); 84 size_t end_offset);
75 85
76 // Our global reference to the Java ContextualSearchManager. 86 // Our global reference to the Java ContextualSearchManager.
77 base::android::ScopedJavaGlobalRef<jobject> java_manager_; 87 base::android::ScopedJavaGlobalRef<jobject> java_manager_;
78 88
79 // The delegate we're using the do the real work. 89 // The delegate we're using the do the real work.
80 scoped_ptr<ContextualSearchDelegate> delegate_; 90 scoped_ptr<ContextualSearchDelegate> delegate_;
81 91
82 DISALLOW_COPY_AND_ASSIGN(ContextualSearchManager); 92 DISALLOW_COPY_AND_ASSIGN(ContextualSearchManager);
83 }; 93 };
84 94
85 bool RegisterContextualSearchManager(JNIEnv* env); 95 bool RegisterContextualSearchManager(JNIEnv* env);
86 96
87 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_ 97 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/contextualsearch/DEPS ('k') | chrome/browser/android/contextualsearch/contextual_search_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698