| 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 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 callback.Run(WebContents::Create(params)); | 363 callback.Run(WebContents::Create(params)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void WebViewGuest::DidAttachToEmbedder() { | 366 void WebViewGuest::DidAttachToEmbedder() { |
| 367 ApplyAttributes(*attach_params()); | 367 ApplyAttributes(*attach_params()); |
| 368 } | 368 } |
| 369 | 369 |
| 370 void WebViewGuest::DidDropLink(const GURL& url) { | 370 void WebViewGuest::DidDropLink(const GURL& url) { |
| 371 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 371 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 372 args->SetString(guest_view::kUrl, url.spec()); | 372 args->SetString(guest_view::kUrl, url.spec()); |
| 373 DispatchEventToView( | 373 DispatchEventToView(make_scoped_ptr( |
| 374 new GuestViewEvent(webview::kEventDropLink, std::move(args))); | 374 new GuestViewEvent(webview::kEventDropLink, std::move(args)))); |
| 375 } | 375 } |
| 376 | 376 |
| 377 void WebViewGuest::DidInitialize(const base::DictionaryValue& create_params) { | 377 void WebViewGuest::DidInitialize(const base::DictionaryValue& create_params) { |
| 378 script_executor_.reset( | 378 script_executor_.reset( |
| 379 new ScriptExecutor(web_contents(), &script_observers_)); | 379 new ScriptExecutor(web_contents(), &script_observers_)); |
| 380 | 380 |
| 381 notification_registrar_.Add(this, | 381 notification_registrar_.Add(this, |
| 382 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 382 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 383 content::Source<WebContents>(web_contents())); | 383 content::Source<WebContents>(web_contents())); |
| 384 | 384 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 web_contents()->GetSiteInstance()); | 418 web_contents()->GetSiteInstance()); |
| 419 partition->ClearData( | 419 partition->ClearData( |
| 420 storage_partition_removal_mask, | 420 storage_partition_removal_mask, |
| 421 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), | 421 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), |
| 422 content::StoragePartition::OriginMatcherFunction(), remove_since, | 422 content::StoragePartition::OriginMatcherFunction(), remove_since, |
| 423 base::Time::Now(), callback); | 423 base::Time::Now(), callback); |
| 424 } | 424 } |
| 425 | 425 |
| 426 void WebViewGuest::GuestViewDidStopLoading() { | 426 void WebViewGuest::GuestViewDidStopLoading() { |
| 427 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 427 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 428 DispatchEventToView( | 428 DispatchEventToView(make_scoped_ptr( |
| 429 new GuestViewEvent(webview::kEventLoadStop, std::move(args))); | 429 new GuestViewEvent(webview::kEventLoadStop, std::move(args)))); |
| 430 } | 430 } |
| 431 | 431 |
| 432 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { | 432 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { |
| 433 is_embedder_fullscreen_ = entered_fullscreen; | 433 is_embedder_fullscreen_ = entered_fullscreen; |
| 434 // If the embedder has got out of fullscreen, we get out of fullscreen | 434 // If the embedder has got out of fullscreen, we get out of fullscreen |
| 435 // mode as well. | 435 // mode as well. |
| 436 if (!entered_fullscreen) | 436 if (!entered_fullscreen) |
| 437 SetFullscreenState(false); | 437 SetFullscreenState(false); |
| 438 } | 438 } |
| 439 | 439 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 } | 473 } |
| 474 } | 474 } |
| 475 | 475 |
| 476 void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, | 476 void WebViewGuest::GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, |
| 477 const gfx::Size& new_size) { | 477 const gfx::Size& new_size) { |
| 478 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 478 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 479 args->SetInteger(webview::kOldHeight, old_size.height()); | 479 args->SetInteger(webview::kOldHeight, old_size.height()); |
| 480 args->SetInteger(webview::kOldWidth, old_size.width()); | 480 args->SetInteger(webview::kOldWidth, old_size.width()); |
| 481 args->SetInteger(webview::kNewHeight, new_size.height()); | 481 args->SetInteger(webview::kNewHeight, new_size.height()); |
| 482 args->SetInteger(webview::kNewWidth, new_size.width()); | 482 args->SetInteger(webview::kNewWidth, new_size.width()); |
| 483 DispatchEventToView( | 483 DispatchEventToView(make_scoped_ptr( |
| 484 new GuestViewEvent(webview::kEventSizeChanged, std::move(args))); | 484 new GuestViewEvent(webview::kEventSizeChanged, std::move(args)))); |
| 485 } | 485 } |
| 486 | 486 |
| 487 bool WebViewGuest::IsAutoSizeSupported() const { | 487 bool WebViewGuest::IsAutoSizeSupported() const { |
| 488 return true; | 488 return true; |
| 489 } | 489 } |
| 490 | 490 |
| 491 void WebViewGuest::GuestZoomChanged(double old_zoom_level, | 491 void WebViewGuest::GuestZoomChanged(double old_zoom_level, |
| 492 double new_zoom_level) { | 492 double new_zoom_level) { |
| 493 // Dispatch the zoomchange event. | 493 // Dispatch the zoomchange event. |
| 494 double old_zoom_factor = ConvertZoomLevelToZoomFactor(old_zoom_level); | 494 double old_zoom_factor = ConvertZoomLevelToZoomFactor(old_zoom_level); |
| 495 double new_zoom_factor = ConvertZoomLevelToZoomFactor(new_zoom_level); | 495 double new_zoom_factor = ConvertZoomLevelToZoomFactor(new_zoom_level); |
| 496 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 496 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 497 args->SetDouble(webview::kOldZoomFactor, old_zoom_factor); | 497 args->SetDouble(webview::kOldZoomFactor, old_zoom_factor); |
| 498 args->SetDouble(webview::kNewZoomFactor, new_zoom_factor); | 498 args->SetDouble(webview::kNewZoomFactor, new_zoom_factor); |
| 499 DispatchEventToView( | 499 DispatchEventToView(make_scoped_ptr( |
| 500 new GuestViewEvent(webview::kEventZoomChange, std::move(args))); | 500 new GuestViewEvent(webview::kEventZoomChange, std::move(args)))); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void WebViewGuest::WillDestroy() { | 503 void WebViewGuest::WillDestroy() { |
| 504 if (!attached() && GetOpener()) | 504 if (!attached() && GetOpener()) |
| 505 GetOpener()->pending_new_windows_.erase(this); | 505 GetOpener()->pending_new_windows_.erase(this); |
| 506 } | 506 } |
| 507 | 507 |
| 508 bool WebViewGuest::AddMessageToConsole(WebContents* source, | 508 bool WebViewGuest::AddMessageToConsole(WebContents* source, |
| 509 int32_t level, | 509 int32_t level, |
| 510 const base::string16& message, | 510 const base::string16& message, |
| 511 int32_t line_no, | 511 int32_t line_no, |
| 512 const base::string16& source_id) { | 512 const base::string16& source_id) { |
| 513 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 513 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 514 // Log levels are from base/logging.h: LogSeverity. | 514 // Log levels are from base/logging.h: LogSeverity. |
| 515 args->SetInteger(webview::kLevel, level); | 515 args->SetInteger(webview::kLevel, level); |
| 516 args->SetString(webview::kMessage, message); | 516 args->SetString(webview::kMessage, message); |
| 517 args->SetInteger(webview::kLine, line_no); | 517 args->SetInteger(webview::kLine, line_no); |
| 518 args->SetString(webview::kSourceId, source_id); | 518 args->SetString(webview::kSourceId, source_id); |
| 519 DispatchEventToView( | 519 DispatchEventToView(make_scoped_ptr( |
| 520 new GuestViewEvent(webview::kEventConsoleMessage, std::move(args))); | 520 new GuestViewEvent(webview::kEventConsoleMessage, std::move(args)))); |
| 521 return true; | 521 return true; |
| 522 } | 522 } |
| 523 | 523 |
| 524 void WebViewGuest::CloseContents(WebContents* source) { | 524 void WebViewGuest::CloseContents(WebContents* source) { |
| 525 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 525 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 526 DispatchEventToView( | 526 DispatchEventToView(make_scoped_ptr( |
| 527 new GuestViewEvent(webview::kEventClose, std::move(args))); | 527 new GuestViewEvent(webview::kEventClose, std::move(args)))); |
| 528 } | 528 } |
| 529 | 529 |
| 530 void WebViewGuest::FindReply(WebContents* source, | 530 void WebViewGuest::FindReply(WebContents* source, |
| 531 int request_id, | 531 int request_id, |
| 532 int number_of_matches, | 532 int number_of_matches, |
| 533 const gfx::Rect& selection_rect, | 533 const gfx::Rect& selection_rect, |
| 534 int active_match_ordinal, | 534 int active_match_ordinal, |
| 535 bool final_update) { | 535 bool final_update) { |
| 536 GuestViewBase::FindReply(source, request_id, number_of_matches, | 536 GuestViewBase::FindReply(source, request_id, number_of_matches, |
| 537 selection_rect, active_match_ordinal, final_update); | 537 selection_rect, active_match_ordinal, final_update); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 567 | 567 |
| 568 bool WebViewGuest::PreHandleGestureEvent(WebContents* source, | 568 bool WebViewGuest::PreHandleGestureEvent(WebContents* source, |
| 569 const blink::WebGestureEvent& event) { | 569 const blink::WebGestureEvent& event) { |
| 570 return !allow_scaling_ && GuestViewBase::PreHandleGestureEvent(source, event); | 570 return !allow_scaling_ && GuestViewBase::PreHandleGestureEvent(source, event); |
| 571 } | 571 } |
| 572 | 572 |
| 573 void WebViewGuest::LoadProgressChanged(WebContents* source, double progress) { | 573 void WebViewGuest::LoadProgressChanged(WebContents* source, double progress) { |
| 574 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 574 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 575 args->SetString(guest_view::kUrl, web_contents()->GetURL().spec()); | 575 args->SetString(guest_view::kUrl, web_contents()->GetURL().spec()); |
| 576 args->SetDouble(webview::kProgress, progress); | 576 args->SetDouble(webview::kProgress, progress); |
| 577 DispatchEventToView( | 577 DispatchEventToView(make_scoped_ptr( |
| 578 new GuestViewEvent(webview::kEventLoadProgress, std::move(args))); | 578 new GuestViewEvent(webview::kEventLoadProgress, std::move(args)))); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void WebViewGuest::LoadAbort(bool is_top_level, | 581 void WebViewGuest::LoadAbort(bool is_top_level, |
| 582 const GURL& url, | 582 const GURL& url, |
| 583 int error_code, | 583 int error_code, |
| 584 const std::string& error_type) { | 584 const std::string& error_type) { |
| 585 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 585 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 586 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); | 586 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); |
| 587 args->SetString(guest_view::kUrl, url.possibly_invalid_spec()); | 587 args->SetString(guest_view::kUrl, url.possibly_invalid_spec()); |
| 588 args->SetInteger(guest_view::kCode, error_code); | 588 args->SetInteger(guest_view::kCode, error_code); |
| 589 args->SetString(guest_view::kReason, error_type); | 589 args->SetString(guest_view::kReason, error_type); |
| 590 DispatchEventToView( | 590 DispatchEventToView(make_scoped_ptr( |
| 591 new GuestViewEvent(webview::kEventLoadAbort, std::move(args))); | 591 new GuestViewEvent(webview::kEventLoadAbort, std::move(args)))); |
| 592 } | 592 } |
| 593 | 593 |
| 594 void WebViewGuest::SetContextMenuPosition(const gfx::Point& position) { | 594 void WebViewGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 595 if (web_view_guest_delegate_) | 595 if (web_view_guest_delegate_) |
| 596 web_view_guest_delegate_->SetContextMenuPosition(position); | 596 web_view_guest_delegate_->SetContextMenuPosition(position); |
| 597 } | 597 } |
| 598 | 598 |
| 599 void WebViewGuest::CreateNewGuestWebViewWindow( | 599 void WebViewGuest::CreateNewGuestWebViewWindow( |
| 600 const content::OpenURLParams& params) { | 600 const content::OpenURLParams& params) { |
| 601 GuestViewManager* guest_manager = | 601 GuestViewManager* guest_manager = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 632 params.user_gesture, | 632 params.user_gesture, |
| 633 new_guest->web_contents()); | 633 new_guest->web_contents()); |
| 634 } | 634 } |
| 635 | 635 |
| 636 // TODO(fsamuel): Find a reliable way to test the 'responsive' and | 636 // TODO(fsamuel): Find a reliable way to test the 'responsive' and |
| 637 // 'unresponsive' events. | 637 // 'unresponsive' events. |
| 638 void WebViewGuest::RendererResponsive(WebContents* source) { | 638 void WebViewGuest::RendererResponsive(WebContents* source) { |
| 639 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 639 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 640 args->SetInteger(webview::kProcessId, | 640 args->SetInteger(webview::kProcessId, |
| 641 web_contents()->GetRenderProcessHost()->GetID()); | 641 web_contents()->GetRenderProcessHost()->GetID()); |
| 642 DispatchEventToView( | 642 DispatchEventToView(make_scoped_ptr( |
| 643 new GuestViewEvent(webview::kEventResponsive, std::move(args))); | 643 new GuestViewEvent(webview::kEventResponsive, std::move(args)))); |
| 644 } | 644 } |
| 645 | 645 |
| 646 void WebViewGuest::RendererUnresponsive(WebContents* source) { | 646 void WebViewGuest::RendererUnresponsive(WebContents* source) { |
| 647 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 647 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 648 args->SetInteger(webview::kProcessId, | 648 args->SetInteger(webview::kProcessId, |
| 649 web_contents()->GetRenderProcessHost()->GetID()); | 649 web_contents()->GetRenderProcessHost()->GetID()); |
| 650 DispatchEventToView( | 650 DispatchEventToView(make_scoped_ptr( |
| 651 new GuestViewEvent(webview::kEventUnresponsive, std::move(args))); | 651 new GuestViewEvent(webview::kEventUnresponsive, std::move(args)))); |
| 652 } | 652 } |
| 653 | 653 |
| 654 void WebViewGuest::Observe(int type, | 654 void WebViewGuest::Observe(int type, |
| 655 const content::NotificationSource& source, | 655 const content::NotificationSource& source, |
| 656 const content::NotificationDetails& details) { | 656 const content::NotificationDetails& details) { |
| 657 switch (type) { | 657 switch (type) { |
| 658 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { | 658 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { |
| 659 DCHECK_EQ(content::Source<WebContents>(source).ptr(), web_contents()); | 659 DCHECK_EQ(content::Source<WebContents>(source).ptr(), web_contents()); |
| 660 if (content::Source<WebContents>(source).ptr() == web_contents()) | 660 if (content::Source<WebContents>(source).ptr() == web_contents()) |
| 661 LoadHandlerCalled(); | 661 LoadHandlerCalled(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 ->GetController() | 808 ->GetController() |
| 809 .GetLastCommittedEntry() | 809 .GetLastCommittedEntry() |
| 810 ->GetBaseURLForDataURL() | 810 ->GetBaseURLForDataURL() |
| 811 .spec()); | 811 .spec()); |
| 812 args->SetInteger(webview::kInternalCurrentEntryIndex, | 812 args->SetInteger(webview::kInternalCurrentEntryIndex, |
| 813 web_contents()->GetController().GetCurrentEntryIndex()); | 813 web_contents()->GetController().GetCurrentEntryIndex()); |
| 814 args->SetInteger(webview::kInternalEntryCount, | 814 args->SetInteger(webview::kInternalEntryCount, |
| 815 web_contents()->GetController().GetEntryCount()); | 815 web_contents()->GetController().GetEntryCount()); |
| 816 args->SetInteger(webview::kInternalProcessId, | 816 args->SetInteger(webview::kInternalProcessId, |
| 817 web_contents()->GetRenderProcessHost()->GetID()); | 817 web_contents()->GetRenderProcessHost()->GetID()); |
| 818 DispatchEventToView( | 818 DispatchEventToView(make_scoped_ptr( |
| 819 new GuestViewEvent(webview::kEventLoadCommit, std::move(args))); | 819 new GuestViewEvent(webview::kEventLoadCommit, std::move(args)))); |
| 820 | 820 |
| 821 find_helper_.CancelAllFindSessions(); | 821 find_helper_.CancelAllFindSessions(); |
| 822 } | 822 } |
| 823 | 823 |
| 824 void WebViewGuest::DidFailProvisionalLoad( | 824 void WebViewGuest::DidFailProvisionalLoad( |
| 825 content::RenderFrameHost* render_frame_host, | 825 content::RenderFrameHost* render_frame_host, |
| 826 const GURL& validated_url, | 826 const GURL& validated_url, |
| 827 int error_code, | 827 int error_code, |
| 828 const base::string16& error_description, | 828 const base::string16& error_description, |
| 829 bool was_ignored_by_handler) { | 829 bool was_ignored_by_handler) { |
| 830 // Suppress loadabort for "mailto" URLs. | 830 // Suppress loadabort for "mailto" URLs. |
| 831 if (validated_url.SchemeIs(url::kMailToScheme)) | 831 if (validated_url.SchemeIs(url::kMailToScheme)) |
| 832 return; | 832 return; |
| 833 | 833 |
| 834 LoadAbort(!render_frame_host->GetParent(), validated_url, error_code, | 834 LoadAbort(!render_frame_host->GetParent(), validated_url, error_code, |
| 835 net::ErrorToShortString(error_code)); | 835 net::ErrorToShortString(error_code)); |
| 836 } | 836 } |
| 837 | 837 |
| 838 void WebViewGuest::DidStartProvisionalLoadForFrame( | 838 void WebViewGuest::DidStartProvisionalLoadForFrame( |
| 839 content::RenderFrameHost* render_frame_host, | 839 content::RenderFrameHost* render_frame_host, |
| 840 const GURL& validated_url, | 840 const GURL& validated_url, |
| 841 bool is_error_page, | 841 bool is_error_page, |
| 842 bool is_iframe_srcdoc) { | 842 bool is_iframe_srcdoc) { |
| 843 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 843 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 844 args->SetString(guest_view::kUrl, validated_url.spec()); | 844 args->SetString(guest_view::kUrl, validated_url.spec()); |
| 845 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); | 845 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); |
| 846 DispatchEventToView( | 846 DispatchEventToView(make_scoped_ptr( |
| 847 new GuestViewEvent(webview::kEventLoadStart, std::move(args))); | 847 new GuestViewEvent(webview::kEventLoadStart, std::move(args)))); |
| 848 } | 848 } |
| 849 | 849 |
| 850 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { | 850 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { |
| 851 // Cancel all find sessions in progress. | 851 // Cancel all find sessions in progress. |
| 852 find_helper_.CancelAllFindSessions(); | 852 find_helper_.CancelAllFindSessions(); |
| 853 | 853 |
| 854 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 854 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 855 args->SetInteger(webview::kProcessId, | 855 args->SetInteger(webview::kProcessId, |
| 856 web_contents()->GetRenderProcessHost()->GetID()); | 856 web_contents()->GetRenderProcessHost()->GetID()); |
| 857 args->SetString(webview::kReason, TerminationStatusToString(status)); | 857 args->SetString(webview::kReason, TerminationStatusToString(status)); |
| 858 DispatchEventToView(new GuestViewEvent(webview::kEventExit, std::move(args))); | 858 DispatchEventToView(make_scoped_ptr( |
| 859 new GuestViewEvent(webview::kEventExit, std::move(args)))); |
| 859 } | 860 } |
| 860 | 861 |
| 861 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { | 862 void WebViewGuest::UserAgentOverrideSet(const std::string& user_agent) { |
| 862 content::NavigationController& controller = web_contents()->GetController(); | 863 content::NavigationController& controller = web_contents()->GetController(); |
| 863 content::NavigationEntry* entry = controller.GetVisibleEntry(); | 864 content::NavigationEntry* entry = controller.GetVisibleEntry(); |
| 864 if (!entry) | 865 if (!entry) |
| 865 return; | 866 return; |
| 866 entry->SetIsOverridingUserAgent(!user_agent.empty()); | 867 entry->SetIsOverridingUserAgent(!user_agent.empty()); |
| 867 web_contents()->GetController().Reload(false); | 868 web_contents()->GetController().Reload(false); |
| 868 } | 869 } |
| 869 | 870 |
| 870 void WebViewGuest::FrameNameChanged(RenderFrameHost* render_frame_host, | 871 void WebViewGuest::FrameNameChanged(RenderFrameHost* render_frame_host, |
| 871 const std::string& name) { | 872 const std::string& name) { |
| 872 if (render_frame_host->GetParent()) | 873 if (render_frame_host->GetParent()) |
| 873 return; | 874 return; |
| 874 | 875 |
| 875 if (name_ == name) | 876 if (name_ == name) |
| 876 return; | 877 return; |
| 877 | 878 |
| 878 ReportFrameNameChange(name); | 879 ReportFrameNameChange(name); |
| 879 } | 880 } |
| 880 | 881 |
| 881 void WebViewGuest::ReportFrameNameChange(const std::string& name) { | 882 void WebViewGuest::ReportFrameNameChange(const std::string& name) { |
| 882 name_ = name; | 883 name_ = name; |
| 883 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 884 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 884 args->SetString(webview::kName, name); | 885 args->SetString(webview::kName, name); |
| 885 DispatchEventToView( | 886 DispatchEventToView(make_scoped_ptr( |
| 886 new GuestViewEvent(webview::kEventFrameNameChanged, std::move(args))); | 887 new GuestViewEvent(webview::kEventFrameNameChanged, std::move(args)))); |
| 887 } | 888 } |
| 888 | 889 |
| 889 void WebViewGuest::LoadHandlerCalled() { | 890 void WebViewGuest::LoadHandlerCalled() { |
| 890 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 891 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 891 DispatchEventToView( | 892 DispatchEventToView(make_scoped_ptr( |
| 892 new GuestViewEvent(webview::kEventContentLoad, std::move(args))); | 893 new GuestViewEvent(webview::kEventContentLoad, std::move(args)))); |
| 893 } | 894 } |
| 894 | 895 |
| 895 void WebViewGuest::LoadRedirect(const GURL& old_url, | 896 void WebViewGuest::LoadRedirect(const GURL& old_url, |
| 896 const GURL& new_url, | 897 const GURL& new_url, |
| 897 bool is_top_level) { | 898 bool is_top_level) { |
| 898 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 899 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 899 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); | 900 args->SetBoolean(guest_view::kIsTopLevel, is_top_level); |
| 900 args->SetString(webview::kNewURL, new_url.spec()); | 901 args->SetString(webview::kNewURL, new_url.spec()); |
| 901 args->SetString(webview::kOldURL, old_url.spec()); | 902 args->SetString(webview::kOldURL, old_url.spec()); |
| 902 DispatchEventToView( | 903 DispatchEventToView(make_scoped_ptr( |
| 903 new GuestViewEvent(webview::kEventLoadRedirect, std::move(args))); | 904 new GuestViewEvent(webview::kEventLoadRedirect, std::move(args)))); |
| 904 } | 905 } |
| 905 | 906 |
| 906 void WebViewGuest::PushWebViewStateToIOThread() { | 907 void WebViewGuest::PushWebViewStateToIOThread() { |
| 907 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL(); | 908 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL(); |
| 908 std::string partition_domain; | 909 std::string partition_domain; |
| 909 std::string partition_id; | 910 std::string partition_id; |
| 910 bool in_memory; | 911 bool in_memory; |
| 911 if (!GetGuestPartitionConfigForSite( | 912 if (!GetGuestPartitionConfigForSite( |
| 912 site_url, &partition_domain, &partition_id, &in_memory)) { | 913 site_url, &partition_domain, &partition_id, &in_memory)) { |
| 913 NOTREACHED(); | 914 NOTREACHED(); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } | 1131 } |
| 1131 | 1132 |
| 1132 // Only read the src attribute if this is not a New Window API flow. | 1133 // Only read the src attribute if this is not a New Window API flow. |
| 1133 if (!is_pending_new_window) { | 1134 if (!is_pending_new_window) { |
| 1134 std::string src; | 1135 std::string src; |
| 1135 if (params.GetString(webview::kAttributeSrc, &src)) | 1136 if (params.GetString(webview::kAttributeSrc, &src)) |
| 1136 NavigateGuest(src, true /* force_navigation */); | 1137 NavigateGuest(src, true /* force_navigation */); |
| 1137 } | 1138 } |
| 1138 } | 1139 } |
| 1139 | 1140 |
| 1140 void WebViewGuest::ShowContextMenu( | 1141 void WebViewGuest::ShowContextMenu(int request_id) { |
| 1141 int request_id, | |
| 1142 const WebViewGuestDelegate::MenuItemVector* items) { | |
| 1143 if (web_view_guest_delegate_) | 1142 if (web_view_guest_delegate_) |
| 1144 web_view_guest_delegate_->OnShowContextMenu(request_id, items); | 1143 web_view_guest_delegate_->OnShowContextMenu(request_id); |
| 1145 } | 1144 } |
| 1146 | 1145 |
| 1147 void WebViewGuest::SetName(const std::string& name) { | 1146 void WebViewGuest::SetName(const std::string& name) { |
| 1148 if (name_ == name) | 1147 if (name_ == name) |
| 1149 return; | 1148 return; |
| 1150 name_ = name; | 1149 name_ = name; |
| 1151 | 1150 |
| 1152 Send(new ExtensionMsg_SetFrameName(routing_id(), name_)); | 1151 Send(new ExtensionMsg_SetFrameName(routing_id(), name_)); |
| 1153 } | 1152 } |
| 1154 | 1153 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 return; | 1487 return; |
| 1489 | 1488 |
| 1490 bool was_fullscreen = is_guest_fullscreen_; | 1489 bool was_fullscreen = is_guest_fullscreen_; |
| 1491 is_guest_fullscreen_ = is_fullscreen; | 1490 is_guest_fullscreen_ = is_fullscreen; |
| 1492 // If the embedder entered fullscreen because of us, it should exit fullscreen | 1491 // If the embedder entered fullscreen because of us, it should exit fullscreen |
| 1493 // when we exit fullscreen. | 1492 // when we exit fullscreen. |
| 1494 if (was_fullscreen && GuestMadeEmbedderFullscreen()) { | 1493 if (was_fullscreen && GuestMadeEmbedderFullscreen()) { |
| 1495 // Dispatch a message so we can call document.webkitCancelFullscreen() | 1494 // Dispatch a message so we can call document.webkitCancelFullscreen() |
| 1496 // on the embedder. | 1495 // on the embedder. |
| 1497 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1496 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 1498 DispatchEventToView( | 1497 DispatchEventToView(make_scoped_ptr( |
| 1499 new GuestViewEvent(webview::kEventExitFullscreen, std::move(args))); | 1498 new GuestViewEvent(webview::kEventExitFullscreen, std::move(args)))); |
| 1500 } | 1499 } |
| 1501 // Since we changed fullscreen state, sending a Resize message ensures that | 1500 // Since we changed fullscreen state, sending a Resize message ensures that |
| 1502 // renderer/ sees the change. | 1501 // renderer/ sees the change. |
| 1503 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); | 1502 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); |
| 1504 } | 1503 } |
| 1505 | 1504 |
| 1506 } // namespace extensions | 1505 } // namespace extensions |
| OLD | NEW |