OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/stringize_macros.h" | 14 #include "base/stringize_macros.h" |
15 #include "remoting/base/plugin_message_loop_proxy.h" | 15 #include "remoting/base/plugin_message_loop_proxy.h" |
16 #include "remoting/host/plugin/host_log_handler.h" | |
16 #include "remoting/host/plugin/host_plugin_utils.h" | 17 #include "remoting/host/plugin/host_plugin_utils.h" |
17 #include "remoting/host/plugin/host_script_object.h" | 18 #include "remoting/host/plugin/host_script_object.h" |
18 #include "third_party/npapi/bindings/npapi.h" | 19 #include "third_party/npapi/bindings/npapi.h" |
19 #include "third_party/npapi/bindings/npfunctions.h" | 20 #include "third_party/npapi/bindings/npfunctions.h" |
20 #include "third_party/npapi/bindings/npruntime.h" | 21 #include "third_party/npapi/bindings/npruntime.h" |
21 | 22 |
22 // Symbol export is handled with a separate def file on Windows. | 23 // Symbol export is handled with a separate def file on Windows. |
23 #if defined (__GNUC__) && __GNUC__ >= 4 | 24 #if defined (__GNUC__) && __GNUC__ >= 4 |
24 #define EXPORT __attribute__((visibility("default"))) | 25 #define EXPORT __attribute__((visibility("default"))) |
25 #else | 26 #else |
(...skipping 10 matching lines...) Expand all Loading... | |
36 return a / b; | 37 return a / b; |
37 } | 38 } |
38 uint64_t __cdecl __udivdi3(uint64_t a, uint64_t b) { | 39 uint64_t __cdecl __udivdi3(uint64_t a, uint64_t b) { |
39 return a / b; | 40 return a / b; |
40 } | 41 } |
41 | 42 |
42 } | 43 } |
43 #endif | 44 #endif |
44 | 45 |
45 using remoting::g_npnetscape_funcs; | 46 using remoting::g_npnetscape_funcs; |
47 using remoting::HostLogHandler; | |
46 using remoting::HostNPScriptObject; | 48 using remoting::HostNPScriptObject; |
47 using remoting::StringFromNPIdentifier; | 49 using remoting::StringFromNPIdentifier; |
48 | 50 |
49 namespace { | 51 namespace { |
50 | 52 |
51 base::AtExitManager* g_at_exit_manager = NULL; | 53 base::AtExitManager* g_at_exit_manager = NULL; |
52 | 54 |
53 // The name and description are returned by GetValue, but are also | 55 // The name and description are returned by GetValue, but are also |
54 // combined with the MIME type to satisfy GetMIMEDescription, so we | 56 // combined with the MIME type to satisfy GetMIMEDescription, so we |
55 // use macros here to allow that to happen at compile-time. | 57 // use macros here to allow that to happen at compile-time. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 } | 347 } |
346 | 348 |
347 NPError CreatePlugin(NPMIMEType pluginType, | 349 NPError CreatePlugin(NPMIMEType pluginType, |
348 NPP instance, | 350 NPP instance, |
349 uint16 mode, | 351 uint16 mode, |
350 int16 argc, | 352 int16 argc, |
351 char** argn, | 353 char** argn, |
352 char** argv, | 354 char** argv, |
353 NPSavedData* saved) { | 355 NPSavedData* saved) { |
354 VLOG(2) << "CreatePlugin"; | 356 VLOG(2) << "CreatePlugin"; |
357 | |
358 // Register a global log handler. | |
359 HostLogHandler::RegisterLogMessageHandler(); | |
360 | |
355 HostNPPlugin* plugin = new HostNPPlugin(instance, mode); | 361 HostNPPlugin* plugin = new HostNPPlugin(instance, mode); |
356 instance->pdata = plugin; | 362 instance->pdata = plugin; |
357 if (!plugin->Init(argc, argn, argv, saved)) { | 363 if (!plugin->Init(argc, argn, argv, saved)) { |
358 delete plugin; | 364 delete plugin; |
359 instance->pdata = NULL; | 365 instance->pdata = NULL; |
360 return NPERR_INVALID_PLUGIN_ERROR; | 366 return NPERR_INVALID_PLUGIN_ERROR; |
361 } else { | 367 } else { |
362 return NPERR_NO_ERROR; | 368 return NPERR_NO_ERROR; |
363 } | 369 } |
364 } | 370 } |
365 | 371 |
366 NPError DestroyPlugin(NPP instance, | 372 NPError DestroyPlugin(NPP instance, |
367 NPSavedData** save) { | 373 NPSavedData** save) { |
368 VLOG(2) << "DestroyPlugin"; | 374 VLOG(2) << "DestroyPlugin"; |
375 | |
376 // Unregister a global log handler. | |
377 HostLogHandler::UnregisterLogMessageHandler(); | |
Wez
2011/08/30 05:20:02
Can't do this here, in case there are threads doin
garykac
2011/08/31 00:59:00
Added comment, per our discussion. Plz review.
| |
378 | |
369 HostNPPlugin* plugin = PluginFromInstance(instance); | 379 HostNPPlugin* plugin = PluginFromInstance(instance); |
370 if (plugin) { | 380 if (plugin) { |
371 plugin->Save(save); | 381 plugin->Save(save); |
372 delete plugin; | 382 delete plugin; |
373 instance->pdata = NULL; | 383 instance->pdata = NULL; |
374 return NPERR_NO_ERROR; | 384 return NPERR_NO_ERROR; |
375 } else { | 385 } else { |
376 return NPERR_INVALID_PLUGIN_ERROR; | 386 return NPERR_INVALID_PLUGIN_ERROR; |
377 } | 387 } |
378 } | 388 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 } | 502 } |
493 | 503 |
494 EXPORT NPError API_CALL NP_GetValue(void* npp, | 504 EXPORT NPError API_CALL NP_GetValue(void* npp, |
495 NPPVariable variable, | 505 NPPVariable variable, |
496 void* value) { | 506 void* value) { |
497 return GetValue((NPP)npp, variable, value); | 507 return GetValue((NPP)npp, variable, value); |
498 } | 508 } |
499 #endif | 509 #endif |
500 | 510 |
501 } // extern "C" | 511 } // extern "C" |
OLD | NEW |