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

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

Issue 1283223004: Contextual Search Panel should own ContentViewCore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Override wrappers instead of native Created 5 years, 4 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 "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/task/cancelable_task_tracker.h" 9 #include "base/task/cancelable_task_tracker.h"
10 #include "chrome/browser/android/contextualsearch/contextual_search_context.h" 10 #include "chrome/browser/android/contextualsearch/contextual_search_context.h"
11 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" 11 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h"
12 12
13 namespace content {
14 class WebContents;
15 } // namespace content
16
17 namespace web_contents_delegate_android {
18 class WebContentsDelegateAndroid;
19 } // namespace web_contents_delegate_android
20
21 // Manages the native extraction and request logic for Contextual Search, 13 // Manages the native extraction and request logic for Contextual Search,
22 // and interacts with the Java ContextualSearchManager for UX. 14 // and interacts with the Java ContextualSearchManager for UX.
23 // Most of the work is done by the associated ContextualSearchDelegate. 15 // Most of the work is done by the associated ContextualSearchDelegate.
24 class ContextualSearchManager { 16 class ContextualSearchManager {
25 public: 17 public:
26 // Constructs a native manager associated with the Java manager. 18 // Constructs a native manager associated with the Java manager.
27 ContextualSearchManager(JNIEnv* env, jobject obj); 19 ContextualSearchManager(JNIEnv* env, jobject obj);
28 virtual ~ContextualSearchManager(); 20 virtual ~ContextualSearchManager();
29 21
30 // Called by the Java ContextualSearchManager when it is being destroyed. 22 // Called by the Java ContextualSearchManager when it is being destroyed.
(...skipping 16 matching lines...) Expand all
47 39
48 // Gathers the surrounding text around the selection and saves it locally. 40 // Gathers the surrounding text around the selection and saves it locally.
49 // Does not send a search term resolution request to the server. 41 // Does not send a search term resolution request to the server.
50 void GatherSurroundingText(JNIEnv* env, 42 void GatherSurroundingText(JNIEnv* env,
51 jobject obj, 43 jobject obj,
52 jstring j_selection, 44 jstring j_selection,
53 jboolean j_use_resolved_search_term, 45 jboolean j_use_resolved_search_term,
54 jobject j_base_content_view_core, 46 jobject j_base_content_view_core,
55 jboolean j_may_send_base_page_url); 47 jboolean j_may_send_base_page_url);
56 48
57 // Removes a search URL from history. |search_start_time_ms| represents the
58 // time at which |search_url| was committed.
59 void RemoveLastSearchVisit(JNIEnv* env,
60 jobject obj,
61 jstring search_url,
62 jlong search_start_time_ms);
63
64 // Takes ownership of the WebContents associated with the given
65 // |ContentViewCore| which holds the Contextual Search Results.
66 void SetWebContents(JNIEnv* env, jobject obj, jobject jcontent_view_core,
67 jobject jweb_contents_delegate);
68
69 // Destroys the WebContents.
70 void DestroyWebContents(JNIEnv* env, jobject jobj);
71
72 // Release ownership of WebContents.
73 void ReleaseWebContents(JNIEnv* env, jobject jobj);
74
75 // Destroys the WebContents of a ContentViewCore.
76 void DestroyWebContentsFromContentViewCore(JNIEnv* env,
77 jobject jobj,
78 jobject jcontent_view_core);
79
80 // Sets the delegate used to convert navigations to intents.
81 void SetInterceptNavigationDelegate(JNIEnv* env,
82 jobject obj,
83 jobject delegate,
84 jobject jweb_contents);
85
86 private: 49 private:
87 // TODO(donnd): encapsulate these response parameters? 50 // TODO(donnd): encapsulate these response parameters?
88 void OnSearchTermResolutionResponse(bool is_invalid, 51 void OnSearchTermResolutionResponse(bool is_invalid,
89 int response_code, 52 int response_code,
90 const std::string& search_term, 53 const std::string& search_term,
91 const std::string& display_text, 54 const std::string& display_text,
92 const std::string& alternate_term, 55 const std::string& alternate_term,
93 bool prevent_preload, 56 bool prevent_preload,
94 int selection_start_adjust, 57 int selection_start_adjust,
95 int selection_end_adjust); 58 int selection_end_adjust);
96 59
97 // Calls back to Java with the surrounding text to be displayed. 60 // Calls back to Java with the surrounding text to be displayed.
98 void OnSurroundingTextAvailable(const std::string& before_text, 61 void OnSurroundingTextAvailable(const std::string& before_text,
99 const std::string& after_text); 62 const std::string& after_text);
100 63
101 // Calls back to Java with notification for Icing selection. 64 // Calls back to Java with notification for Icing selection.
102 void OnIcingSelectionAvailable(const std::string& encoding, 65 void OnIcingSelectionAvailable(const std::string& encoding,
103 const base::string16& surrounding_text, 66 const base::string16& surrounding_text,
104 size_t start_offset, 67 size_t start_offset,
105 size_t end_offset); 68 size_t end_offset);
106 69
107 // Our global reference to the Java ContextualSearchManager. 70 // Our global reference to the Java ContextualSearchManager.
108 base::android::ScopedJavaGlobalRef<jobject> java_manager_; 71 base::android::ScopedJavaGlobalRef<jobject> java_manager_;
109 72
110 // The delegate we're using the do the real work. 73 // The delegate we're using the do the real work.
111 scoped_ptr<ContextualSearchDelegate> delegate_; 74 scoped_ptr<ContextualSearchDelegate> delegate_;
112 75
113 // Used if we need to clear history.
114 base::CancelableTaskTracker history_task_tracker_;
115
116 // The WebContents that holds the Contextual Search Results.
117 scoped_ptr<content::WebContents> web_contents_;
118 scoped_ptr<web_contents_delegate_android::WebContentsDelegateAndroid>
119 web_contents_delegate_;
120
121 DISALLOW_COPY_AND_ASSIGN(ContextualSearchManager); 76 DISALLOW_COPY_AND_ASSIGN(ContextualSearchManager);
122 }; 77 };
123 78
124 bool RegisterContextualSearchManager(JNIEnv* env); 79 bool RegisterContextualSearchManager(JNIEnv* env);
125 80
126 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_ 81 #endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/chrome_jni_registrar.cc ('k') | chrome/browser/android/contextualsearch/contextual_search_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698