Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / spellchecker / spellchecker_session_bridge_android.h
blob23353bb8b6bd1820d9cd2c5871a00534f63be712
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_
8 #include <jni.h>
10 #include "base/android/scoped_java_ref.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
14 // A class used to interface between the Java class of the same name and the
15 // android message filter. This class receives text to be spellchecked
16 // from the message filter, sends that text to the Java side via JNI to be
17 // spellchecked, and then sends those results to the renderer.
18 class SpellCheckerSessionBridge {
19 public:
20 explicit SpellCheckerSessionBridge(int render_process_id);
21 ~SpellCheckerSessionBridge();
22 static bool RegisterJNI(JNIEnv* env);
24 // Receives text to be checked from the message filter and sends it to Java
25 // to be spellchecked.
26 void RequestTextCheck(int route_id,
27 int identifier,
28 const base::string16& text);
30 // Receives information from Java side about the typos in a given string
31 // of text, processes these and sends them to the renderer.
32 void ProcessSpellCheckResults(JNIEnv* env,
33 jobject jobj,
34 jintArray offset_array,
35 jintArray length_array);
37 // Sets the handle to the Java SpellCheckerSessionBridge object to null,
38 // marking the Java object for garbage collection.
39 void DisconnectSession();
41 private:
42 struct SpellingRequest {
43 SpellingRequest(int route_id, int identifier, const base::string16& text);
44 ~SpellingRequest();
46 int route_id;
47 int identifier;
48 base::string16 text;
51 int render_process_id_;
53 scoped_ptr<SpellingRequest> active_request_;
54 scoped_ptr<SpellingRequest> pending_request_;
56 base::android::ScopedJavaGlobalRef<jobject> java_object_;
57 bool java_object_initialization_failed_;
59 DISALLOW_COPY_AND_ASSIGN(SpellCheckerSessionBridge);
62 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_