| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "pdf/out_of_process_instance.h" | 5 #include "pdf/out_of_process_instance.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> // for min/max() | 10 #include <algorithm> // for min/max() |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } | 336 } |
| 337 | 337 |
| 338 // Only allow the plugin to handle find requests if it is full frame. | 338 // Only allow the plugin to handle find requests if it is full frame. |
| 339 if (full_) | 339 if (full_) |
| 340 SetPluginToHandleFindRequests(); | 340 SetPluginToHandleFindRequests(); |
| 341 | 341 |
| 342 text_input_.reset(new pp::TextInput_Dev(this)); | 342 text_input_.reset(new pp::TextInput_Dev(this)); |
| 343 | 343 |
| 344 const char* stream_url = nullptr; | 344 const char* stream_url = nullptr; |
| 345 const char* original_url = nullptr; | 345 const char* original_url = nullptr; |
| 346 const char* embedder_url = nullptr; |
| 346 const char* headers = nullptr; | 347 const char* headers = nullptr; |
| 347 for (uint32_t i = 0; i < argc; ++i) { | 348 for (uint32_t i = 0; i < argc; ++i) { |
| 348 bool success = true; | 349 bool success = true; |
| 349 if (strcmp(argn[i], "src") == 0) | 350 if (strcmp(argn[i], "src") == 0) |
| 350 original_url = argv[i]; | 351 original_url = argv[i]; |
| 351 else if (strcmp(argn[i], "stream-url") == 0) | 352 else if (strcmp(argn[i], "stream-url") == 0) |
| 352 stream_url = argv[i]; | 353 stream_url = argv[i]; |
| 354 else if (!full_ && strcmp(argn[i], "embedder-url") == 0) |
| 355 embedder_url = argv[i]; |
| 353 else if (strcmp(argn[i], "headers") == 0) | 356 else if (strcmp(argn[i], "headers") == 0) |
| 354 headers = argv[i]; | 357 headers = argv[i]; |
| 355 else if (strcmp(argn[i], "background-color") == 0) | 358 else if (strcmp(argn[i], "background-color") == 0) |
| 356 success = base::HexStringToUInt(argv[i], &background_color_); | 359 success = base::HexStringToUInt(argv[i], &background_color_); |
| 357 else if (strcmp(argn[i], "top-toolbar-height") == 0) | 360 else if (strcmp(argn[i], "top-toolbar-height") == 0) |
| 358 success = base::StringToInt(argv[i], &top_toolbar_height_); | 361 success = base::StringToInt(argv[i], &top_toolbar_height_); |
| 359 | 362 |
| 360 if (!success) | 363 if (!success) |
| 361 return false; | 364 return false; |
| 362 } | 365 } |
| 363 | 366 |
| 364 if (!original_url) | 367 if (!original_url) |
| 365 return false; | 368 return false; |
| 366 | 369 |
| 367 if (!stream_url) | 370 if (!stream_url) |
| 368 stream_url = original_url; | 371 stream_url = original_url; |
| 369 | 372 |
| 370 // If we're in print preview mode we don't need to load the document yet. | 373 // If we're in print preview mode we don't need to load the document yet. |
| 371 // A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting | 374 // A |kJSResetPrintPreviewModeType| message will be sent to the plugin letting |
| 372 // it know the url to load. By not loading here we avoid loading the same | 375 // it know the url to load. By not loading here we avoid loading the same |
| 373 // document twice. | 376 // document twice. |
| 374 if (IsPrintPreviewUrl(original_url)) | 377 if (IsPrintPreviewUrl(original_url)) |
| 375 return true; | 378 return true; |
| 376 | 379 |
| 377 LoadUrl(stream_url); | 380 LoadUrl(stream_url); |
| 378 url_ = original_url; | 381 url_ = original_url; |
| 382 pp::PDF::SetCrashData(GetPluginInstance(), original_url, embedder_url); |
| 379 return engine_->New(original_url, headers); | 383 return engine_->New(original_url, headers); |
| 380 } | 384 } |
| 381 | 385 |
| 382 void OutOfProcessInstance::HandleMessage(const pp::Var& message) { | 386 void OutOfProcessInstance::HandleMessage(const pp::Var& message) { |
| 383 pp::VarDictionary dict(message); | 387 pp::VarDictionary dict(message); |
| 384 if (!dict.Get(kType).is_string()) { | 388 if (!dict.Get(kType).is_string()) { |
| 385 NOTREACHED(); | 389 NOTREACHED(); |
| 386 return; | 390 return; |
| 387 } | 391 } |
| 388 | 392 |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 const pp::FloatPoint& scroll_offset) { | 1527 const pp::FloatPoint& scroll_offset) { |
| 1524 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1528 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1525 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1529 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1526 float min_y = -top_toolbar_height_; | 1530 float min_y = -top_toolbar_height_; |
| 1527 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1531 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1528 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1532 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1529 return pp::FloatPoint(x, y); | 1533 return pp::FloatPoint(x, y); |
| 1530 } | 1534 } |
| 1531 | 1535 |
| 1532 } // namespace chrome_pdf | 1536 } // namespace chrome_pdf |
| OLD | NEW |