Chromium Code Reviews| 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 | 436 |
| 437 void WebViewGuest::HandleKeyboardEvent( | 437 void WebViewGuest::HandleKeyboardEvent( |
| 438 WebContents* source, | 438 WebContents* source, |
| 439 const content::NativeWebKeyboardEvent& event) { | 439 const content::NativeWebKeyboardEvent& event) { |
| 440 if (HandleKeyboardShortcuts(event)) | 440 if (HandleKeyboardShortcuts(event)) |
| 441 return; | 441 return; |
| 442 | 442 |
| 443 GuestViewBase::HandleKeyboardEvent(source, event); | 443 GuestViewBase::HandleKeyboardEvent(source, event); |
| 444 } | 444 } |
| 445 | 445 |
| 446 bool WebViewGuest::PreHandleGestureEvent(content::WebContents* source, | |
| 447 const blink::WebGestureEvent& event) { | |
| 448 return allow_scaling_ ? false | |
|
Fady Samuel
2015/02/12 21:27:09
return !allow_scaling_ && GuestViewBase::PreHandle
wjmaclean
2015/02/12 21:41:25
Done.
| |
| 449 : GuestViewBase::PreHandleGestureEvent(source, event); | |
| 450 } | |
| 451 | |
| 446 void WebViewGuest::LoadProgressChanged(content::WebContents* source, | 452 void WebViewGuest::LoadProgressChanged(content::WebContents* source, |
| 447 double progress) { | 453 double progress) { |
| 448 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 454 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 449 args->SetString(guestview::kUrl, web_contents()->GetURL().spec()); | 455 args->SetString(guestview::kUrl, web_contents()->GetURL().spec()); |
| 450 args->SetDouble(webview::kProgress, progress); | 456 args->SetDouble(webview::kProgress, progress); |
| 451 DispatchEventToView( | 457 DispatchEventToView( |
| 452 new GuestViewBase::Event(webview::kEventLoadProgress, args.Pass())); | 458 new GuestViewBase::Event(webview::kEventLoadProgress, args.Pass())); |
| 453 } | 459 } |
| 454 | 460 |
| 455 void WebViewGuest::LoadAbort(bool is_top_level, | 461 void WebViewGuest::LoadAbort(bool is_top_level, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 } | 637 } |
| 632 | 638 |
| 633 WebViewGuest::WebViewGuest(content::WebContents* owner_web_contents) | 639 WebViewGuest::WebViewGuest(content::WebContents* owner_web_contents) |
| 634 : GuestView<WebViewGuest>(owner_web_contents), | 640 : GuestView<WebViewGuest>(owner_web_contents), |
| 635 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID), | 641 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID), |
| 636 find_helper_(this), | 642 find_helper_(this), |
| 637 is_overriding_user_agent_(false), | 643 is_overriding_user_agent_(false), |
| 638 guest_opaque_(true), | 644 guest_opaque_(true), |
| 639 javascript_dialog_helper_(this), | 645 javascript_dialog_helper_(this), |
| 640 current_zoom_factor_(1.0), | 646 current_zoom_factor_(1.0), |
| 647 allow_scaling_(false), | |
| 641 weak_ptr_factory_(this) { | 648 weak_ptr_factory_(this) { |
| 642 web_view_guest_delegate_.reset( | 649 web_view_guest_delegate_.reset( |
| 643 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); | 650 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); |
| 644 } | 651 } |
| 645 | 652 |
| 646 WebViewGuest::~WebViewGuest() { | 653 WebViewGuest::~WebViewGuest() { |
| 647 } | 654 } |
| 648 | 655 |
| 649 void WebViewGuest::DidCommitProvisionalLoadForFrame( | 656 void WebViewGuest::DidCommitProvisionalLoadForFrame( |
| 650 content::RenderFrameHost* render_frame_host, | 657 content::RenderFrameHost* render_frame_host, |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 959 std::string user_agent_override; | 966 std::string user_agent_override; |
| 960 params.GetString(webview::kParameterUserAgentOverride, &user_agent_override); | 967 params.GetString(webview::kParameterUserAgentOverride, &user_agent_override); |
| 961 SetUserAgentOverride(user_agent_override); | 968 SetUserAgentOverride(user_agent_override); |
| 962 | 969 |
| 963 bool allow_transparency = false; | 970 bool allow_transparency = false; |
| 964 params.GetBoolean(webview::kAttributeAllowTransparency, &allow_transparency); | 971 params.GetBoolean(webview::kAttributeAllowTransparency, &allow_transparency); |
| 965 // We need to set the background opaque flag after navigation to ensure that | 972 // We need to set the background opaque flag after navigation to ensure that |
| 966 // there is a RenderWidgetHostView available. | 973 // there is a RenderWidgetHostView available. |
| 967 SetAllowTransparency(allow_transparency); | 974 SetAllowTransparency(allow_transparency); |
| 968 | 975 |
| 976 bool allow_scaling = false; | |
| 977 params.GetBoolean(webview::kAttributeAllowScaling, &allow_scaling); | |
| 978 SetAllowScaling(allow_scaling); | |
| 979 | |
| 969 bool is_pending_new_window = false; | 980 bool is_pending_new_window = false; |
| 970 if (GetOpener()) { | 981 if (GetOpener()) { |
| 971 // We need to do a navigation here if the target URL has changed between | 982 // We need to do a navigation here if the target URL has changed between |
| 972 // the time the WebContents was created and the time it was attached. | 983 // the time the WebContents was created and the time it was attached. |
| 973 // We also need to do an initial navigation if a RenderView was never | 984 // We also need to do an initial navigation if a RenderView was never |
| 974 // created for the new window in cases where there is no referrer. | 985 // created for the new window in cases where there is no referrer. |
| 975 auto it = GetOpener()->pending_new_windows_.find(this); | 986 auto it = GetOpener()->pending_new_windows_.find(this); |
| 976 if (it != GetOpener()->pending_new_windows_.end()) { | 987 if (it != GetOpener()->pending_new_windows_.end()) { |
| 977 const NewWindowInfo& new_window_info = it->second; | 988 const NewWindowInfo& new_window_info = it->second; |
| 978 if (new_window_info.changed || !web_contents()->HasOpener()) | 989 if (new_window_info.changed || !web_contents()->HasOpener()) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1037 web_contents() | 1048 web_contents() |
| 1038 ->GetRenderViewHost() | 1049 ->GetRenderViewHost() |
| 1039 ->GetView() | 1050 ->GetView() |
| 1040 ->SetBackgroundColorToDefault(); | 1051 ->SetBackgroundColorToDefault(); |
| 1041 } else { | 1052 } else { |
| 1042 web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor( | 1053 web_contents()->GetRenderViewHost()->GetView()->SetBackgroundColor( |
| 1043 SK_ColorTRANSPARENT); | 1054 SK_ColorTRANSPARENT); |
| 1044 } | 1055 } |
| 1045 } | 1056 } |
| 1046 | 1057 |
| 1058 void WebViewGuest::SetAllowScaling(bool allow) { | |
| 1059 allow_scaling_ = allow; | |
| 1060 } | |
| 1061 | |
| 1047 bool WebViewGuest::LoadDataWithBaseURL(const std::string& data_url, | 1062 bool WebViewGuest::LoadDataWithBaseURL(const std::string& data_url, |
| 1048 const std::string& base_url, | 1063 const std::string& base_url, |
| 1049 const std::string& virtual_url, | 1064 const std::string& virtual_url, |
| 1050 std::string* error) { | 1065 std::string* error) { |
| 1051 // Make GURLs from URLs. | 1066 // Make GURLs from URLs. |
| 1052 const GURL data_gurl = GURL(data_url); | 1067 const GURL data_gurl = GURL(data_url); |
| 1053 const GURL base_gurl = GURL(base_url); | 1068 const GURL base_gurl = GURL(base_url); |
| 1054 const GURL virtual_gurl = GURL(virtual_url); | 1069 const GURL virtual_gurl = GURL(virtual_url); |
| 1055 | 1070 |
| 1056 // Check that the provided URLs are valid. | 1071 // Check that the provided URLs are valid. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1218 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), | 1233 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), |
| 1219 new_window_instance_id); | 1234 new_window_instance_id); |
| 1220 if (!guest) | 1235 if (!guest) |
| 1221 return; | 1236 return; |
| 1222 | 1237 |
| 1223 if (!allow) | 1238 if (!allow) |
| 1224 guest->Destroy(); | 1239 guest->Destroy(); |
| 1225 } | 1240 } |
| 1226 | 1241 |
| 1227 } // namespace extensions | 1242 } // namespace extensions |
| OLD | NEW |