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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 434 } |
435 | 435 |
436 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { | 436 void WebViewGuest::EmbedderFullscreenToggled(bool entered_fullscreen) { |
437 is_embedder_fullscreen_ = entered_fullscreen; | 437 is_embedder_fullscreen_ = entered_fullscreen; |
438 // If the embedder has got out of fullscreen, we get out of fullscreen | 438 // If the embedder has got out of fullscreen, we get out of fullscreen |
439 // mode as well. | 439 // mode as well. |
440 if (!entered_fullscreen) | 440 if (!entered_fullscreen) |
441 SetFullscreenState(false); | 441 SetFullscreenState(false); |
442 } | 442 } |
443 | 443 |
| 444 bool WebViewGuest::ZoomPropagatesFromEmbedderToGuest() const { |
| 445 // We use the embedder's zoom iff we haven't set a zoom ourselves using |
| 446 // e.g. webview.setZoom(). |
| 447 return !did_set_explicit_zoom_; |
| 448 } |
| 449 |
444 const char* WebViewGuest::GetAPINamespace() const { | 450 const char* WebViewGuest::GetAPINamespace() const { |
445 return webview::kAPINamespace; | 451 return webview::kAPINamespace; |
446 } | 452 } |
447 | 453 |
448 int WebViewGuest::GetTaskPrefix() const { | 454 int WebViewGuest::GetTaskPrefix() const { |
449 return IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX; | 455 return IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX; |
450 } | 456 } |
451 | 457 |
452 void WebViewGuest::GuestDestroyed() { | 458 void WebViewGuest::GuestDestroyed() { |
453 RemoveWebViewStateFromIOThread(web_contents()); | 459 RemoveWebViewStateFromIOThread(web_contents()); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID), | 780 rules_registry_id_(RulesRegistryService::kInvalidRulesRegistryID), |
775 find_helper_(this), | 781 find_helper_(this), |
776 is_overriding_user_agent_(false), | 782 is_overriding_user_agent_(false), |
777 allow_transparency_(false), | 783 allow_transparency_(false), |
778 javascript_dialog_helper_(this), | 784 javascript_dialog_helper_(this), |
779 allow_scaling_(false), | 785 allow_scaling_(false), |
780 is_guest_fullscreen_(false), | 786 is_guest_fullscreen_(false), |
781 is_embedder_fullscreen_(false), | 787 is_embedder_fullscreen_(false), |
782 last_fullscreen_permission_was_allowed_by_embedder_(false), | 788 last_fullscreen_permission_was_allowed_by_embedder_(false), |
783 pending_zoom_factor_(0.0), | 789 pending_zoom_factor_(0.0), |
| 790 did_set_explicit_zoom_(false), |
784 weak_ptr_factory_(this) { | 791 weak_ptr_factory_(this) { |
785 web_view_guest_delegate_.reset( | 792 web_view_guest_delegate_.reset( |
786 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); | 793 ExtensionsAPIClient::Get()->CreateWebViewGuestDelegate(this)); |
787 } | 794 } |
788 | 795 |
789 WebViewGuest::~WebViewGuest() { | 796 WebViewGuest::~WebViewGuest() { |
790 } | 797 } |
791 | 798 |
792 void WebViewGuest::DidCommitProvisionalLoadForFrame( | 799 void WebViewGuest::DidCommitProvisionalLoadForFrame( |
793 content::RenderFrameHost* render_frame_host, | 800 content::RenderFrameHost* render_frame_host, |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 | 1155 |
1149 void WebViewGuest::SetName(const std::string& name) { | 1156 void WebViewGuest::SetName(const std::string& name) { |
1150 if (name_ == name) | 1157 if (name_ == name) |
1151 return; | 1158 return; |
1152 name_ = name; | 1159 name_ = name; |
1153 | 1160 |
1154 Send(new ExtensionMsg_SetFrameName(routing_id(), name_)); | 1161 Send(new ExtensionMsg_SetFrameName(routing_id(), name_)); |
1155 } | 1162 } |
1156 | 1163 |
1157 void WebViewGuest::SetZoom(double zoom_factor) { | 1164 void WebViewGuest::SetZoom(double zoom_factor) { |
| 1165 did_set_explicit_zoom_ = true; |
1158 auto* zoom_controller = ZoomController::FromWebContents(web_contents()); | 1166 auto* zoom_controller = ZoomController::FromWebContents(web_contents()); |
1159 DCHECK(zoom_controller); | 1167 DCHECK(zoom_controller); |
1160 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); | 1168 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); |
1161 zoom_controller->SetZoomLevel(zoom_level); | 1169 zoom_controller->SetZoomLevel(zoom_level); |
1162 } | 1170 } |
1163 | 1171 |
1164 void WebViewGuest::SetZoomMode(ZoomController::ZoomMode zoom_mode) { | 1172 void WebViewGuest::SetZoomMode(ZoomController::ZoomMode zoom_mode) { |
1165 ZoomController::FromWebContents(web_contents())->SetZoomMode(zoom_mode); | 1173 ZoomController::FromWebContents(web_contents())->SetZoomMode(zoom_mode); |
1166 } | 1174 } |
1167 | 1175 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 1507 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
1500 DispatchEventToView(base::WrapUnique( | 1508 DispatchEventToView(base::WrapUnique( |
1501 new GuestViewEvent(webview::kEventExitFullscreen, std::move(args)))); | 1509 new GuestViewEvent(webview::kEventExitFullscreen, std::move(args)))); |
1502 } | 1510 } |
1503 // Since we changed fullscreen state, sending a Resize message ensures that | 1511 // Since we changed fullscreen state, sending a Resize message ensures that |
1504 // renderer/ sees the change. | 1512 // renderer/ sees the change. |
1505 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); | 1513 web_contents()->GetRenderViewHost()->GetWidget()->WasResized(); |
1506 } | 1514 } |
1507 | 1515 |
1508 } // namespace extensions | 1516 } // namespace extensions |
OLD | NEW |