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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 int min_width = 0; | 747 int min_width = 0; |
748 params.GetInteger(guestview::kAttributeMinHeight, &min_height); | 748 params.GetInteger(guestview::kAttributeMinHeight, &min_height); |
749 params.GetInteger(guestview::kAttributeMinWidth, &min_width); | 749 params.GetInteger(guestview::kAttributeMinWidth, &min_width); |
750 | 750 |
751 // Set the normal size to the element size so that the guestview will fit the | 751 // Set the normal size to the element size so that the guestview will fit the |
752 // element initially if autosize is disabled. | 752 // element initially if autosize is disabled. |
753 double element_height = 0.0; | 753 double element_height = 0.0; |
754 double element_width = 0.0; | 754 double element_width = 0.0; |
755 params.GetDouble(guestview::kElementHeight, &element_height); | 755 params.GetDouble(guestview::kElementHeight, &element_height); |
756 params.GetDouble(guestview::kElementWidth, &element_width); | 756 params.GetDouble(guestview::kElementWidth, &element_width); |
757 // Convert the element size from logical pixels to physical pixels. | 757 |
758 int normal_height = LogicalPixelsToPhysicalPixels(element_height); | 758 // If the element size was provided in logical units (versus physical), then |
759 int normal_width = LogicalPixelsToPhysicalPixels(element_width); | 759 // it will be converted to physical units. |
| 760 bool element_size_is_logical = false; |
| 761 params.GetBoolean(guestview::kElementSizeIsLogical, &element_size_is_logical); |
| 762 int normal_height = 0; |
| 763 int normal_width = 0; |
| 764 if (element_size_is_logical) { |
| 765 // Convert the element size from logical pixels to physical pixels. |
| 766 normal_height = LogicalPixelsToPhysicalPixels(element_height); |
| 767 normal_width = LogicalPixelsToPhysicalPixels(element_width); |
| 768 } else { |
| 769 normal_height = lround(element_height); |
| 770 normal_width = lround(element_width); |
| 771 } |
760 | 772 |
761 SetSizeParams set_size_params; | 773 SetSizeParams set_size_params; |
762 set_size_params.enable_auto_size.reset(new bool(auto_size_enabled)); | 774 set_size_params.enable_auto_size.reset(new bool(auto_size_enabled)); |
763 set_size_params.min_size.reset(new gfx::Size(min_width, min_height)); | 775 set_size_params.min_size.reset(new gfx::Size(min_width, min_height)); |
764 set_size_params.max_size.reset(new gfx::Size(max_width, max_height)); | 776 set_size_params.max_size.reset(new gfx::Size(max_width, max_height)); |
765 set_size_params.normal_size.reset(new gfx::Size(normal_width, normal_height)); | 777 set_size_params.normal_size.reset(new gfx::Size(normal_width, normal_height)); |
766 | 778 |
767 // Call SetSize to apply all the appropriate validation and clipping of | 779 // Call SetSize to apply all the appropriate validation and clipping of |
768 // values. | 780 // values. |
769 SetSize(set_size_params); | 781 SetSize(set_size_params); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 void GuestViewBase::RegisterGuestViewTypes() { | 813 void GuestViewBase::RegisterGuestViewTypes() { |
802 AppViewGuest::Register(); | 814 AppViewGuest::Register(); |
803 ExtensionOptionsGuest::Register(); | 815 ExtensionOptionsGuest::Register(); |
804 ExtensionViewGuest::Register(); | 816 ExtensionViewGuest::Register(); |
805 MimeHandlerViewGuest::Register(); | 817 MimeHandlerViewGuest::Register(); |
806 SurfaceWorkerGuest::Register(); | 818 SurfaceWorkerGuest::Register(); |
807 WebViewGuest::Register(); | 819 WebViewGuest::Register(); |
808 } | 820 } |
809 | 821 |
810 } // namespace extensions | 822 } // namespace extensions |
OLD | NEW |