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