| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" | 5 #include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 259 } |
| 260 | 260 |
| 261 WebViewInternalCaptureVisibleRegionFunction:: | 261 WebViewInternalCaptureVisibleRegionFunction:: |
| 262 WebViewInternalCaptureVisibleRegionFunction() | 262 WebViewInternalCaptureVisibleRegionFunction() |
| 263 : is_guest_transparent_(false) {} | 263 : is_guest_transparent_(false) {} |
| 264 | 264 |
| 265 bool WebViewInternalCaptureVisibleRegionFunction::RunAsyncSafe( | 265 bool WebViewInternalCaptureVisibleRegionFunction::RunAsyncSafe( |
| 266 WebViewGuest* guest) { | 266 WebViewGuest* guest) { |
| 267 using api::extension_types::ImageDetails; | 267 using api::extension_types::ImageDetails; |
| 268 | 268 |
| 269 scoped_ptr<web_view_internal::CaptureVisibleRegion::Params> params( | 269 std::unique_ptr<web_view_internal::CaptureVisibleRegion::Params> params( |
| 270 web_view_internal::CaptureVisibleRegion::Params::Create(*args_)); | 270 web_view_internal::CaptureVisibleRegion::Params::Create(*args_)); |
| 271 EXTENSION_FUNCTION_VALIDATE(params.get()); | 271 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 272 | 272 |
| 273 scoped_ptr<ImageDetails> image_details; | 273 std::unique_ptr<ImageDetails> image_details; |
| 274 if (args_->GetSize() > 1) { | 274 if (args_->GetSize() > 1) { |
| 275 base::Value* spec = NULL; | 275 base::Value* spec = NULL; |
| 276 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); | 276 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); |
| 277 image_details = ImageDetails::FromValue(*spec); | 277 image_details = ImageDetails::FromValue(*spec); |
| 278 } | 278 } |
| 279 | 279 |
| 280 is_guest_transparent_ = guest->allow_transparency(); | 280 is_guest_transparent_ = guest->allow_transparency(); |
| 281 return CaptureAsync(guest->web_contents(), image_details.get(), | 281 return CaptureAsync(guest->web_contents(), image_details.get(), |
| 282 base::Bind(&WebViewInternalCaptureVisibleRegionFunction:: | 282 base::Bind(&WebViewInternalCaptureVisibleRegionFunction:: |
| 283 CopyFromBackingStoreComplete, | 283 CopyFromBackingStoreComplete, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 case FAILURE_REASON_VIEW_INVISIBLE: | 317 case FAILURE_REASON_VIEW_INVISIBLE: |
| 318 reason_description = "view is invisible"; | 318 reason_description = "view is invisible"; |
| 319 break; | 319 break; |
| 320 } | 320 } |
| 321 error_ = ErrorUtils::FormatErrorMessage("Failed to capture webview: *", | 321 error_ = ErrorUtils::FormatErrorMessage("Failed to capture webview: *", |
| 322 reason_description); | 322 reason_description); |
| 323 SendResponse(false); | 323 SendResponse(false); |
| 324 } | 324 } |
| 325 | 325 |
| 326 bool WebViewInternalNavigateFunction::RunAsyncSafe(WebViewGuest* guest) { | 326 bool WebViewInternalNavigateFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 327 scoped_ptr<web_view_internal::Navigate::Params> params( | 327 std::unique_ptr<web_view_internal::Navigate::Params> params( |
| 328 web_view_internal::Navigate::Params::Create(*args_)); | 328 web_view_internal::Navigate::Params::Create(*args_)); |
| 329 EXTENSION_FUNCTION_VALIDATE(params.get()); | 329 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 330 std::string src = params->src; | 330 std::string src = params->src; |
| 331 guest->NavigateGuest(src, true /* force_navigation */); | 331 guest->NavigateGuest(src, true /* force_navigation */); |
| 332 return true; | 332 return true; |
| 333 } | 333 } |
| 334 | 334 |
| 335 WebViewInternalExecuteCodeFunction::WebViewInternalExecuteCodeFunction() | 335 WebViewInternalExecuteCodeFunction::WebViewInternalExecuteCodeFunction() |
| 336 : guest_instance_id_(0), guest_src_(GURL::EmptyGURL()) { | 336 : guest_instance_id_(0), guest_src_(GURL::EmptyGURL()) { |
| 337 } | 337 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 355 | 355 |
| 356 // Set |guest_src_| here, but do not return false if it is invalid. | 356 // Set |guest_src_| here, but do not return false if it is invalid. |
| 357 // Instead, let it continue with the normal page load sequence, | 357 // Instead, let it continue with the normal page load sequence, |
| 358 // which will result in the usual LOAD_ABORT event in the case where | 358 // which will result in the usual LOAD_ABORT event in the case where |
| 359 // the URL is invalid. | 359 // the URL is invalid. |
| 360 guest_src_ = GURL(src); | 360 guest_src_ = GURL(src); |
| 361 | 361 |
| 362 base::DictionaryValue* details_value = NULL; | 362 base::DictionaryValue* details_value = NULL; |
| 363 if (!args_->GetDictionary(2, &details_value)) | 363 if (!args_->GetDictionary(2, &details_value)) |
| 364 return false; | 364 return false; |
| 365 scoped_ptr<InjectDetails> details(new InjectDetails()); | 365 std::unique_ptr<InjectDetails> details(new InjectDetails()); |
| 366 if (!InjectDetails::Populate(*details_value, details.get())) | 366 if (!InjectDetails::Populate(*details_value, details.get())) |
| 367 return false; | 367 return false; |
| 368 | 368 |
| 369 details_ = std::move(details); | 369 details_ = std::move(details); |
| 370 | 370 |
| 371 if (extension()) { | 371 if (extension()) { |
| 372 set_host_id(HostID(HostID::EXTENSIONS, extension()->id())); | 372 set_host_id(HostID(HostID::EXTENSIONS, extension()->id())); |
| 373 return true; | 373 return true; |
| 374 } | 374 } |
| 375 | 375 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 WebViewInternalAddContentScriptsFunction:: | 469 WebViewInternalAddContentScriptsFunction:: |
| 470 WebViewInternalAddContentScriptsFunction() { | 470 WebViewInternalAddContentScriptsFunction() { |
| 471 } | 471 } |
| 472 | 472 |
| 473 WebViewInternalAddContentScriptsFunction:: | 473 WebViewInternalAddContentScriptsFunction:: |
| 474 ~WebViewInternalAddContentScriptsFunction() { | 474 ~WebViewInternalAddContentScriptsFunction() { |
| 475 } | 475 } |
| 476 | 476 |
| 477 ExecuteCodeFunction::ResponseAction | 477 ExecuteCodeFunction::ResponseAction |
| 478 WebViewInternalAddContentScriptsFunction::Run() { | 478 WebViewInternalAddContentScriptsFunction::Run() { |
| 479 scoped_ptr<web_view_internal::AddContentScripts::Params> params( | 479 std::unique_ptr<web_view_internal::AddContentScripts::Params> params( |
| 480 web_view_internal::AddContentScripts::Params::Create(*args_)); | 480 web_view_internal::AddContentScripts::Params::Create(*args_)); |
| 481 EXTENSION_FUNCTION_VALIDATE(params.get()); | 481 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 482 | 482 |
| 483 if (!params->instance_id) | 483 if (!params->instance_id) |
| 484 return RespondNow(Error(kViewInstanceIdError)); | 484 return RespondNow(Error(kViewInstanceIdError)); |
| 485 | 485 |
| 486 GURL owner_base_url( | 486 GURL owner_base_url( |
| 487 render_frame_host()->GetSiteInstance()->GetSiteURL().GetWithEmptyPath()); | 487 render_frame_host()->GetSiteInstance()->GetSiteURL().GetWithEmptyPath()); |
| 488 std::set<UserScript> result; | 488 std::set<UserScript> result; |
| 489 | 489 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 509 WebViewInternalRemoveContentScriptsFunction:: | 509 WebViewInternalRemoveContentScriptsFunction:: |
| 510 WebViewInternalRemoveContentScriptsFunction() { | 510 WebViewInternalRemoveContentScriptsFunction() { |
| 511 } | 511 } |
| 512 | 512 |
| 513 WebViewInternalRemoveContentScriptsFunction:: | 513 WebViewInternalRemoveContentScriptsFunction:: |
| 514 ~WebViewInternalRemoveContentScriptsFunction() { | 514 ~WebViewInternalRemoveContentScriptsFunction() { |
| 515 } | 515 } |
| 516 | 516 |
| 517 ExecuteCodeFunction::ResponseAction | 517 ExecuteCodeFunction::ResponseAction |
| 518 WebViewInternalRemoveContentScriptsFunction::Run() { | 518 WebViewInternalRemoveContentScriptsFunction::Run() { |
| 519 scoped_ptr<web_view_internal::RemoveContentScripts::Params> params( | 519 std::unique_ptr<web_view_internal::RemoveContentScripts::Params> params( |
| 520 web_view_internal::RemoveContentScripts::Params::Create(*args_)); | 520 web_view_internal::RemoveContentScripts::Params::Create(*args_)); |
| 521 EXTENSION_FUNCTION_VALIDATE(params.get()); | 521 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 522 | 522 |
| 523 if (!params->instance_id) | 523 if (!params->instance_id) |
| 524 return RespondNow(Error(kViewInstanceIdError)); | 524 return RespondNow(Error(kViewInstanceIdError)); |
| 525 | 525 |
| 526 WebViewContentScriptManager* manager = | 526 WebViewContentScriptManager* manager = |
| 527 WebViewContentScriptManager::Get(browser_context()); | 527 WebViewContentScriptManager::Get(browser_context()); |
| 528 DCHECK(manager); | 528 DCHECK(manager); |
| 529 | 529 |
| 530 content::WebContents* sender_web_contents = GetSenderWebContents(); | 530 content::WebContents* sender_web_contents = GetSenderWebContents(); |
| 531 HostID host_id = GenerateHostIDFromEmbedder(extension(), sender_web_contents); | 531 HostID host_id = GenerateHostIDFromEmbedder(extension(), sender_web_contents); |
| 532 | 532 |
| 533 std::vector<std::string> script_name_list; | 533 std::vector<std::string> script_name_list; |
| 534 if (params->script_name_list) | 534 if (params->script_name_list) |
| 535 script_name_list.swap(*params->script_name_list); | 535 script_name_list.swap(*params->script_name_list); |
| 536 manager->RemoveContentScripts( | 536 manager->RemoveContentScripts( |
| 537 sender_web_contents->GetRenderProcessHost()->GetID(), | 537 sender_web_contents->GetRenderProcessHost()->GetID(), |
| 538 params->instance_id, host_id, script_name_list); | 538 params->instance_id, host_id, script_name_list); |
| 539 return RespondNow(NoArguments()); | 539 return RespondNow(NoArguments()); |
| 540 } | 540 } |
| 541 | 541 |
| 542 WebViewInternalSetNameFunction::WebViewInternalSetNameFunction() { | 542 WebViewInternalSetNameFunction::WebViewInternalSetNameFunction() { |
| 543 } | 543 } |
| 544 | 544 |
| 545 WebViewInternalSetNameFunction::~WebViewInternalSetNameFunction() { | 545 WebViewInternalSetNameFunction::~WebViewInternalSetNameFunction() { |
| 546 } | 546 } |
| 547 | 547 |
| 548 bool WebViewInternalSetNameFunction::RunAsyncSafe(WebViewGuest* guest) { | 548 bool WebViewInternalSetNameFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 549 scoped_ptr<web_view_internal::SetName::Params> params( | 549 std::unique_ptr<web_view_internal::SetName::Params> params( |
| 550 web_view_internal::SetName::Params::Create(*args_)); | 550 web_view_internal::SetName::Params::Create(*args_)); |
| 551 EXTENSION_FUNCTION_VALIDATE(params.get()); | 551 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 552 guest->SetName(params->frame_name); | 552 guest->SetName(params->frame_name); |
| 553 SendResponse(true); | 553 SendResponse(true); |
| 554 return true; | 554 return true; |
| 555 } | 555 } |
| 556 | 556 |
| 557 WebViewInternalSetAllowTransparencyFunction:: | 557 WebViewInternalSetAllowTransparencyFunction:: |
| 558 WebViewInternalSetAllowTransparencyFunction() { | 558 WebViewInternalSetAllowTransparencyFunction() { |
| 559 } | 559 } |
| 560 | 560 |
| 561 WebViewInternalSetAllowTransparencyFunction:: | 561 WebViewInternalSetAllowTransparencyFunction:: |
| 562 ~WebViewInternalSetAllowTransparencyFunction() { | 562 ~WebViewInternalSetAllowTransparencyFunction() { |
| 563 } | 563 } |
| 564 | 564 |
| 565 bool WebViewInternalSetAllowTransparencyFunction::RunAsyncSafe( | 565 bool WebViewInternalSetAllowTransparencyFunction::RunAsyncSafe( |
| 566 WebViewGuest* guest) { | 566 WebViewGuest* guest) { |
| 567 scoped_ptr<web_view_internal::SetAllowTransparency::Params> params( | 567 std::unique_ptr<web_view_internal::SetAllowTransparency::Params> params( |
| 568 web_view_internal::SetAllowTransparency::Params::Create(*args_)); | 568 web_view_internal::SetAllowTransparency::Params::Create(*args_)); |
| 569 EXTENSION_FUNCTION_VALIDATE(params.get()); | 569 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 570 guest->SetAllowTransparency(params->allow); | 570 guest->SetAllowTransparency(params->allow); |
| 571 SendResponse(true); | 571 SendResponse(true); |
| 572 return true; | 572 return true; |
| 573 } | 573 } |
| 574 | 574 |
| 575 WebViewInternalSetAllowScalingFunction:: | 575 WebViewInternalSetAllowScalingFunction:: |
| 576 WebViewInternalSetAllowScalingFunction() { | 576 WebViewInternalSetAllowScalingFunction() { |
| 577 } | 577 } |
| 578 | 578 |
| 579 WebViewInternalSetAllowScalingFunction:: | 579 WebViewInternalSetAllowScalingFunction:: |
| 580 ~WebViewInternalSetAllowScalingFunction() { | 580 ~WebViewInternalSetAllowScalingFunction() { |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool WebViewInternalSetAllowScalingFunction::RunAsyncSafe(WebViewGuest* guest) { | 583 bool WebViewInternalSetAllowScalingFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 584 scoped_ptr<web_view_internal::SetAllowScaling::Params> params( | 584 std::unique_ptr<web_view_internal::SetAllowScaling::Params> params( |
| 585 web_view_internal::SetAllowScaling::Params::Create(*args_)); | 585 web_view_internal::SetAllowScaling::Params::Create(*args_)); |
| 586 EXTENSION_FUNCTION_VALIDATE(params.get()); | 586 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 587 guest->SetAllowScaling(params->allow); | 587 guest->SetAllowScaling(params->allow); |
| 588 SendResponse(true); | 588 SendResponse(true); |
| 589 return true; | 589 return true; |
| 590 } | 590 } |
| 591 | 591 |
| 592 WebViewInternalSetZoomFunction::WebViewInternalSetZoomFunction() { | 592 WebViewInternalSetZoomFunction::WebViewInternalSetZoomFunction() { |
| 593 } | 593 } |
| 594 | 594 |
| 595 WebViewInternalSetZoomFunction::~WebViewInternalSetZoomFunction() { | 595 WebViewInternalSetZoomFunction::~WebViewInternalSetZoomFunction() { |
| 596 } | 596 } |
| 597 | 597 |
| 598 bool WebViewInternalSetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { | 598 bool WebViewInternalSetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 599 scoped_ptr<web_view_internal::SetZoom::Params> params( | 599 std::unique_ptr<web_view_internal::SetZoom::Params> params( |
| 600 web_view_internal::SetZoom::Params::Create(*args_)); | 600 web_view_internal::SetZoom::Params::Create(*args_)); |
| 601 EXTENSION_FUNCTION_VALIDATE(params.get()); | 601 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 602 guest->SetZoom(params->zoom_factor); | 602 guest->SetZoom(params->zoom_factor); |
| 603 | 603 |
| 604 SendResponse(true); | 604 SendResponse(true); |
| 605 return true; | 605 return true; |
| 606 } | 606 } |
| 607 | 607 |
| 608 WebViewInternalGetZoomFunction::WebViewInternalGetZoomFunction() { | 608 WebViewInternalGetZoomFunction::WebViewInternalGetZoomFunction() { |
| 609 } | 609 } |
| 610 | 610 |
| 611 WebViewInternalGetZoomFunction::~WebViewInternalGetZoomFunction() { | 611 WebViewInternalGetZoomFunction::~WebViewInternalGetZoomFunction() { |
| 612 } | 612 } |
| 613 | 613 |
| 614 bool WebViewInternalGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { | 614 bool WebViewInternalGetZoomFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 615 scoped_ptr<web_view_internal::GetZoom::Params> params( | 615 std::unique_ptr<web_view_internal::GetZoom::Params> params( |
| 616 web_view_internal::GetZoom::Params::Create(*args_)); | 616 web_view_internal::GetZoom::Params::Create(*args_)); |
| 617 EXTENSION_FUNCTION_VALIDATE(params.get()); | 617 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 618 | 618 |
| 619 double zoom_factor = guest->GetZoom(); | 619 double zoom_factor = guest->GetZoom(); |
| 620 SetResult(new base::FundamentalValue(zoom_factor)); | 620 SetResult(new base::FundamentalValue(zoom_factor)); |
| 621 SendResponse(true); | 621 SendResponse(true); |
| 622 return true; | 622 return true; |
| 623 } | 623 } |
| 624 | 624 |
| 625 WebViewInternalSetZoomModeFunction::WebViewInternalSetZoomModeFunction() { | 625 WebViewInternalSetZoomModeFunction::WebViewInternalSetZoomModeFunction() { |
| 626 } | 626 } |
| 627 | 627 |
| 628 WebViewInternalSetZoomModeFunction::~WebViewInternalSetZoomModeFunction() { | 628 WebViewInternalSetZoomModeFunction::~WebViewInternalSetZoomModeFunction() { |
| 629 } | 629 } |
| 630 | 630 |
| 631 bool WebViewInternalSetZoomModeFunction::RunAsyncSafe(WebViewGuest* guest) { | 631 bool WebViewInternalSetZoomModeFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 632 scoped_ptr<web_view_internal::SetZoomMode::Params> params( | 632 std::unique_ptr<web_view_internal::SetZoomMode::Params> params( |
| 633 web_view_internal::SetZoomMode::Params::Create(*args_)); | 633 web_view_internal::SetZoomMode::Params::Create(*args_)); |
| 634 EXTENSION_FUNCTION_VALIDATE(params.get()); | 634 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 635 | 635 |
| 636 ZoomController::ZoomMode zoom_mode = ZoomController::ZOOM_MODE_DEFAULT; | 636 ZoomController::ZoomMode zoom_mode = ZoomController::ZOOM_MODE_DEFAULT; |
| 637 switch (params->zoom_mode) { | 637 switch (params->zoom_mode) { |
| 638 case web_view_internal::ZOOM_MODE_PER_ORIGIN: | 638 case web_view_internal::ZOOM_MODE_PER_ORIGIN: |
| 639 zoom_mode = ZoomController::ZOOM_MODE_DEFAULT; | 639 zoom_mode = ZoomController::ZOOM_MODE_DEFAULT; |
| 640 break; | 640 break; |
| 641 case web_view_internal::ZOOM_MODE_PER_VIEW: | 641 case web_view_internal::ZOOM_MODE_PER_VIEW: |
| 642 zoom_mode = ZoomController::ZOOM_MODE_ISOLATED; | 642 zoom_mode = ZoomController::ZOOM_MODE_ISOLATED; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 654 return true; | 654 return true; |
| 655 } | 655 } |
| 656 | 656 |
| 657 WebViewInternalGetZoomModeFunction::WebViewInternalGetZoomModeFunction() { | 657 WebViewInternalGetZoomModeFunction::WebViewInternalGetZoomModeFunction() { |
| 658 } | 658 } |
| 659 | 659 |
| 660 WebViewInternalGetZoomModeFunction::~WebViewInternalGetZoomModeFunction() { | 660 WebViewInternalGetZoomModeFunction::~WebViewInternalGetZoomModeFunction() { |
| 661 } | 661 } |
| 662 | 662 |
| 663 bool WebViewInternalGetZoomModeFunction::RunAsyncSafe(WebViewGuest* guest) { | 663 bool WebViewInternalGetZoomModeFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 664 scoped_ptr<web_view_internal::GetZoomMode::Params> params( | 664 std::unique_ptr<web_view_internal::GetZoomMode::Params> params( |
| 665 web_view_internal::GetZoomMode::Params::Create(*args_)); | 665 web_view_internal::GetZoomMode::Params::Create(*args_)); |
| 666 EXTENSION_FUNCTION_VALIDATE(params.get()); | 666 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 667 | 667 |
| 668 web_view_internal::ZoomMode zoom_mode = web_view_internal::ZOOM_MODE_NONE; | 668 web_view_internal::ZoomMode zoom_mode = web_view_internal::ZOOM_MODE_NONE; |
| 669 switch (guest->GetZoomMode()) { | 669 switch (guest->GetZoomMode()) { |
| 670 case ZoomController::ZOOM_MODE_DEFAULT: | 670 case ZoomController::ZOOM_MODE_DEFAULT: |
| 671 zoom_mode = web_view_internal::ZOOM_MODE_PER_ORIGIN; | 671 zoom_mode = web_view_internal::ZOOM_MODE_PER_ORIGIN; |
| 672 break; | 672 break; |
| 673 case ZoomController::ZOOM_MODE_ISOLATED: | 673 case ZoomController::ZOOM_MODE_ISOLATED: |
| 674 zoom_mode = web_view_internal::ZOOM_MODE_PER_VIEW; | 674 zoom_mode = web_view_internal::ZOOM_MODE_PER_VIEW; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 685 return true; | 685 return true; |
| 686 } | 686 } |
| 687 | 687 |
| 688 WebViewInternalFindFunction::WebViewInternalFindFunction() { | 688 WebViewInternalFindFunction::WebViewInternalFindFunction() { |
| 689 } | 689 } |
| 690 | 690 |
| 691 WebViewInternalFindFunction::~WebViewInternalFindFunction() { | 691 WebViewInternalFindFunction::~WebViewInternalFindFunction() { |
| 692 } | 692 } |
| 693 | 693 |
| 694 bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) { | 694 bool WebViewInternalFindFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 695 scoped_ptr<web_view_internal::Find::Params> params( | 695 std::unique_ptr<web_view_internal::Find::Params> params( |
| 696 web_view_internal::Find::Params::Create(*args_)); | 696 web_view_internal::Find::Params::Create(*args_)); |
| 697 EXTENSION_FUNCTION_VALIDATE(params.get()); | 697 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 698 | 698 |
| 699 // Convert the std::string search_text to string16. | 699 // Convert the std::string search_text to string16. |
| 700 base::string16 search_text; | 700 base::string16 search_text; |
| 701 base::UTF8ToUTF16( | 701 base::UTF8ToUTF16( |
| 702 params->search_text.c_str(), params->search_text.length(), &search_text); | 702 params->search_text.c_str(), params->search_text.length(), &search_text); |
| 703 | 703 |
| 704 // Set the find options to their default values. | 704 // Set the find options to their default values. |
| 705 blink::WebFindOptions options; | 705 blink::WebFindOptions options; |
| 706 if (params->options) { | 706 if (params->options) { |
| 707 options.forward = | 707 options.forward = |
| 708 params->options->backward ? !*params->options->backward : true; | 708 params->options->backward ? !*params->options->backward : true; |
| 709 options.matchCase = | 709 options.matchCase = |
| 710 params->options->match_case ? *params->options->match_case : false; | 710 params->options->match_case ? *params->options->match_case : false; |
| 711 } | 711 } |
| 712 | 712 |
| 713 guest->StartFind(search_text, options, this); | 713 guest->StartFind(search_text, options, this); |
| 714 return true; | 714 return true; |
| 715 } | 715 } |
| 716 | 716 |
| 717 WebViewInternalStopFindingFunction::WebViewInternalStopFindingFunction() { | 717 WebViewInternalStopFindingFunction::WebViewInternalStopFindingFunction() { |
| 718 } | 718 } |
| 719 | 719 |
| 720 WebViewInternalStopFindingFunction::~WebViewInternalStopFindingFunction() { | 720 WebViewInternalStopFindingFunction::~WebViewInternalStopFindingFunction() { |
| 721 } | 721 } |
| 722 | 722 |
| 723 bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) { | 723 bool WebViewInternalStopFindingFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 724 scoped_ptr<web_view_internal::StopFinding::Params> params( | 724 std::unique_ptr<web_view_internal::StopFinding::Params> params( |
| 725 web_view_internal::StopFinding::Params::Create(*args_)); | 725 web_view_internal::StopFinding::Params::Create(*args_)); |
| 726 EXTENSION_FUNCTION_VALIDATE(params.get()); | 726 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 727 | 727 |
| 728 // Set the StopFindAction. | 728 // Set the StopFindAction. |
| 729 content::StopFindAction action; | 729 content::StopFindAction action; |
| 730 switch (params->action) { | 730 switch (params->action) { |
| 731 case web_view_internal::STOP_FINDING_ACTION_CLEAR: | 731 case web_view_internal::STOP_FINDING_ACTION_CLEAR: |
| 732 action = content::STOP_FIND_ACTION_CLEAR_SELECTION; | 732 action = content::STOP_FIND_ACTION_CLEAR_SELECTION; |
| 733 break; | 733 break; |
| 734 case web_view_internal::STOP_FINDING_ACTION_KEEP: | 734 case web_view_internal::STOP_FINDING_ACTION_KEEP: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 748 WebViewInternalLoadDataWithBaseUrlFunction:: | 748 WebViewInternalLoadDataWithBaseUrlFunction:: |
| 749 WebViewInternalLoadDataWithBaseUrlFunction() { | 749 WebViewInternalLoadDataWithBaseUrlFunction() { |
| 750 } | 750 } |
| 751 | 751 |
| 752 WebViewInternalLoadDataWithBaseUrlFunction:: | 752 WebViewInternalLoadDataWithBaseUrlFunction:: |
| 753 ~WebViewInternalLoadDataWithBaseUrlFunction() { | 753 ~WebViewInternalLoadDataWithBaseUrlFunction() { |
| 754 } | 754 } |
| 755 | 755 |
| 756 bool WebViewInternalLoadDataWithBaseUrlFunction::RunAsyncSafe( | 756 bool WebViewInternalLoadDataWithBaseUrlFunction::RunAsyncSafe( |
| 757 WebViewGuest* guest) { | 757 WebViewGuest* guest) { |
| 758 scoped_ptr<web_view_internal::LoadDataWithBaseUrl::Params> params( | 758 std::unique_ptr<web_view_internal::LoadDataWithBaseUrl::Params> params( |
| 759 web_view_internal::LoadDataWithBaseUrl::Params::Create(*args_)); | 759 web_view_internal::LoadDataWithBaseUrl::Params::Create(*args_)); |
| 760 EXTENSION_FUNCTION_VALIDATE(params.get()); | 760 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 761 | 761 |
| 762 // If a virtual URL was provided, use it. Otherwise, the user will be shown | 762 // If a virtual URL was provided, use it. Otherwise, the user will be shown |
| 763 // the data URL. | 763 // the data URL. |
| 764 std::string virtual_url = | 764 std::string virtual_url = |
| 765 params->virtual_url ? *params->virtual_url : params->data_url; | 765 params->virtual_url ? *params->virtual_url : params->data_url; |
| 766 | 766 |
| 767 bool successful = guest->LoadDataWithBaseURL( | 767 bool successful = guest->LoadDataWithBaseURL( |
| 768 params->data_url, params->base_url, virtual_url, &error_); | 768 params->data_url, params->base_url, virtual_url, &error_); |
| 769 SendResponse(successful); | 769 SendResponse(successful); |
| 770 return successful; | 770 return successful; |
| 771 } | 771 } |
| 772 | 772 |
| 773 WebViewInternalGoFunction::WebViewInternalGoFunction() { | 773 WebViewInternalGoFunction::WebViewInternalGoFunction() { |
| 774 } | 774 } |
| 775 | 775 |
| 776 WebViewInternalGoFunction::~WebViewInternalGoFunction() { | 776 WebViewInternalGoFunction::~WebViewInternalGoFunction() { |
| 777 } | 777 } |
| 778 | 778 |
| 779 bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) { | 779 bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 780 scoped_ptr<web_view_internal::Go::Params> params( | 780 std::unique_ptr<web_view_internal::Go::Params> params( |
| 781 web_view_internal::Go::Params::Create(*args_)); | 781 web_view_internal::Go::Params::Create(*args_)); |
| 782 EXTENSION_FUNCTION_VALIDATE(params.get()); | 782 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 783 | 783 |
| 784 bool successful = guest->Go(params->relative_index); | 784 bool successful = guest->Go(params->relative_index); |
| 785 SetResult(new base::FundamentalValue(successful)); | 785 SetResult(new base::FundamentalValue(successful)); |
| 786 SendResponse(true); | 786 SendResponse(true); |
| 787 return true; | 787 return true; |
| 788 } | 788 } |
| 789 | 789 |
| 790 WebViewInternalReloadFunction::WebViewInternalReloadFunction() { | 790 WebViewInternalReloadFunction::WebViewInternalReloadFunction() { |
| 791 } | 791 } |
| 792 | 792 |
| 793 WebViewInternalReloadFunction::~WebViewInternalReloadFunction() { | 793 WebViewInternalReloadFunction::~WebViewInternalReloadFunction() { |
| 794 } | 794 } |
| 795 | 795 |
| 796 bool WebViewInternalReloadFunction::RunAsyncSafe(WebViewGuest* guest) { | 796 bool WebViewInternalReloadFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 797 guest->Reload(); | 797 guest->Reload(); |
| 798 return true; | 798 return true; |
| 799 } | 799 } |
| 800 | 800 |
| 801 WebViewInternalSetPermissionFunction::WebViewInternalSetPermissionFunction() { | 801 WebViewInternalSetPermissionFunction::WebViewInternalSetPermissionFunction() { |
| 802 } | 802 } |
| 803 | 803 |
| 804 WebViewInternalSetPermissionFunction::~WebViewInternalSetPermissionFunction() { | 804 WebViewInternalSetPermissionFunction::~WebViewInternalSetPermissionFunction() { |
| 805 } | 805 } |
| 806 | 806 |
| 807 bool WebViewInternalSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { | 807 bool WebViewInternalSetPermissionFunction::RunAsyncSafe(WebViewGuest* guest) { |
| 808 scoped_ptr<web_view_internal::SetPermission::Params> params( | 808 std::unique_ptr<web_view_internal::SetPermission::Params> params( |
| 809 web_view_internal::SetPermission::Params::Create(*args_)); | 809 web_view_internal::SetPermission::Params::Create(*args_)); |
| 810 EXTENSION_FUNCTION_VALIDATE(params.get()); | 810 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 811 | 811 |
| 812 WebViewPermissionHelper::PermissionResponseAction action = | 812 WebViewPermissionHelper::PermissionResponseAction action = |
| 813 WebViewPermissionHelper::DEFAULT; | 813 WebViewPermissionHelper::DEFAULT; |
| 814 switch (params->action) { | 814 switch (params->action) { |
| 815 case api::web_view_internal::SET_PERMISSION_ACTION_ALLOW: | 815 case api::web_view_internal::SET_PERMISSION_ACTION_ALLOW: |
| 816 action = WebViewPermissionHelper::ALLOW; | 816 action = WebViewPermissionHelper::ALLOW; |
| 817 break; | 817 break; |
| 818 case api::web_view_internal::SET_PERMISSION_ACTION_DENY: | 818 case api::web_view_internal::SET_PERMISSION_ACTION_DENY: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 847 WebViewInternalOverrideUserAgentFunction:: | 847 WebViewInternalOverrideUserAgentFunction:: |
| 848 WebViewInternalOverrideUserAgentFunction() { | 848 WebViewInternalOverrideUserAgentFunction() { |
| 849 } | 849 } |
| 850 | 850 |
| 851 WebViewInternalOverrideUserAgentFunction:: | 851 WebViewInternalOverrideUserAgentFunction:: |
| 852 ~WebViewInternalOverrideUserAgentFunction() { | 852 ~WebViewInternalOverrideUserAgentFunction() { |
| 853 } | 853 } |
| 854 | 854 |
| 855 bool WebViewInternalOverrideUserAgentFunction::RunAsyncSafe( | 855 bool WebViewInternalOverrideUserAgentFunction::RunAsyncSafe( |
| 856 WebViewGuest* guest) { | 856 WebViewGuest* guest) { |
| 857 scoped_ptr<web_view_internal::OverrideUserAgent::Params> params( | 857 std::unique_ptr<web_view_internal::OverrideUserAgent::Params> params( |
| 858 web_view_internal::OverrideUserAgent::Params::Create(*args_)); | 858 web_view_internal::OverrideUserAgent::Params::Create(*args_)); |
| 859 EXTENSION_FUNCTION_VALIDATE(params.get()); | 859 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 860 | 860 |
| 861 guest->SetUserAgentOverride(params->user_agent_override); | 861 guest->SetUserAgentOverride(params->user_agent_override); |
| 862 return true; | 862 return true; |
| 863 } | 863 } |
| 864 | 864 |
| 865 WebViewInternalStopFunction::WebViewInternalStopFunction() { | 865 WebViewInternalStopFunction::WebViewInternalStopFunction() { |
| 866 } | 866 } |
| 867 | 867 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 // Will finish asynchronously. | 960 // Will finish asynchronously. |
| 961 return true; | 961 return true; |
| 962 } | 962 } |
| 963 | 963 |
| 964 void WebViewInternalClearDataFunction::ClearDataDone() { | 964 void WebViewInternalClearDataFunction::ClearDataDone() { |
| 965 Release(); // Balanced in RunAsync(). | 965 Release(); // Balanced in RunAsync(). |
| 966 SendResponse(true); | 966 SendResponse(true); |
| 967 } | 967 } |
| 968 | 968 |
| 969 } // namespace extensions | 969 } // namespace extensions |
| OLD | NEW |