| 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/guest_view/web_view/web_view_guest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" | 16 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
| 16 #include "components/guest_view/browser/guest_view_event.h" | 17 #include "components/guest_view/browser/guest_view_event.h" |
| 17 #include "components/guest_view/browser/guest_view_manager.h" | 18 #include "components/guest_view/browser/guest_view_manager.h" |
| 18 #include "components/guest_view/common/guest_view_constants.h" | 19 #include "components/guest_view/common/guest_view_constants.h" |
| 19 #include "components/web_cache/browser/web_cache_manager.h" | 20 #include "components/web_cache/browser/web_cache_manager.h" |
| 20 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 std::move(guest_site_instance)); | 363 std::move(guest_site_instance)); |
| 363 params.guest_delegate = this; | 364 params.guest_delegate = this; |
| 364 callback.Run(WebContents::Create(params)); | 365 callback.Run(WebContents::Create(params)); |
| 365 } | 366 } |
| 366 | 367 |
| 367 void WebViewGuest::DidAttachToEmbedder() { | 368 void WebViewGuest::DidAttachToEmbedder() { |
| 368 ApplyAttributes(*attach_params()); | 369 ApplyAttributes(*attach_params()); |
| 369 } | 370 } |
| 370 | 371 |
| 371 void WebViewGuest::DidDropLink(const GURL& url) { | 372 void WebViewGuest::DidDropLink(const GURL& url) { |
| 372 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 373 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 373 args->SetString(guest_view::kUrl, url.spec()); | 374 args->SetString(guest_view::kUrl, url.spec()); |
| 374 DispatchEventToView(make_scoped_ptr( | 375 DispatchEventToView(base::WrapUnique( |
| 375 new GuestViewEvent(webview::kEventDropLink, std::move(args)))); | 376 new GuestViewEvent(webview::kEventDropLink, std::move(args)))); |
| 376 } | 377 } |
| 377 | 378 |
| 378 void WebViewGuest::DidInitialize(const base::DictionaryValue& create_params) { | 379 void WebViewGuest::DidInitialize(const base::DictionaryValue& create_params) { |
| 379 script_executor_.reset( | 380 script_executor_.reset( |
| 380 new ScriptExecutor(web_contents(), &script_observers_)); | 381 new ScriptExecutor(web_contents(), &script_observers_)); |
| 381 | 382 |
| 382 notification_registrar_.Add(this, | 383 notification_registrar_.Add(this, |
| 383 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 384 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 384 content::Source<WebContents>(web_contents())); | 385 content::Source<WebContents>(web_contents())); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 web_contents()->GetBrowserContext(), | 419 web_contents()->GetBrowserContext(), |
| 419 web_contents()->GetSiteInstance()); | 420 web_contents()->GetSiteInstance()); |
| 420 partition->ClearData( | 421 partition->ClearData( |
| 421 storage_partition_removal_mask, | 422 storage_partition_removal_mask, |
| 422 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), | 423 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), |
| 423 content::StoragePartition::OriginMatcherFunction(), remove_since, | 424 content::StoragePartition::OriginMatcherFunction(), remove_since, |
| 424 base::Time::Now(), callback); | 425 base::Time::Now(), callback); |
| 425 } | 426 } |
| 426 | 427 |
| 427 void WebViewGuest::GuestViewDidStopLoading() { | 428 void WebViewGuest::GuestViewDidStopLoading() { |
| 428 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 429 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 429 DispatchEventToView(make_scoped_ptr( | 430 DispatchEventToView(base::WrapUnique( |
| 430 new GuestViewEvent(webview::kEventLoadStop, std::move(args)))); | 431 new GuestViewEvent(webview::kEventLoadStop, std::move(args)))); |
| 431 } | 432 } |
| 432 | 433 |
| 433 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { | 434 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { |
| 434 is_embedder_fullscreen_ = entered_fullscreen; | 435 is_embedder_fullscreen_ = entered_fullscreen; |
| 435 // If the embedder has got out of fullscreen, we get out of fullscreen | 436 // If the embedder has got out of fullscreen, we get out of fullscreen |
| 436 // mode as well. | 437 // mode as well. |
| 437 if (!entered_fullscreen) | 438 if (!entered_fullscreen) |
| 438 SetFullscreenState(false); | 439 SetFullscreenState(false); |
| 439 } | 440 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 469 web_contents() | 470 web_contents() |
| 470 ->GetRenderViewHost() | 471 ->GetRenderViewHost() |
| 471 ->GetWidget() | 472 ->GetWidget() |
| 472 ->GetView() | 473 ->GetView() |
| 473 ->SetBackgroundColorToDefault(); | 474 ->SetBackgroundColorToDefault(); |
| 474 } | 475 } |
| 475 } | 476 } |
| 476 | 477 |
| 477 void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, | 478 void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, |
| 478 const gfx::Size& new_size) { | 479 const gfx::Size& new_size) { |
| 479 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 480 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 480 args->SetInteger(webview::kOldHeight, old_size.height()); | 481 args->SetInteger(webview::kOldHeight, old_size.height()); |
| 481 args->SetInteger(webview::kOldWidth, old_size.width()); | 482 args->SetInteger(webview::kOldWidth, old_size.width()); |
| 482 args->SetInteger(webview::kNewHeight, new_size.height()); | 483 args->SetInteger(webview::kNewHeight, new_size.height()); |
| 483 args->SetInteger(webview::kNewWidth, new_size.width()); | 484 args->SetInteger(webview::kNewWidth, new_size.width()); |
| 484 DispatchEventToView(make_scoped_ptr( | 485 DispatchEventToView(base::WrapUnique( |
| 485 new GuestViewEvent(webview::kEventSizeChanged, std::move(args)))); | 486 new GuestViewEvent(webview::kEventSizeChanged, std::move(args)))); |
| 486 } | 487 } |
| 487 | 488 |
| 488 bool WebViewGuest::IsAutoSizeSupported() const { | 489 bool WebViewGuest::IsAutoSizeSupported() const { |
| 489 return true; | 490 return true; |
| 490 } | 491 } |
| 491 | 492 |
| 492 void WebViewGuest::GuestZoomChanged(double old_zoom_level, | 493 void WebViewGuest::GuestZoomChanged(double old_zoom_level, |
| 493 double new_zoom_level) { | 494 double new_zoom_level) { |
| 494 // Dispatch the zoomchange event. | 495 // Dispatch the zoomchange event. |
| 495 double old_zoom_factor = ConvertZoomLevelToZoomFactor(old_zoom_level); | 496 double old_zoom_factor = ConvertZoomLevelToZoomFactor(old_zoom_level); |
| 496 double new_zoom_factor = ConvertZoomLevelToZoomFactor(new_zoom_level); | 497 double new_zoom_factor = ConvertZoomLevelToZoomFactor(new_zoom_level); |
| 497 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 498 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 498 args->SetDouble(webview::kOldZoomFactor, old_zoom_factor); | 499 args->SetDouble(webview::kOldZoomFactor, old_zoom_factor); |
| 499 args->SetDouble(webview::kNewZoomFactor, new_zoom_factor); | 500 args->SetDouble(webview::kNewZoomFactor, new_zoom_factor); |
| 500 DispatchEventToView(make_scoped_ptr( | 501 DispatchEventToView(base::WrapUnique( |
| 501 new GuestViewEvent(webview::kEventZoomChange, std::move(args)))); | 502 new GuestViewEvent(webview::kEventZoomChange, std::move(args)))); |
| 502 } | 503 } |
| 503 | 504 |
| 504 void WebViewGuest::WillDestroy() { | 505 void WebViewGuest::WillDestroy() { |
| 505 if (!attached() && GetOpener()) | 506 if (!attached() && GetOpener()) |
| 506 GetOpener()->pending_new_windows_.erase(this); | 507 GetOpener()->pending_new_windows_.erase(this); |
| 507 } | 508 } |
| 508 | 509 |
| 509 bool WebViewGuest::AddMessageToConsole(WebContents* source, | 510 bool WebViewGuest::AddMessageToConsole(WebContents* source, |
| 510 int32_t level, | 511 int32_t level, |
| 511 const base::string16& message, | 512 const base::string16& message, |
| 512 int32_t line_no, | 513 int32_t line_no, |
| 513 const base::string16& source_id) { | 514 const base::string16& source_id) { |
| 514 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 515 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 515 // Log levels are from base/logging.h: LogSeverity. | 516 // Log levels are from base/logging.h: LogSeverity. |
| 516 args->SetInteger(webview::kLevel, level); | 517 args->SetInteger(webview::kLevel, level); |
| 517 args->SetString(webview::kMessage, message); | 518 args->SetString(webview::kMessage, message); |
| 518 args->SetInteger(webview::kLine, line_no); | 519 args->SetInteger(webview::kLine, line_no); |
| 519 args->SetString(webview::kSourceId, source_id); | 520 args->SetString(webview::kSourceId, source_id); |
| 520 DispatchEventToView(make_scoped_ptr( | 521 DispatchEventToView(base::WrapUnique( |
| 521 new GuestViewEvent(webview::kEventConsoleMessage, std::move(args)))); | 522 new GuestViewEvent(webview::kEventConsoleMessage, std::move(args)))); |
| 522 return true; | 523 return true; |
| 523 } | 524 } |
| 524 | 525 |
| 525 void WebViewGuest::CloseContents(WebContents* source) { | 526 void WebViewGuest::CloseContents(WebContents* source) { |
| 526 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 527 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 527 DispatchEventToView(make_scoped_ptr( | 528 DispatchEventToView(base::WrapUnique( |
| 528 new GuestViewEvent(webview::kEventClose, std::move(args)))); | 529 new GuestViewEvent(webview::kEventClose, std::move(args)))); |
| 529 } | 530 } |
| 530 | 531 |
| 531 void WebViewGuest::FindReply(WebContents* source, | 532 void WebViewGuest::FindReply(WebContents* source, |
| 532 int request_id, | 533 int request_id, |
| 533 int number_of_matches, | 534 int number_of_matches, |
| 534 const gfx::Rect& selection_rect, | 535 const gfx::Rect& selection_rect, |
| 535 int active_match_ordinal, | 536 int active_match_ordinal, |
| 536 bool final_update) { | 537 bool final_update) { |
| 537 GuestViewBase::FindReply(source, request_id, number_of_matches, | 538 GuestViewBase::FindReply(source, request_id, number_of_matches, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 565 | 566 |
| 566 GuestViewBase::HandleKeyboardEvent(source, event); | 567 GuestViewBase::HandleKeyboardEvent(source, event); |
| 567 } | 568 } |
| 568 | 569 |
| 569 bool WebViewGuest::PreHandleGestureEvent(WebContents* source, | 570 bool WebViewGuest::PreHandleGestureEvent(WebContents* source, |
| 570 const blink::WebGestureEvent& event) { | 571 const blink::WebGestureEvent& event) { |
| 571 return !allow_scaling_ && GuestViewBase::PreHandleGestureEvent(source, event); | 572 return !allow_scaling_ && GuestViewBase::PreHandleGestureEvent(source, event); |
| 572 } | 573 } |
| 573 | 574 |
| 574 void WebViewGuest::LoadProgressChanged(WebContents* source, double progress) { | 575 void WebViewGuest::LoadProgressChanged(WebContents* source, double progress) { |
| 575 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 576 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 576 args->SetString(guest_view::kUrl, web_contents()->GetURL().spec()); | 577 args->SetString(guest_view::kUrl, web_contents()->GetURL().spec()); |
| 577 args->SetDouble(webview::kProgress, progress); | 578 args->SetDouble(webview::kProgress, progress); |
| 578 DispatchEventToView(make_scoped_ptr( | 579 DispatchEventToView(base::WrapUnique( |
| 579 new GuestViewEvent(webview::kEventLoadProgress, std::move(args)))); | 580 new GuestViewEvent(webview::kEventLoadProgress, std::move(args)))); |
| 580 } | 581 } |
| 581 | 582 |
| 582 void WebViewGuest::LoadAbort(bool is_top_level, | 583 void WebViewGuest::LoadAbort(bool is_top_level, |
| 583 const GURL& url, | 584 const GURL& url, |
| 584 int error_code, | 585 int error_code, |
| 585 const std::string& error_type) { | 586 const std::string& error_type) { |
| 586 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 587 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 587 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); | 588 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); |
| 588 args->SetString(guest_view::kUrl, url.possibly_invalid_spec()); | 589 args->SetString(guest_view::kUrl, url.possibly_invalid_spec()); |
| 589 args->SetInteger(guest_view::kCode, error_code); | 590 args->SetInteger(guest_view::kCode, error_code); |
| 590 args->SetString(guest_view::kReason, error_type); | 591 args->SetString(guest_view::kReason, error_type); |
| 591 DispatchEventToView(make_scoped_ptr( | 592 DispatchEventToView(base::WrapUnique( |
| 592 new GuestViewEvent(webview::kEventLoadAbort, std::move(args)))); | 593 new GuestViewEvent(webview::kEventLoadAbort, std::move(args)))); |
| 593 } | 594 } |
| 594 | 595 |
| 595 void WebViewGuest::SetContextMenuPosition(const gfx::Point& position) { | 596 void WebViewGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 596 if (web_view_guest_delegate_) | 597 if (web_view_guest_delegate_) |
| 597 web_view_guest_delegate_->SetContextMenuPosition(position); | 598 web_view_guest_delegate_->SetContextMenuPosition(position); |
| 598 } | 599 } |
| 599 | 600 |
| 600 void WebViewGuest::CreateNewGuestWebViewWindow( | 601 void WebViewGuest::CreateNewGuestWebViewWindow( |
| 601 const content::OpenURLParams& params) { | 602 const content::OpenURLParams& params) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 630 // Request permission to show the new window. | 631 // Request permission to show the new window. |
| 631 RequestNewWindowPermission(params.disposition, | 632 RequestNewWindowPermission(params.disposition, |
| 632 gfx::Rect(), | 633 gfx::Rect(), |
| 633 params.user_gesture, | 634 params.user_gesture, |
| 634 new_guest->web_contents()); | 635 new_guest->web_contents()); |
| 635 } | 636 } |
| 636 | 637 |
| 637 // TODO(fsamuel): Find a reliable way to test the 'responsive' and | 638 // TODO(fsamuel): Find a reliable way to test the 'responsive' and |
| 638 // 'unresponsive' events. | 639 // 'unresponsive' events. |
| 639 void WebViewGuest::RendererResponsive(WebContents* source) { | 640 void WebViewGuest::RendererResponsive(WebContents* source) { |
| 640 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 641 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 641 args->SetInteger(webview::kProcessId, | 642 args->SetInteger(webview::kProcessId, |
| 642 web_contents()->GetRenderProcessHost()->GetID()); | 643 web_contents()->GetRenderProcessHost()->GetID()); |
| 643 DispatchEventToView(make_scoped_ptr( | 644 DispatchEventToView(base::WrapUnique( |
| 644 new GuestViewEvent(webview::kEventResponsive, std::move(args)))); | 645 new GuestViewEvent(webview::kEventResponsive, std::move(args)))); |
| 645 } | 646 } |
| 646 | 647 |
| 647 void WebViewGuest::RendererUnresponsive(WebContents* source) { | 648 void WebViewGuest::RendererUnresponsive(WebContents* source) { |
| 648 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 649 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 649 args->SetInteger(webview::kProcessId, | 650 args->SetInteger(webview::kProcessId, |
| 650 web_contents()->GetRenderProcessHost()->GetID()); | 651 web_contents()->GetRenderProcessHost()->GetID()); |
| 651 DispatchEventToView(make_scoped_ptr( | 652 DispatchEventToView(base::WrapUnique( |
| 652 new GuestViewEvent(webview::kEventUnresponsive, std::move(args)))); | 653 new GuestViewEvent(webview::kEventUnresponsive, std::move(args)))); |
| 653 } | 654 } |
| 654 | 655 |
| 655 void WebViewGuest::Observe(int type, | 656 void WebViewGuest::Observe(int type, |
| 656 const content::NotificationSource& source, | 657 const content::NotificationSource& source, |
| 657 const content::NotificationDetails& details) { | 658 const content::NotificationDetails& details) { |
| 658 switch (type) { | 659 switch (type) { |
| 659 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { | 660 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { |
| 660 DCHECK_EQ(content::Source<WebContents>(source).ptr(), web_contents()); | 661 DCHECK_EQ(content::Source<WebContents>(source).ptr(), web_contents()); |
| 661 if (content::Source<WebContents>(source).ptr() == web_contents()) | 662 if (content::Source<WebContents>(source).ptr() == web_contents()) |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 if (!render_frame_host->GetParent()) { | 795 if (!render_frame_host->GetParent()) { |
| 795 // For LoadDataWithBaseURL loads, |url| contains the data URL, but the | 796 // For LoadDataWithBaseURL loads, |url| contains the data URL, but the |
| 796 // virtual URL is needed in that case. So use WebContents::GetURL instead. | 797 // virtual URL is needed in that case. So use WebContents::GetURL instead. |
| 797 src_ = web_contents()->GetURL(); | 798 src_ = web_contents()->GetURL(); |
| 798 // Handle a pending zoom if one exists. | 799 // Handle a pending zoom if one exists. |
| 799 if (pending_zoom_factor_) { | 800 if (pending_zoom_factor_) { |
| 800 SetZoom(pending_zoom_factor_); | 801 SetZoom(pending_zoom_factor_); |
| 801 pending_zoom_factor_ = 0.0; | 802 pending_zoom_factor_ = 0.0; |
| 802 } | 803 } |
| 803 } | 804 } |
| 804 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 805 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 805 args->SetString(guest_view::kUrl, src_.spec()); | 806 args->SetString(guest_view::kUrl, src_.spec()); |
| 806 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); | 807 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); |
| 807 args->SetString(webview::kInternalBaseURLForDataURL, | 808 args->SetString(webview::kInternalBaseURLForDataURL, |
| 808 web_contents() | 809 web_contents() |
| 809 ->GetController() | 810 ->GetController() |
| 810 .GetLastCommittedEntry() | 811 .GetLastCommittedEntry() |
| 811 ->GetBaseURLForDataURL() | 812 ->GetBaseURLForDataURL() |
| 812 .spec()); | 813 .spec()); |
| 813 args->SetInteger(webview::kInternalCurrentEntryIndex, | 814 args->SetInteger(webview::kInternalCurrentEntryIndex, |
| 814 web_contents()->GetController().GetCurrentEntryIndex()); | 815 web_contents()->GetController().GetCurrentEntryIndex()); |
| 815 args->SetInteger(webview::kInternalEntryCount, | 816 args->SetInteger(webview::kInternalEntryCount, |
| 816 web_contents()->GetController().GetEntryCount()); | 817 web_contents()->GetController().GetEntryCount()); |
| 817 args->SetInteger(webview::kInternalProcessId, | 818 args->SetInteger(webview::kInternalProcessId, |
| 818 web_contents()->GetRenderProcessHost()->GetID()); | 819 web_contents()->GetRenderProcessHost()->GetID()); |
| 819 DispatchEventToView(make_scoped_ptr( | 820 DispatchEventToView(base::WrapUnique( |
| 820 new GuestViewEvent(webview::kEventLoadCommit, std::move(args)))); | 821 new GuestViewEvent(webview::kEventLoadCommit, std::move(args)))); |
| 821 | 822 |
| 822 find_helper_.CancelAllFindSessions(); | 823 find_helper_.CancelAllFindSessions(); |
| 823 } | 824 } |
| 824 | 825 |
| 825 void WebViewGuest::DidFailProvisionalLoad( | 826 void WebViewGuest::DidFailProvisionalLoad( |
| 826 content::RenderFrameHost* render_frame_host, | 827 content::RenderFrameHost* render_frame_host, |
| 827 const GURL& validated_url, | 828 const GURL& validated_url, |
| 828 int error_code, | 829 int error_code, |
| 829 const base::string16& error_description, | 830 const base::string16& error_description, |
| 830 bool was_ignored_by_handler) { | 831 bool was_ignored_by_handler) { |
| 831 // Suppress loadabort for "mailto" URLs. | 832 // Suppress loadabort for "mailto" URLs. |
| 832 if (validated_url.SchemeIs(url::kMailToScheme)) | 833 if (validated_url.SchemeIs(url::kMailToScheme)) |
| 833 return; | 834 return; |
| 834 | 835 |
| 835 LoadAbort(!render_frame_host->GetParent(), validated_url, error_code, | 836 LoadAbort(!render_frame_host->GetParent(), validated_url, error_code, |
| 836 net::ErrorToShortString(error_code)); | 837 net::ErrorToShortString(error_code)); |
| 837 } | 838 } |
| 838 | 839 |
| 839 void WebViewGuest::DidStartProvisionalLoadForFrame( | 840 void WebViewGuest::DidStartProvisionalLoadForFrame( |
| 840 content::RenderFrameHost* render_frame_host, | 841 content::RenderFrameHost* render_frame_host, |
| 841 const GURL& validated_url, | 842 const GURL& validated_url, |
| 842 bool is_error_page, | 843 bool is_error_page, |
| 843 bool is_iframe_srcdoc) { | 844 bool is_iframe_srcdoc) { |
| 844 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 845 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 845 args->SetString(guest_view::kUrl, validated_url.spec()); | 846 args->SetString(guest_view::kUrl, validated_url.spec()); |
| 846 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); | 847 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); |
| 847 DispatchEventToView(make_scoped_ptr( | 848 DispatchEventToView(base::WrapUnique( |
| 848 new GuestViewEvent(webview::kEventLoadStart, std::move(args)))); | 849 new GuestViewEvent(webview::kEventLoadStart, std::move(args)))); |
| 849 } | 850 } |
| 850 | 851 |
| 851 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { | 852 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { |
| 852 // Cancel all find sessions in progress. | 853 // Cancel all find sessions in progress. |
| 853 find_helper_.CancelAllFindSessions(); | 854 find_helper_.CancelAllFindSessions(); |
| 854 | 855 |
| 855 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 856 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 856 args->SetInteger(webview::kProcessId, | 857 args->SetInteger(webview::kProcessId, |
| 857 web_contents()->GetRenderProcessHost()->GetID()); | 858 web_contents()->GetRenderProcessHost()->GetID()); |
| 858 args->SetString(webview::kReason, TerminationStatusToString(status)); | 859 args->SetString(webview::kReason, TerminationStatusToString(status)); |
| 859 DispatchEventToView(make_scoped_ptr( | 860 DispatchEventToView(base::WrapUnique( |
| 860 new GuestViewEvent(webview::kEventExit, std::move(args)))); | 861 new GuestViewEvent(webview::kEventExit, std::move(args)))); |
| 861 } | 862 } |
| 862 | 863 |
| 863 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { | 864 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { |
| 864 content::NavigationController& controller = web_contents()->GetController(); | 865 content::NavigationController& controller = web_contents()->GetController(); |
| 865 content::NavigationEntry* entry = controller.GetVisibleEntry(); | 866 content::NavigationEntry* entry = controller.GetVisibleEntry(); |
| 866 if (!entry) | 867 if (!entry) |
| 867 return; | 868 return; |
| 868 entry->SetIsOverridingUserAgent(!user_agent.empty()); | 869 entry->SetIsOverridingUserAgent(!user_agent.empty()); |
| 869 web_contents()->GetController().Reload(false); | 870 web_contents()->GetController().Reload(false); |
| 870 } | 871 } |
| 871 | 872 |
| 872 void WebViewGuest::FrameNameChanged(RenderFrameHost* render_frame_host, | 873 void WebViewGuest::FrameNameChanged(RenderFrameHost* render_frame_host, |
| 873 const std::string& name) { | 874 const std::string& name) { |
| 874 if (render_frame_host->GetParent()) | 875 if (render_frame_host->GetParent()) |
| 875 return; | 876 return; |
| 876 | 877 |
| 877 if (name_ == name) | 878 if (name_ == name) |
| 878 return; | 879 return; |
| 879 | 880 |
| 880 ReportFrameNameChange(name); | 881 ReportFrameNameChange(name); |
| 881 } | 882 } |
| 882 | 883 |
| 883 void WebViewGuest::ReportFrameNameChange(const std::string& name) { | 884 void WebViewGuest::ReportFrameNameChange(const std::string& name) { |
| 884 name_ = name; | 885 name_ = name; |
| 885 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 886 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 886 args->SetString(webview::kName, name); | 887 args->SetString(webview::kName, name); |
| 887 DispatchEventToView(make_scoped_ptr( | 888 DispatchEventToView(base::WrapUnique( |
| 888 new GuestViewEvent(webview::kEventFrameNameChanged, std::move(args)))); | 889 new GuestViewEvent(webview::kEventFrameNameChanged, std::move(args)))); |
| 889 } | 890 } |
| 890 | 891 |
| 891 void WebViewGuest::LoadHandlerCalled() { | 892 void WebViewGuest::LoadHandlerCalled() { |
| 892 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 893 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 893 DispatchEventToView(make_scoped_ptr( | 894 DispatchEventToView(base::WrapUnique( |
| 894 new GuestViewEvent(webview::kEventContentLoad, std::move(args)))); | 895 new GuestViewEvent(webview::kEventContentLoad, std::move(args)))); |
| 895 } | 896 } |
| 896 | 897 |
| 897 void WebViewGuest::LoadRedirect(const GURL& old_url, | 898 void WebViewGuest::LoadRedirect(const GURL& old_url, |
| 898 const GURL& new_url, | 899 const GURL& new_url, |
| 899 bool is_top_level) { | 900 bool is_top_level) { |
| 900 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 901 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 901 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); | 902 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); |
| 902 args->SetString(webview::kNewURL, new_url.spec()); | 903 args->SetString(webview::kNewURL, new_url.spec()); |
| 903 args->SetString(webview::kOldURL, old_url.spec()); | 904 args->SetString(webview::kOldURL, old_url.spec()); |
| 904 DispatchEventToView(make_scoped_ptr( | 905 DispatchEventToView(base::WrapUnique( |
| 905 new GuestViewEvent(webview::kEventLoadRedirect, std::move(args)))); | 906 new GuestViewEvent(webview::kEventLoadRedirect, std::move(args)))); |
| 906 } | 907 } |
| 907 | 908 |
| 908 void WebViewGuest::PushWebViewStateToIOThread() { | 909 void WebViewGuest::PushWebViewStateToIOThread() { |
| 909 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL(); | 910 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL(); |
| 910 std::string partition_domain; | 911 std::string partition_domain; |
| 911 std::string partition_id; | 912 std::string partition_id; |
| 912 bool in_memory; | 913 bool in_memory; |
| 913 if (!GetGuestPartitionConfigForSite( | 914 if (!GetGuestPartitionConfigForSite( |
| 914 site_url, &partition_domain, &partition_id, &in_memory)) { | 915 site_url, &partition_domain, &partition_id, &in_memory)) { |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 if (is_fullscreen == is_guest_fullscreen_) | 1488 if (is_fullscreen == is_guest_fullscreen_) |
| 1488 return; | 1489 return; |
| 1489 | 1490 |
| 1490 bool was_fullscreen = is_guest_fullscreen_; | 1491 bool was_fullscreen = is_guest_fullscreen_; |
| 1491 is_guest_fullscreen_ = is_fullscreen; | 1492 is_guest_fullscreen_ = is_fullscreen; |
| 1492 // If the embedder entered fullscreen because of us, it should exit fullscreen | 1493 // If the embedder entered fullscreen because of us, it should exit fullscreen |
| 1493 // when we exit fullscreen. | 1494 // when we exit fullscreen. |
| 1494 if (was_fullscreen && GuestMadeEmbedderFullscreen()) { | 1495 if (was_fullscreen && GuestMadeEmbedderFullscreen()) { |
| 1495 // Dispatch a message so we can call document.webkitCancelFullscreen() | 1496 // Dispatch a message so we can call document.webkitCancelFullscreen() |
| 1496 // on the embedder. | 1497 // on the embedder. |
| 1497 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1498 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 1498 DispatchEventToView(make_scoped_ptr( | 1499 DispatchEventToView(base::WrapUnique( |
| 1499 new GuestViewEvent(webview::kEventExitFullscreen, std::move(args)))); | 1500 new GuestViewEvent(webview::kEventExitFullscreen, std::move(args)))); |
| 1500 } | 1501 } |
| 1501 // Since we changed fullscreen state, sending a Resize message ensures that | 1502 // Since we changed fullscreen state, sending a Resize message ensures that |
| 1502 // renderer/ sees the change. | 1503 // renderer/ sees the change. |
| 1503 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); | 1504 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); |
| 1504 } | 1505 } |
| 1505 | 1506 |
| 1506 } // namespace extensions | 1507 } // namespace extensions |
| OLD | NEW |