OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ | 5 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ |
6 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ | 6 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "remoting/client/host_connection.h" | 12 #include "remoting/client/host_connection.h" |
13 #include "remoting/client/pepper/pepper_plugin.h" | |
14 #include "testing/gtest/include/gtest/gtest_prod.h" | 13 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 14 #include "third_party/ppapi/cpp/device_context_2d.h" |
| 15 #include "third_party/ppapi/cpp/instance.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class Thread; | 18 class Thread; |
18 } // namespace base | 19 } // namespace base |
19 | 20 |
20 namespace remoting { | 21 namespace remoting { |
21 | 22 |
22 class ChromotingClient; | 23 class ChromotingClient; |
23 class HostConnection; | 24 class HostConnection; |
24 class JingleThread; | 25 class JingleThread; |
25 class PepperView; | 26 class PepperView; |
26 | 27 |
27 class ChromotingClient; | 28 class ChromotingClient; |
28 | 29 |
29 class ChromotingPlugin : public pepper::PepperPlugin { | 30 class ChromotingPlugin : public pp::Instance { |
30 public: | 31 public: |
31 // The mimetype for which this plugin is registered. | 32 // The mimetype for which this plugin is registered. |
32 // | 33 // |
33 // TODO(ajwong): Mimetype doesn't really make sense for us as the trigger | 34 // TODO(ajwong): Mimetype doesn't really make sense for us as the trigger |
34 // point. I think we should handle a special protocol (eg., chromotocol://) | 35 // point. I think we should handle a special protocol (eg., chromotocol://) |
35 static const char *kMimeType; | 36 static const char *kMimeType; |
36 | 37 |
37 ChromotingPlugin(NPNetscapeFuncs* browser_funcs, NPP instance); | 38 ChromotingPlugin(PP_Instance instance); |
38 virtual ~ChromotingPlugin(); | 39 virtual ~ChromotingPlugin(); |
39 | 40 |
40 // PepperPlugin implementation. | 41 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); |
41 virtual NPError New(NPMIMEType pluginType, int16 argc, char* argn[], | 42 virtual bool HandleEvent(const PP_Event& event); |
42 char* argv[]); | 43 virtual void ViewChanged(const PP_Rect& position, const PP_Rect& clip); |
43 virtual NPError Destroy(NPSavedData** save); | |
44 virtual NPError SetWindow(NPWindow* window); | |
45 virtual int16 HandleEvent(void* event); | |
46 virtual NPError GetValue(NPPVariable variable, void* value); | |
47 virtual NPError SetValue(NPNVariable variable, void* value); | |
48 | 44 |
49 private: | 45 private: |
50 FRIEND_TEST(ChromotingPluginTest, ParseUrl); | 46 FRIEND_TEST(ChromotingPluginTest, ParseUrl); |
51 FRIEND_TEST(ChromotingPluginTest, TestCaseSetup); | 47 FRIEND_TEST(ChromotingPluginTest, TestCaseSetup); |
52 | 48 |
53 NPDevice* device() { return device_; } | |
54 | |
55 static bool ParseUrl(const std::string& url, | 49 static bool ParseUrl(const std::string& url, |
56 std::string* user_id, | 50 std::string* user_id, |
57 std::string* auth_token, | 51 std::string* auth_token, |
58 std::string* host_jid); | 52 std::string* host_jid); |
59 | 53 |
60 // Size of the plugin window. | 54 // Size of the plugin window. |
61 int width_, height_; | 55 int width_; |
| 56 int height_; |
62 | 57 |
63 // Rendering device provided by browser. | 58 pp::DeviceContext2D device_context_; |
64 NPDevice* device_; | |
65 | |
66 // Since the ChromotingPlugin's lifetime is conceptually the lifetime of the | |
67 // object, use it to control running of atexit() calls. | |
68 // | |
69 // TODO(ajwong): Should this be moved into PepperPlugin? Or maybe even | |
70 // higher? | |
71 // | |
72 // TODO(ajwong): This causes unittests to fail so commenting out for now. We | |
73 // need to understand process instantiation better. This may also be a | |
74 // non-issue when we are no longer being loaded as a DSO. | |
75 // | |
76 // base::AtExitManager at_exit_manager_; | |
77 | 59 |
78 scoped_ptr<base::Thread> main_thread_; | 60 scoped_ptr<base::Thread> main_thread_; |
79 scoped_ptr<JingleThread> network_thread_; | 61 scoped_ptr<JingleThread> network_thread_; |
80 | 62 |
81 scoped_ptr<HostConnection> host_connection_; | 63 scoped_ptr<HostConnection> host_connection_; |
82 scoped_ptr<PepperView> view_; | 64 scoped_ptr<PepperView> view_; |
83 scoped_ptr<ChromotingClient> client_; | 65 scoped_ptr<ChromotingClient> client_; |
84 | 66 |
85 DISALLOW_COPY_AND_ASSIGN(ChromotingPlugin); | 67 DISALLOW_COPY_AND_ASSIGN(ChromotingPlugin); |
86 }; | 68 }; |
87 | 69 |
88 } // namespace remoting | 70 } // namespace remoting |
89 | 71 |
90 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ | 72 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_PLUGIN_H_ |
OLD | NEW |