Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / remoting / client / jni / chromoting_jni_instance.h
index fdb5a4f..ce572fc 100644 (file)
 #include "base/memory/weak_ptr.h"
 #include "base/message_loop/message_loop.h"
 #include "remoting/client/chromoting_client.h"
-#include "remoting/client/client_config.h"
 #include "remoting/client/client_context.h"
 #include "remoting/client/client_user_interface.h"
 #include "remoting/client/frame_consumer_proxy.h"
 #include "remoting/client/jni/jni_frame_consumer.h"
-#include "remoting/jingle_glue/xmpp_signal_strategy.h"
 #include "remoting/protocol/clipboard_stub.h"
-#include "remoting/protocol/connection_to_host.h"
 #include "remoting/protocol/cursor_shape_stub.h"
+#include "remoting/signaling/xmpp_signal_strategy.h"
 
 namespace remoting {
 
@@ -29,7 +27,9 @@ class ClipboardEvent;
 class CursorShapeInfo;
 }  // namespace protocol
 
+class ClientStatusLogger;
 class VideoRenderer;
+class TokenFetcherProxy;
 
 // ClientUserInterface that indirectly makes and receives JNI calls.
 class ChromotingJniInstance
@@ -48,30 +48,46 @@ class ChromotingJniInstance
                         const char* host_id,
                         const char* host_pubkey,
                         const char* pairing_id,
-                        const char* pairing_secret);
+                        const char* pairing_secret,
+                        const char* capabilities);
 
   // Terminates the current connection (if it hasn't already failed) and cleans
   // up. Must be called before destruction.
-  void Cleanup();
+  void Disconnect();
+
+  // Requests the android app to fetch a third-party token.
+  void FetchThirdPartyToken(
+      const GURL& token_url,
+      const std::string& client_id,
+      const std::string& scope,
+      const base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy);
+
+  // Called by the android app when the token is fetched.
+  void HandleOnThirdPartyTokenFetched(const std::string& token,
+                                      const std::string& shared_secret);
 
   // Provides the user's PIN and resumes the host authentication attempt. Call
   // on the UI thread once the user has finished entering this PIN into the UI,
   // but only after the UI has been asked to provide a PIN (via FetchSecret()).
-  void ProvideSecret(const std::string& pin, bool create_pair);
+  void ProvideSecret(const std::string& pin, bool create_pair,
+                     const std::string& device_name);
 
   // Schedules a redraw on the display thread. May be called from any thread.
   void RedrawDesktop();
 
   // Moves the host's cursor to the specified coordinates, optionally with some
   // mouse button depressed. If |button| is BUTTON_UNDEFINED, no click is made.
-  void PerformMouseAction(int x, int y,
-                          protocol::MouseEvent_MouseButton button,
-                          bool button_down);
-
-  void PerformMouseWheelDeltaAction(int delta_x, int delta_y);
+  void SendMouseEvent(int x, int y,
+                      protocol::MouseEvent_MouseButton button,
+                      bool button_down);
+  void SendMouseWheelEvent(int delta_x, int delta_y);
 
   // Sends the provided keyboard scan code to the host.
-  void PerformKeyboardAction(int key_code, bool key_down);
+  bool SendKeyEvent(int key_code, bool key_down);
+
+  void SendTextEvent(const std::string& text);
+
+  void SendClientMessage(const std::string& type, const std::string& data);
 
   // Records paint time for statistics logging, if enabled. May be called from
   // any thread.
@@ -91,8 +107,6 @@ class ChromotingJniInstance
       const protocol::ExtensionMessage& message) OVERRIDE;
   virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE;
   virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE;
-  virtual scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
-      GetTokenFetcher(const std::string& host_public_key) OVERRIDE;
 
   // CursorShapeStub implementation.
   virtual void InjectClipboardEvent(
@@ -115,6 +129,11 @@ class ChromotingJniInstance
   void FetchSecret(bool pairable,
                    const protocol::SecretFetchedCallback& callback);
 
+  // Sets the device name. Can be called on any thread.
+  void SetDeviceName(const std::string& device_name);
+
+  void SendKeyEventInternal(int usb_key_code, bool key_down);
+
   // Enables or disables periodic logging of performance statistics. Called on
   // the network thread.
   void EnableStatsLogging(bool enabled);
@@ -129,6 +148,7 @@ class ChromotingJniInstance
 
   // ID of the host we are connecting to.
   std::string host_id_;
+  std::string host_jid_;
 
   // This group of variables is to be used on the display thread.
   scoped_refptr<FrameConsumerProxy> frame_consumer_;
@@ -136,13 +156,14 @@ class ChromotingJniInstance
   scoped_ptr<base::WeakPtrFactory<JniFrameConsumer> > view_weak_factory_;
 
   // This group of variables is to be used on the network thread.
-  ClientConfig client_config_;
   scoped_ptr<ClientContext> client_context_;
   scoped_ptr<VideoRenderer> video_renderer_;
-  scoped_ptr<protocol::ConnectionToHost> connection_;
+  scoped_ptr<protocol::Authenticator> authenticator_;
   scoped_ptr<ChromotingClient> client_;
   XmppSignalStrategy::XmppServerConfig xmpp_config_;
   scoped_ptr<XmppSignalStrategy> signaling_;  // Must outlive client_
+  scoped_ptr<ClientStatusLogger> client_status_logger_;
+  base::WeakPtr<TokenFetcherProxy> token_fetcher_proxy_;
 
   // Pass this the user's PIN once we have it. To be assigned and accessed on
   // the UI thread, but must be posted to the network thread to call it.
@@ -154,12 +175,23 @@ class ChromotingJniInstance
   // once per run, and always before any reference to this flag.)
   bool create_pairing_;
 
+  // The device name to appear in the paired-clients list. Accessed on the
+  // network thread.
+  std::string device_name_;
+
   // If this is true, performance statistics will be periodically written to
   // the Android log. Used on the network thread.
   bool stats_logging_enabled_;
 
+  // The set of capabilities supported by the client. Accessed on the network
+  // thread. Once SetCapabilities() is called, this will contain the negotiated
+  // set of capabilities for this remoting session.
+  std::string capabilities_;
+
   friend class base::RefCountedThreadSafe<ChromotingJniInstance>;
 
+  base::WeakPtrFactory<ChromotingJniInstance> weak_factory_;
+
   DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance);
 };