| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can be | |
| 4 * found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 | |
| 8 // Interface for browser interaction | |
| 9 | |
| 10 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_BROWSER_INTERFACE_H_ | |
| 11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_BROWSER_INTERFACE_H_ | |
| 12 | |
| 13 #include <stdio.h> | |
| 14 #include <map> | |
| 15 | |
| 16 #include "native_client/src/include/nacl_macros.h" | |
| 17 #include "native_client/src/include/nacl_string.h" | |
| 18 #include "native_client/src/include/portability.h" | |
| 19 #include "ppapi/cpp/instance.h" | |
| 20 | |
| 21 namespace pp { | |
| 22 class InstancePrivate; | |
| 23 } // namespace | |
| 24 | |
| 25 namespace plugin { | |
| 26 | |
| 27 // BrowserInterface represents the interface to the browser from the plugin. | |
| 28 // I.e., when the plugin needs to request an alert, it uses these interfaces. | |
| 29 class BrowserInterface { | |
| 30 public: | |
| 31 BrowserInterface() : next_identifier(0) {} | |
| 32 ~BrowserInterface() { } | |
| 33 | |
| 34 // Functions for communication with the browser. | |
| 35 | |
| 36 // Convert a string to an identifier. | |
| 37 uintptr_t StringToIdentifier(const nacl::string& str); | |
| 38 // Convert an identifier to a string. | |
| 39 nacl::string IdentifierToString(uintptr_t ident); | |
| 40 | |
| 41 // Write to the JavaScript console. | |
| 42 void AddToConsole(pp::InstancePrivate* instance, const nacl::string& text); | |
| 43 | |
| 44 private: | |
| 45 NACL_DISALLOW_COPY_AND_ASSIGN(BrowserInterface); | |
| 46 | |
| 47 // Map strings used for property and method names to unique ids and back. | |
| 48 typedef std::map<nacl::string, uintptr_t> StringToIdentifierMap; | |
| 49 typedef std::map<uintptr_t, nacl::string> IdentifierToStringMap; | |
| 50 StringToIdentifierMap string_to_identifier_map_; | |
| 51 IdentifierToStringMap identifier_to_string_map_; | |
| 52 uintptr_t next_identifier; // will be incremented once used | |
| 53 }; | |
| 54 | |
| 55 } // namespace plugin | |
| 56 | |
| 57 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_BROWSER_INTERFACE_H_ | |
| OLD | NEW |