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 "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 web_view_guest_delegate_.reset( | 622 web_view_guest_delegate_.reset( |
623 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); | 623 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); |
624 } | 624 } |
625 | 625 |
626 WebViewGuest::~WebViewGuest() { | 626 WebViewGuest::~WebViewGuest() { |
627 } | 627 } |
628 | 628 |
629 void WebViewGuest::DidCommitProvisionalLoadForFrame( | 629 void WebViewGuest::DidCommitProvisionalLoadForFrame( |
630 content::RenderFrameHost* render_frame_host, | 630 content::RenderFrameHost* render_frame_host, |
631 const GURL& url, | 631 const GURL& url, |
632 content::PageTransition transition_type) { | 632 ui::PageTransition transition_type) { |
633 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 633 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
634 args->SetString(guestview::kUrl, url.spec()); | 634 args->SetString(guestview::kUrl, url.spec()); |
635 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent()); | 635 args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent()); |
636 args->SetInteger(webview::kInternalCurrentEntryIndex, | 636 args->SetInteger(webview::kInternalCurrentEntryIndex, |
637 web_contents()->GetController().GetCurrentEntryIndex()); | 637 web_contents()->GetController().GetCurrentEntryIndex()); |
638 args->SetInteger(webview::kInternalEntryCount, | 638 args->SetInteger(webview::kInternalEntryCount, |
639 web_contents()->GetController().GetEntryCount()); | 639 web_contents()->GetController().GetEntryCount()); |
640 args->SetInteger(webview::kInternalProcessId, | 640 args->SetInteger(webview::kInternalProcessId, |
641 web_contents()->GetRenderProcessHost()->GetID()); | 641 web_contents()->GetRenderProcessHost()->GetID()); |
642 DispatchEventToEmbedder( | 642 DispatchEventToEmbedder( |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 } | 862 } |
863 | 863 |
864 GURL validated_url(url); | 864 GURL validated_url(url); |
865 web_contents()->GetRenderProcessHost()->FilterURL(false, &validated_url); | 865 web_contents()->GetRenderProcessHost()->FilterURL(false, &validated_url); |
866 // As guests do not swap processes on navigation, only navigations to | 866 // As guests do not swap processes on navigation, only navigations to |
867 // normal web URLs are supported. No protocol handlers are installed for | 867 // normal web URLs are supported. No protocol handlers are installed for |
868 // other schemes (e.g., WebUI or extensions), and no permissions or bindings | 868 // other schemes (e.g., WebUI or extensions), and no permissions or bindings |
869 // can be granted to the guest process. | 869 // can be granted to the guest process. |
870 LoadURLWithParams(validated_url, | 870 LoadURLWithParams(validated_url, |
871 content::Referrer(), | 871 content::Referrer(), |
872 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 872 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
873 web_contents()); | 873 web_contents()); |
874 } | 874 } |
875 | 875 |
876 bool WebViewGuest::HandleKeyboardShortcuts( | 876 bool WebViewGuest::HandleKeyboardShortcuts( |
877 const content::NativeWebKeyboardEvent& event) { | 877 const content::NativeWebKeyboardEvent& event) { |
878 if (event.type != blink::WebInputEvent::RawKeyDown) | 878 if (event.type != blink::WebInputEvent::RawKeyDown) |
879 return false; | 879 return false; |
880 | 880 |
881 // If the user hits the escape key without any modifiers then unlock the | 881 // If the user hits the escape key without any modifiers then unlock the |
882 // mouse if necessary. | 882 // mouse if necessary. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 CHECK(guest); | 1008 CHECK(guest); |
1009 guest->SetOpener(this); | 1009 guest->SetOpener(this); |
1010 std::string guest_name = base::UTF16ToUTF8(frame_name); | 1010 std::string guest_name = base::UTF16ToUTF8(frame_name); |
1011 guest->name_ = guest_name; | 1011 guest->name_ = guest_name; |
1012 pending_new_windows_.insert( | 1012 pending_new_windows_.insert( |
1013 std::make_pair(guest, NewWindowInfo(target_url, guest_name))); | 1013 std::make_pair(guest, NewWindowInfo(target_url, guest_name))); |
1014 } | 1014 } |
1015 | 1015 |
1016 void WebViewGuest::LoadURLWithParams(const GURL& url, | 1016 void WebViewGuest::LoadURLWithParams(const GURL& url, |
1017 const content::Referrer& referrer, | 1017 const content::Referrer& referrer, |
1018 content::PageTransition transition_type, | 1018 ui::PageTransition transition_type, |
1019 content::WebContents* web_contents) { | 1019 content::WebContents* web_contents) { |
1020 content::NavigationController::LoadURLParams load_url_params(url); | 1020 content::NavigationController::LoadURLParams load_url_params(url); |
1021 load_url_params.referrer = referrer; | 1021 load_url_params.referrer = referrer; |
1022 load_url_params.transition_type = transition_type; | 1022 load_url_params.transition_type = transition_type; |
1023 load_url_params.extra_headers = std::string(); | 1023 load_url_params.extra_headers = std::string(); |
1024 if (is_overriding_user_agent_) { | 1024 if (is_overriding_user_agent_) { |
1025 load_url_params.override_user_agent = | 1025 load_url_params.override_user_agent = |
1026 content::NavigationController::UA_OVERRIDE_TRUE; | 1026 content::NavigationController::UA_OVERRIDE_TRUE; |
1027 } | 1027 } |
1028 web_contents->GetController().LoadURLWithParams(load_url_params); | 1028 web_contents->GetController().LoadURLWithParams(load_url_params); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 WebViewGuest* guest = | 1103 WebViewGuest* guest = |
1104 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1104 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1105 if (!guest) | 1105 if (!guest) |
1106 return; | 1106 return; |
1107 | 1107 |
1108 if (!allow) | 1108 if (!allow) |
1109 guest->Destroy(); | 1109 guest->Destroy(); |
1110 } | 1110 } |
1111 | 1111 |
1112 } // namespace extensions | 1112 } // namespace extensions |
OLD | NEW |