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 if (params.HasKey(guestview::kElementSizeIsLogical)) { | |
Fady Samuel
2015/03/03 17:50:58
This check seems unnecessary. Just call GetBoolean
paulmeyer
2015/03/03 20:36:23
Done.
| |
762 params.GetBoolean(guestview::kElementSizeIsLogical, | |
763 &element_size_is_logical); | |
764 } | |
765 int normal_height = 0; | |
766 int normal_width = 0; | |
767 if (element_size_is_logical) { | |
768 // Convert the element size from logical pixels to physical pixels. | |
769 normal_height = LogicalPixelsToPhysicalPixels(element_height); | |
770 normal_width = LogicalPixelsToPhysicalPixels(element_width); | |
771 } else { | |
772 normal_height = lround(element_height); | |
773 normal_width = lround(element_width); | |
774 } | |
760 | 775 |
761 SetSizeParams set_size_params; | 776 SetSizeParams set_size_params; |
762 set_size_params.enable_auto_size.reset(new bool(auto_size_enabled)); | 777 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)); | 778 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)); | 779 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)); | 780 set_size_params.normal_size.reset(new gfx::Size(normal_width, normal_height)); |
766 | 781 |
767 // Call SetSize to apply all the appropriate validation and clipping of | 782 // Call SetSize to apply all the appropriate validation and clipping of |
768 // values. | 783 // values. |
769 SetSize(set_size_params); | 784 SetSize(set_size_params); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
801 void GuestViewBase::RegisterGuestViewTypes() { | 816 void GuestViewBase::RegisterGuestViewTypes() { |
802 AppViewGuest::Register(); | 817 AppViewGuest::Register(); |
803 ExtensionOptionsGuest::Register(); | 818 ExtensionOptionsGuest::Register(); |
804 ExtensionViewGuest::Register(); | 819 ExtensionViewGuest::Register(); |
805 MimeHandlerViewGuest::Register(); | 820 MimeHandlerViewGuest::Register(); |
806 SurfaceWorkerGuest::Register(); | 821 SurfaceWorkerGuest::Register(); |
807 WebViewGuest::Register(); | 822 WebViewGuest::Register(); |
808 } | 823 } |
809 | 824 |
810 } // namespace extensions | 825 } // namespace extensions |
OLD | NEW |