OLD | NEW |
(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 "content/public/browser/web_contents.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 class WebContents; |
| 18 |
| 19 class ContextSelectionClient { |
| 20 public: |
| 21 ContextSelectionClient(JNIEnv* env, |
| 22 const base::android::JavaRef<jobject>& obj, |
| 23 WebContents* web_contents); |
| 24 ~ContextSelectionClient(); |
| 25 |
| 26 void RequestSurroundingText(JNIEnv* env, |
| 27 const base::android::JavaParamRef<jobject>& obj, |
| 28 int callback_data); |
| 29 void CancelAllRequests(JNIEnv* env, |
| 30 const base::android::JavaParamRef<jobject>& obj); |
| 31 |
| 32 private: |
| 33 class UserData; |
| 34 |
| 35 void OnSurroundingTextReceived(int callback_data, |
| 36 const base::string16& text, |
| 37 int start, |
| 38 int end); |
| 39 |
| 40 // A weak reference to the Java ContentSelectionClient object. |
| 41 JavaObjectWeakGlobalRef java_ref_; |
| 42 |
| 43 // WebContents is used to find the relevant RenderFrameHost that can send |
| 44 // the request for the text. |
| 45 WebContents* web_contents_; |
| 46 |
| 47 base::WeakPtrFactory<ContextSelectionClient> weak_ptr_factory_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(ContextSelectionClient); |
| 50 }; |
| 51 |
| 52 bool RegisterContextSelectionClient(JNIEnv* env); |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_BROWSER_ANDROID_CONTEXT_SELECTION_CLIENT_H_ |
OLD | NEW |