OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ |
6 #define CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 | 14 |
| 15 #if defined(OS_ANDROID) |
| 16 #include "base/android/scoped_java_ref.h" |
| 17 #endif |
| 18 |
15 namespace content { | 19 namespace content { |
16 | |
17 class AppWebMessagePortService; | |
18 class WebContents; | 20 class WebContents; |
19 | 21 |
20 // An interface consisting of methods that can be called to use Message ports. | 22 // An interface consisting of methods that can be called to use Message ports. |
21 class CONTENT_EXPORT MessagePortProvider { | 23 class CONTENT_EXPORT MessagePortProvider { |
22 public: | 24 public: |
23 // Posts a MessageEvent to the main frame using the given source and target | 25 // Posts a MessageEvent to the main frame using the given source and target |
24 // origins and data. The caller may also provide any message port ids as | 26 // origins and data. |
25 // part of the message. | |
26 // See https://html.spec.whatwg.org/multipage/comms.html#messageevent for | 27 // See https://html.spec.whatwg.org/multipage/comms.html#messageevent for |
27 // further information on message events. | 28 // further information on message events. |
28 // Should be called on UI thread. | 29 // Should be called on UI thread. |
29 static void PostMessageToFrame( | 30 static void PostMessageToFrame( |
30 WebContents* web_contents, | 31 WebContents* web_contents, |
31 const base::string16& source_origin, | 32 const base::string16& source_origin, |
32 const base::string16& target_origin, | 33 const base::string16& target_origin, |
33 const base::string16& data, | 34 const base::string16& data); |
34 const std::vector<int>& ports); | |
35 | 35 |
36 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
37 static content::AppWebMessagePortService* GetAppWebMessagePortService(); | 37 static void PostMessageToFrame( |
| 38 WebContents* web_contents, |
| 39 JNIEnv* env, |
| 40 const base::android::JavaParamRef<jstring>& source_origin, |
| 41 const base::android::JavaParamRef<jstring>& target_origin, |
| 42 const base::android::JavaParamRef<jstring>& data, |
| 43 const base::android::JavaParamRef<jobjectArray>& ports); |
38 #endif | 44 #endif |
39 | 45 |
40 private: | 46 private: |
41 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortProvider); | 47 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortProvider); |
42 }; | 48 }; |
43 | 49 |
44 } // namespace content | 50 } // namespace content |
45 | 51 |
46 #endif // CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ | 52 #endif // CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ |
OLD | NEW |