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

Side by Side Diff: content/browser/android/context_selection_client.h

Issue 2740103006: Implement SmartText selection. (Closed)
Patch Set: Made ~ContextSelectionClient() public and inlined SelectionPopupControler.unhideActionMode() Created 3 years, 8 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
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/android/context_selection_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 CONTENT_BROWSER_ANDROID_CONTEXT_SELECTION_CLIENT_H_
6 #define CONTENT_BROWSER_ANDROID_CONTEXT_SELECTION_CLIENT_H_
7
8 #include <jni.h>
9
10 #include "base/android/jni_weak_ref.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14
15 namespace content {
16
17 class WebContents;
18
19 // The native portion of Java ContextSelectionClient.
20 // This class performs one operation: retrieves the selected text together with
21 // its surrounding context from WebContents. This surrounding text is obtained
22 // asynchronously from the current focused frame and passed back to Java layer.
23 class ContextSelectionClient {
24 public:
25 ContextSelectionClient(JNIEnv* env,
26 const base::android::JavaRef<jobject>& obj,
27 WebContents* web_contents);
28 ~ContextSelectionClient();
29
30 // Sends asynchronius request to retrieve the text.
31 void RequestSurroundingText(JNIEnv* env,
32 const base::android::JavaParamRef<jobject>& obj,
33 int num_extra_characters,
34 int callback_data);
35
36 // Cancels all pending requests.
37 void CancelAllRequests(JNIEnv* env,
38 const base::android::JavaParamRef<jobject>& obj);
39
40 private:
41 void OnSurroundingTextReceived(int callback_data,
42 const base::string16& text,
43 int start,
44 int end);
45
46 // A weak reference to the Java ContentSelectionClient object.
47 JavaObjectWeakGlobalRef java_ref_;
48
49 // WebContents is used to find the relevant RenderFrameHost that can send
50 // the request for the text.
51 WebContents* web_contents_;
52
53 base::WeakPtrFactory<ContextSelectionClient> weak_ptr_factory_;
54
55 DISALLOW_COPY_AND_ASSIGN(ContextSelectionClient);
56 };
57
58 bool RegisterContextSelectionClient(JNIEnv* env);
59
60 } // namespace content
61
62 #endif // CONTENT_BROWSER_ANDROID_CONTEXT_SELECTION_CLIENT_H_
OLDNEW
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/browser/android/context_selection_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698