| 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 "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" | 10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 new ScriptExecutor(web_contents(), &script_observers_)); | 323 new ScriptExecutor(web_contents(), &script_observers_)); |
| 324 | 324 |
| 325 notification_registrar_.Add(this, | 325 notification_registrar_.Add(this, |
| 326 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 326 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 327 content::Source<WebContents>(web_contents())); | 327 content::Source<WebContents>(web_contents())); |
| 328 | 328 |
| 329 notification_registrar_.Add(this, | 329 notification_registrar_.Add(this, |
| 330 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 330 content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 331 content::Source<WebContents>(web_contents())); | 331 content::Source<WebContents>(web_contents())); |
| 332 | 332 |
| 333 if (web_view_guest_delegate_) | |
| 334 web_view_guest_delegate_->OnDidInitialize(); | |
| 335 AttachWebViewHelpers(web_contents()); | 333 AttachWebViewHelpers(web_contents()); |
| 336 | 334 |
| 337 rules_registry_id_ = GetOrGenerateRulesRegistryID( | 335 rules_registry_id_ = GetOrGenerateRulesRegistryID( |
| 338 owner_web_contents()->GetRenderProcessHost()->GetID(), | 336 owner_web_contents()->GetRenderProcessHost()->GetID(), |
| 339 view_instance_id()); | 337 view_instance_id()); |
| 340 | 338 |
| 341 // We must install the mapping from guests to WebViews prior to resuming | 339 // We must install the mapping from guests to WebViews prior to resuming |
| 342 // suspended resource loads so that the WebRequest API will catch resource | 340 // suspended resource loads so that the WebRequest API will catch resource |
| 343 // requests. | 341 // requests. |
| 344 PushWebViewStateToIOThread(); | 342 PushWebViewStateToIOThread(); |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 args->SetInteger(webview::kInternalCurrentEntryIndex, | 777 args->SetInteger(webview::kInternalCurrentEntryIndex, |
| 780 web_contents()->GetController().GetCurrentEntryIndex()); | 778 web_contents()->GetController().GetCurrentEntryIndex()); |
| 781 args->SetInteger(webview::kInternalEntryCount, | 779 args->SetInteger(webview::kInternalEntryCount, |
| 782 web_contents()->GetController().GetEntryCount()); | 780 web_contents()->GetController().GetEntryCount()); |
| 783 args->SetInteger(webview::kInternalProcessId, | 781 args->SetInteger(webview::kInternalProcessId, |
| 784 web_contents()->GetRenderProcessHost()->GetID()); | 782 web_contents()->GetRenderProcessHost()->GetID()); |
| 785 DispatchEventToView( | 783 DispatchEventToView( |
| 786 new GuestViewEvent(webview::kEventLoadCommit, args.Pass())); | 784 new GuestViewEvent(webview::kEventLoadCommit, args.Pass())); |
| 787 | 785 |
| 788 find_helper_.CancelAllFindSessions(); | 786 find_helper_.CancelAllFindSessions(); |
| 789 | |
| 790 if (web_view_guest_delegate_) { | |
| 791 web_view_guest_delegate_->OnDidCommitProvisionalLoadForFrame( | |
| 792 !render_frame_host->GetParent()); | |
| 793 } | |
| 794 } | 787 } |
| 795 | 788 |
| 796 void WebViewGuest::DidFailProvisionalLoad( | 789 void WebViewGuest::DidFailProvisionalLoad( |
| 797 content::RenderFrameHost* render_frame_host, | 790 content::RenderFrameHost* render_frame_host, |
| 798 const GURL& validated_url, | 791 const GURL& validated_url, |
| 799 int error_code, | 792 int error_code, |
| 800 const base::string16& error_description) { | 793 const base::string16& error_description) { |
| 801 LoadAbort(!render_frame_host->GetParent(), validated_url, error_code, | 794 LoadAbort(!render_frame_host->GetParent(), validated_url, error_code, |
| 802 net::ErrorToShortString(error_code)); | 795 net::ErrorToShortString(error_code)); |
| 803 } | 796 } |
| 804 | 797 |
| 805 void WebViewGuest::DidStartProvisionalLoadForFrame( | 798 void WebViewGuest::DidStartProvisionalLoadForFrame( |
| 806 content::RenderFrameHost* render_frame_host, | 799 content::RenderFrameHost* render_frame_host, |
| 807 const GURL& validated_url, | 800 const GURL& validated_url, |
| 808 bool is_error_page, | 801 bool is_error_page, |
| 809 bool is_iframe_srcdoc) { | 802 bool is_iframe_srcdoc) { |
| 810 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 803 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 811 args->SetString(guest_view::kUrl, validated_url.spec()); | 804 args->SetString(guest_view::kUrl, validated_url.spec()); |
| 812 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); | 805 args->SetBoolean(guest_view::kIsTopLevel, !render_frame_host->GetParent()); |
| 813 DispatchEventToView( | 806 DispatchEventToView( |
| 814 new GuestViewEvent(webview::kEventLoadStart, args.Pass())); | 807 new GuestViewEvent(webview::kEventLoadStart, args.Pass())); |
| 815 } | 808 } |
| 816 | 809 |
| 817 void WebViewGuest::DocumentLoadedInFrame( | |
| 818 content::RenderFrameHost* render_frame_host) { | |
| 819 if (web_view_guest_delegate_) | |
| 820 web_view_guest_delegate_->OnDocumentLoadedInFrame(render_frame_host); | |
| 821 } | |
| 822 | |
| 823 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { | 810 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { |
| 824 // Cancel all find sessions in progress. | 811 // Cancel all find sessions in progress. |
| 825 find_helper_.CancelAllFindSessions(); | 812 find_helper_.CancelAllFindSessions(); |
| 826 | 813 |
| 827 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 814 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 828 args->SetInteger(webview::kProcessId, | 815 args->SetInteger(webview::kProcessId, |
| 829 web_contents()->GetRenderProcessHost()->GetID()); | 816 web_contents()->GetRenderProcessHost()->GetID()); |
| 830 args->SetString(webview::kReason, TerminationStatusToString(status)); | 817 args->SetString(webview::kReason, TerminationStatusToString(status)); |
| 831 DispatchEventToView( | 818 DispatchEventToView( |
| 832 new GuestViewEvent(webview::kEventExit, args.Pass())); | 819 new GuestViewEvent(webview::kEventExit, args.Pass())); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1439 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 1453 DispatchEventToView( | 1440 DispatchEventToView( |
| 1454 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); | 1441 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); |
| 1455 } | 1442 } |
| 1456 // Since we changed fullscreen state, sending a Resize message ensures that | 1443 // Since we changed fullscreen state, sending a Resize message ensures that |
| 1457 // renderer/ sees the change. | 1444 // renderer/ sees the change. |
| 1458 web_contents()->GetRenderViewHost()->WasResized(); | 1445 web_contents()->GetRenderViewHost()->WasResized(); |
| 1459 } | 1446 } |
| 1460 | 1447 |
| 1461 } // namespace extensions | 1448 } // namespace extensions |
| OLD | NEW |