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/guest_view_base.h" | 5 #include "extensions/browser/guest_view/guest_view_base.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/ui/zoom/page_zoom.h" | 9 #include "components/ui/zoom/page_zoom.h" |
| 10 #include "components/ui/zoom/zoom_controller.h" | 10 #include "components/ui/zoom/zoom_controller.h" |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 ui_zoom::ZoomController::FromWebContents(embedder_web_contents()); | 777 ui_zoom::ZoomController::FromWebContents(embedder_web_contents()); |
| 778 if (!zoom_controller) | 778 if (!zoom_controller) |
| 779 return 1.0; | 779 return 1.0; |
| 780 | 780 |
| 781 double zoom_factor = | 781 double zoom_factor = |
| 782 content::ZoomLevelToZoomFactor(zoom_controller->GetZoomLevel()); | 782 content::ZoomLevelToZoomFactor(zoom_controller->GetZoomLevel()); |
| 783 return zoom_factor; | 783 return zoom_factor; |
| 784 } | 784 } |
| 785 | 785 |
| 786 void GuestViewBase::SetUpSizing(const base::DictionaryValue& params) { | 786 void GuestViewBase::SetUpSizing(const base::DictionaryValue& params) { |
| 787 SetSizeParams set_size_params; | |
|
paulmeyer
2015/03/27 22:40:40
Why is set_size_params declared up here now?
Fady Samuel
2015/03/27 22:56:36
Done.
| |
| 787 // Read the autosize parameters passed in from the embedder. | 788 // Read the autosize parameters passed in from the embedder. |
| 788 bool auto_size_enabled = false; | 789 bool auto_size_enabled = auto_size_enabled_; |
| 789 params.GetBoolean(guestview::kAttributeAutoSize, &auto_size_enabled); | 790 params.GetBoolean(guestview::kAttributeAutoSize, &auto_size_enabled); |
| 790 | 791 |
| 791 int max_height = 0; | 792 int max_height = max_auto_size_.height(); |
| 792 int max_width = 0; | 793 int max_width = max_auto_size_.width(); |
| 793 params.GetInteger(guestview::kAttributeMaxHeight, &max_height); | 794 params.GetInteger(guestview::kAttributeMaxHeight, &max_height); |
| 794 params.GetInteger(guestview::kAttributeMaxWidth, &max_width); | 795 params.GetInteger(guestview::kAttributeMaxWidth, &max_width); |
| 795 | 796 |
| 796 int min_height = 0; | 797 int min_height = min_auto_size_.height(); |
| 797 int min_width = 0; | 798 int min_width = min_auto_size_.width(); |
| 798 params.GetInteger(guestview::kAttributeMinHeight, &min_height); | 799 params.GetInteger(guestview::kAttributeMinHeight, &min_height); |
| 799 params.GetInteger(guestview::kAttributeMinWidth, &min_width); | 800 params.GetInteger(guestview::kAttributeMinWidth, &min_width); |
| 800 | 801 |
| 801 int normal_height = 0; | 802 int normal_height = normal_size_.height(); |
| 802 int normal_width = 0; | 803 int normal_width = normal_size_.width(); |
| 803 if (is_full_page_plugin()) { | 804 if (is_full_page_plugin()) { |
| 804 // The initial size of a full page plugin should be set to fill the | 805 // The initial size of a full page plugin should be set to fill the |
| 805 // owner's visible viewport. | 806 // owner's visible viewport. |
| 806 auto owner_size = owner_web_contents()->GetRenderWidgetHostView()-> | 807 auto owner_size = owner_web_contents()->GetRenderWidgetHostView()-> |
| 807 GetVisibleViewportSize(); | 808 GetVisibleViewportSize(); |
| 808 normal_height = owner_size.height(); | 809 normal_height = owner_size.height(); |
| 809 normal_width = owner_size.width(); | 810 normal_width = owner_size.width(); |
| 810 } else { | 811 } else { |
| 811 // Set the normal size to the element size so that the guestview will fit | 812 // Set the normal size to the element size so that the guestview will fit |
| 812 // the element initially if autosize is disabled. | 813 // the element initially if autosize is disabled. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 823 if (element_size_is_logical) { | 824 if (element_size_is_logical) { |
| 824 // Convert the element size from logical pixels to physical pixels. | 825 // Convert the element size from logical pixels to physical pixels. |
| 825 normal_height = LogicalPixelsToPhysicalPixels(element_height); | 826 normal_height = LogicalPixelsToPhysicalPixels(element_height); |
| 826 normal_width = LogicalPixelsToPhysicalPixels(element_width); | 827 normal_width = LogicalPixelsToPhysicalPixels(element_width); |
| 827 } else { | 828 } else { |
| 828 normal_height = lround(element_height); | 829 normal_height = lround(element_height); |
| 829 normal_width = lround(element_width); | 830 normal_width = lround(element_width); |
| 830 } | 831 } |
| 831 } | 832 } |
| 832 | 833 |
| 833 SetSizeParams set_size_params; | |
| 834 set_size_params.enable_auto_size.reset(new bool(auto_size_enabled)); | 834 set_size_params.enable_auto_size.reset(new bool(auto_size_enabled)); |
| 835 set_size_params.min_size.reset(new gfx::Size(min_width, min_height)); | 835 set_size_params.min_size.reset(new gfx::Size(min_width, min_height)); |
| 836 set_size_params.max_size.reset(new gfx::Size(max_width, max_height)); | 836 set_size_params.max_size.reset(new gfx::Size(max_width, max_height)); |
| 837 set_size_params.normal_size.reset(new gfx::Size(normal_width, normal_height)); | 837 set_size_params.normal_size.reset(new gfx::Size(normal_width, normal_height)); |
| 838 | 838 |
| 839 // Call SetSize to apply all the appropriate validation and clipping of | 839 // Call SetSize to apply all the appropriate validation and clipping of |
| 840 // values. | 840 // values. |
| 841 SetSize(set_size_params); | 841 SetSize(set_size_params); |
| 842 } | 842 } |
| 843 | 843 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 883 void GuestViewBase::RegisterGuestViewTypes() { | 883 void GuestViewBase::RegisterGuestViewTypes() { |
| 884 AppViewGuest::Register(); | 884 AppViewGuest::Register(); |
| 885 ExtensionOptionsGuest::Register(); | 885 ExtensionOptionsGuest::Register(); |
| 886 ExtensionViewGuest::Register(); | 886 ExtensionViewGuest::Register(); |
| 887 MimeHandlerViewGuest::Register(); | 887 MimeHandlerViewGuest::Register(); |
| 888 SurfaceWorkerGuest::Register(); | 888 SurfaceWorkerGuest::Register(); |
| 889 WebViewGuest::Register(); | 889 WebViewGuest::Register(); |
| 890 } | 890 } |
| 891 | 891 |
| 892 } // namespace extensions | 892 } // namespace extensions |
| OLD | NEW |