| 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 #ifdef _MSC_VER | 5 #ifdef _MSC_VER |
| 6 // Do not warn about use of std::copy with raw pointers. | 6 // Do not warn about use of std::copy with raw pointers. |
| 7 #pragma warning(disable : 4996) | 7 #pragma warning(disable : 4996) |
| 8 #endif | 8 #endif |
| 9 | 9 |
| 10 #include "native_client/src/trusted/plugin/plugin.h" | 10 #include "native_client/src/trusted/plugin/plugin.h" |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 argc_(-1), | 992 argc_(-1), |
| 993 argn_(NULL), | 993 argn_(NULL), |
| 994 argv_(NULL), | 994 argv_(NULL), |
| 995 main_subprocess_(kMainSubprocessId, NULL, NULL), | 995 main_subprocess_(kMainSubprocessId, NULL, NULL), |
| 996 nacl_ready_state_(UNSENT), | 996 nacl_ready_state_(UNSENT), |
| 997 nexe_error_reported_(false), | 997 nexe_error_reported_(false), |
| 998 wrapper_factory_(NULL), | 998 wrapper_factory_(NULL), |
| 999 last_error_string_(""), | 999 last_error_string_(""), |
| 1000 ppapi_proxy_(NULL), | 1000 ppapi_proxy_(NULL), |
| 1001 enable_dev_interfaces_(false), | 1001 enable_dev_interfaces_(false), |
| 1002 replayDidChangeView(false), | |
| 1003 replayHandleDocumentLoad(false), | |
| 1004 init_time_(0), | 1002 init_time_(0), |
| 1005 ready_time_(0), | 1003 ready_time_(0), |
| 1006 nexe_size_(0), | 1004 nexe_size_(0), |
| 1007 time_of_last_progress_event_(0) { | 1005 time_of_last_progress_event_(0) { |
| 1008 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 1006 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
| 1009 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); | 1007 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); |
| 1010 callback_factory_.Initialize(this); | 1008 callback_factory_.Initialize(this); |
| 1011 nexe_downloader_.Initialize(this); | 1009 nexe_downloader_.Initialize(this); |
| 1012 } | 1010 } |
| 1013 | 1011 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 HistogramTimeSmall( | 1069 HistogramTimeSmall( |
| 1072 "NaCl.Perf.ShutdownTime.Total", | 1070 "NaCl.Perf.ShutdownTime.Total", |
| 1073 (NaClGetTimeOfDayMicroseconds() - shutdown_start) | 1071 (NaClGetTimeOfDayMicroseconds() - shutdown_start) |
| 1074 / NACL_MICROS_PER_MILLI); | 1072 / NACL_MICROS_PER_MILLI); |
| 1075 | 1073 |
| 1076 PLUGIN_PRINTF(("Plugin::~Plugin (this=%p, return)\n", | 1074 PLUGIN_PRINTF(("Plugin::~Plugin (this=%p, return)\n", |
| 1077 static_cast<void*>(this))); | 1075 static_cast<void*>(this))); |
| 1078 } | 1076 } |
| 1079 | 1077 |
| 1080 | 1078 |
| 1081 void Plugin::DidChangeView(const pp::Rect& position, const pp::Rect& clip) { | 1079 void Plugin::DidChangeView(const pp::View& view) { |
| 1082 PLUGIN_PRINTF(("Plugin::DidChangeView (this=%p)\n", | 1080 PLUGIN_PRINTF(("Plugin::DidChangeView (this=%p)\n", |
| 1083 static_cast<void*>(this))); | 1081 static_cast<void*>(this))); |
| 1084 | 1082 |
| 1085 if (!BrowserPpp::is_valid(ppapi_proxy_)) { | 1083 if (!BrowserPpp::is_valid(ppapi_proxy_)) { |
| 1086 // Store this event and replay it when the proxy becomes available. | 1084 // Store this event and replay it when the proxy becomes available. |
| 1087 replayDidChangeView = true; | 1085 view_to_replay_ = view; |
| 1088 replayDidChangeViewPosition = position; | |
| 1089 replayDidChangeViewClip = clip; | |
| 1090 return; | |
| 1091 } else { | 1086 } else { |
| 1092 ppapi_proxy_->ppp_instance_interface()->DidChangeView( | 1087 ppapi_proxy_->ppp_instance_interface()->DidChangeView( |
| 1093 pp_instance(), &(position.pp_rect()), &(clip.pp_rect())); | 1088 pp_instance(), view.pp_resource()); |
| 1094 } | 1089 } |
| 1095 } | 1090 } |
| 1096 | 1091 |
| 1097 | 1092 |
| 1098 void Plugin::DidChangeFocus(bool has_focus) { | 1093 void Plugin::DidChangeFocus(bool has_focus) { |
| 1099 PLUGIN_PRINTF(("Plugin::DidChangeFocus (this=%p)\n", | 1094 PLUGIN_PRINTF(("Plugin::DidChangeFocus (this=%p)\n", |
| 1100 static_cast<void*>(this))); | 1095 static_cast<void*>(this))); |
| 1101 if (!BrowserPpp::is_valid(ppapi_proxy_)) { | 1096 if (BrowserPpp::is_valid(ppapi_proxy_)) { |
| 1102 return; | |
| 1103 } else { | |
| 1104 ppapi_proxy_->ppp_instance_interface()->DidChangeFocus( | 1097 ppapi_proxy_->ppp_instance_interface()->DidChangeFocus( |
| 1105 pp_instance(), PP_FromBool(has_focus)); | 1098 pp_instance(), PP_FromBool(has_focus)); |
| 1106 } | 1099 } |
| 1107 } | 1100 } |
| 1108 | 1101 |
| 1109 | 1102 |
| 1110 bool Plugin::HandleInputEvent(const pp::InputEvent& event) { | 1103 bool Plugin::HandleInputEvent(const pp::InputEvent& event) { |
| 1111 PLUGIN_PRINTF(("Plugin::HandleInputEvent (this=%p)\n", | 1104 PLUGIN_PRINTF(("Plugin::HandleInputEvent (this=%p)\n", |
| 1112 static_cast<void*>(this))); | 1105 static_cast<void*>(this))); |
| 1113 if (!BrowserPpp::is_valid(ppapi_proxy_) || | 1106 if (!BrowserPpp::is_valid(ppapi_proxy_) || |
| 1114 ppapi_proxy_->ppp_input_event_interface() == NULL) { | 1107 ppapi_proxy_->ppp_input_event_interface() == NULL) { |
| 1115 return false; // event is not handled here. | 1108 return false; // event is not handled here. |
| 1116 } else { | 1109 } else { |
| 1117 bool handled = PP_ToBool( | 1110 bool handled = PP_ToBool( |
| 1118 ppapi_proxy_->ppp_input_event_interface()->HandleInputEvent( | 1111 ppapi_proxy_->ppp_input_event_interface()->HandleInputEvent( |
| 1119 pp_instance(), event.pp_resource())); | 1112 pp_instance(), event.pp_resource())); |
| 1120 PLUGIN_PRINTF(("Plugin::HandleInputEvent (handled=%d)\n", handled)); | 1113 PLUGIN_PRINTF(("Plugin::HandleInputEvent (handled=%d)\n", handled)); |
| 1121 return handled; | 1114 return handled; |
| 1122 } | 1115 } |
| 1123 } | 1116 } |
| 1124 | 1117 |
| 1125 | 1118 |
| 1126 bool Plugin::HandleDocumentLoad(const pp::URLLoader& url_loader) { | 1119 bool Plugin::HandleDocumentLoad(const pp::URLLoader& url_loader) { |
| 1127 PLUGIN_PRINTF(("Plugin::HandleDocumentLoad (this=%p)\n", | 1120 PLUGIN_PRINTF(("Plugin::HandleDocumentLoad (this=%p)\n", |
| 1128 static_cast<void*>(this))); | 1121 static_cast<void*>(this))); |
| 1129 if (!BrowserPpp::is_valid(ppapi_proxy_)) { | 1122 if (!BrowserPpp::is_valid(ppapi_proxy_)) { |
| 1130 // Store this event and replay it when the proxy becomes available. | 1123 // Store this event and replay it when the proxy becomes available. |
| 1131 replayHandleDocumentLoad = true; | 1124 document_load_to_replay_ = url_loader; |
| 1132 replayHandleDocumentLoadURLLoader = url_loader; | |
| 1133 // Return true so that the browser keeps servicing this loader so we can | 1125 // Return true so that the browser keeps servicing this loader so we can |
| 1134 // perform requests on it later. | 1126 // perform requests on it later. |
| 1135 return true; | 1127 return true; |
| 1136 } else { | 1128 } else { |
| 1137 return PP_ToBool( | 1129 return PP_ToBool( |
| 1138 ppapi_proxy_->ppp_instance_interface()->HandleDocumentLoad( | 1130 ppapi_proxy_->ppp_instance_interface()->HandleDocumentLoad( |
| 1139 pp_instance(), url_loader.pp_resource())); | 1131 pp_instance(), url_loader.pp_resource())); |
| 1140 } | 1132 } |
| 1141 } | 1133 } |
| 1142 | 1134 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 error_info->SetReport(ERROR_START_PROXY_ALLOC, | 1367 error_info->SetReport(ERROR_START_PROXY_ALLOC, |
| 1376 "could not allocate proxy memory."); | 1368 "could not allocate proxy memory."); |
| 1377 return false; | 1369 return false; |
| 1378 } | 1370 } |
| 1379 pp::Module* module = pp::Module::Get(); | 1371 pp::Module* module = pp::Module::Get(); |
| 1380 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (module=%p)\n", | 1372 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (module=%p)\n", |
| 1381 static_cast<void*>(module))); | 1373 static_cast<void*>(module))); |
| 1382 CHECK(module != NULL); // We could not have gotten past init stage otherwise. | 1374 CHECK(module != NULL); // We could not have gotten past init stage otherwise. |
| 1383 int32_t pp_error = | 1375 int32_t pp_error = |
| 1384 ppapi_proxy->InitializeModule(module->pp_module(), | 1376 ppapi_proxy->InitializeModule(module->pp_module(), |
| 1385 module->get_browser_interface()); | 1377 module->get_browser_interface()); |
| 1386 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (pp_error=%" | 1378 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (pp_error=%" |
| 1387 NACL_PRId32")\n", pp_error)); | 1379 NACL_PRId32")\n", pp_error)); |
| 1388 if (pp_error != PP_OK) { | 1380 if (pp_error != PP_OK) { |
| 1389 error_info->SetReport(ERROR_START_PROXY_MODULE, | 1381 error_info->SetReport(ERROR_START_PROXY_MODULE, |
| 1390 "could not initialize module."); | 1382 "could not initialize module."); |
| 1391 return false; | 1383 return false; |
| 1392 } | 1384 } |
| 1393 const PPP_Instance* instance_interface = | 1385 const PPP_Instance* instance_interface = |
| 1394 ppapi_proxy->ppp_instance_interface(); | 1386 ppapi_proxy->ppp_instance_interface(); |
| 1395 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (ppp_instance=%p)\n", | 1387 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (ppp_instance=%p)\n", |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1412 | 1404 |
| 1413 // Create PPP* interface adapters to forward calls to .nexe. | 1405 // Create PPP* interface adapters to forward calls to .nexe. |
| 1414 find_adapter_.reset(new(std::nothrow) FindAdapter(this)); | 1406 find_adapter_.reset(new(std::nothrow) FindAdapter(this)); |
| 1415 mouse_lock_adapter_.reset(new(std::nothrow) MouseLockAdapter(this)); | 1407 mouse_lock_adapter_.reset(new(std::nothrow) MouseLockAdapter(this)); |
| 1416 printing_adapter_.reset(new(std::nothrow) PrintingAdapter(this)); | 1408 printing_adapter_.reset(new(std::nothrow) PrintingAdapter(this)); |
| 1417 selection_adapter_.reset(new(std::nothrow) SelectionAdapter(this)); | 1409 selection_adapter_.reset(new(std::nothrow) SelectionAdapter(this)); |
| 1418 widget_client_adapter_.reset(new(std::nothrow) WidgetClientAdapter(this)); | 1410 widget_client_adapter_.reset(new(std::nothrow) WidgetClientAdapter(this)); |
| 1419 zoom_adapter_.reset(new(std::nothrow) ZoomAdapter(this)); | 1411 zoom_adapter_.reset(new(std::nothrow) ZoomAdapter(this)); |
| 1420 | 1412 |
| 1421 // Replay missed events. | 1413 // Replay missed events. |
| 1422 if (replayDidChangeView) { | 1414 if (!view_to_replay_.is_null()) { |
| 1423 replayDidChangeView = false; | 1415 DidChangeView(view_to_replay_); |
| 1424 DidChangeView(replayDidChangeViewPosition, replayDidChangeViewClip); | 1416 view_to_replay_ = pp::View(); |
| 1425 } | 1417 } |
| 1426 if (replayHandleDocumentLoad) { | 1418 if (!document_load_to_replay_.is_null()) { |
| 1427 replayHandleDocumentLoad = false; | 1419 HandleDocumentLoad(document_load_to_replay_); |
| 1428 HandleDocumentLoad(replayHandleDocumentLoadURLLoader); | 1420 document_load_to_replay_ = pp::URLLoader(); |
| 1429 // Release our reference on this loader. | |
| 1430 replayHandleDocumentLoadURLLoader = pp::URLLoader(); | |
| 1431 } | 1421 } |
| 1432 bool is_valid_proxy = BrowserPpp::is_valid(ppapi_proxy_); | 1422 bool is_valid_proxy = BrowserPpp::is_valid(ppapi_proxy_); |
| 1433 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (is_valid_proxy=%d)\n", | 1423 PLUGIN_PRINTF(("Plugin::StartProxiedExecution (is_valid_proxy=%d)\n", |
| 1434 is_valid_proxy)); | 1424 is_valid_proxy)); |
| 1435 if (!is_valid_proxy) { | 1425 if (!is_valid_proxy) { |
| 1436 error_info->SetReport(ERROR_START_PROXY_CRASH, | 1426 error_info->SetReport(ERROR_START_PROXY_CRASH, |
| 1437 "instance crashed after creation."); | 1427 "instance crashed after creation."); |
| 1438 } | 1428 } |
| 1439 return is_valid_proxy; | 1429 return is_valid_proxy; |
| 1440 } | 1430 } |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, | 2047 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, |
| 2058 comps.scheme.len); | 2048 comps.scheme.len); |
| 2059 if (scheme == kChromeExtensionUriScheme) | 2049 if (scheme == kChromeExtensionUriScheme) |
| 2060 return SCHEME_CHROME_EXTENSION; | 2050 return SCHEME_CHROME_EXTENSION; |
| 2061 if (scheme == kDataUriScheme) | 2051 if (scheme == kDataUriScheme) |
| 2062 return SCHEME_DATA; | 2052 return SCHEME_DATA; |
| 2063 return SCHEME_OTHER; | 2053 return SCHEME_OTHER; |
| 2064 } | 2054 } |
| 2065 | 2055 |
| 2066 } // namespace plugin | 2056 } // namespace plugin |
| OLD | NEW |