| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chrome_page_zoom.h" |
| 6 |
| 5 #include <algorithm> | 7 #include <algorithm> |
| 6 #include <cmath> | 8 #include <cmath> |
| 7 | 9 |
| 8 #include "chrome/browser/chrome_page_zoom.h" | 10 #include "chrome/browser/chrome_page_zoom_constants.h" |
| 9 #include "content/public/common/page_zoom.h" | 11 #include "content/public/common/page_zoom.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 11 | 13 |
| 12 namespace chrome_page_zoom { | 14 namespace chrome_page_zoom { |
| 13 | 15 |
| 14 enum PageZoomValueType { | 16 enum PageZoomValueType { |
| 15 PAGE_ZOOM_VALUE_TYPE_FACTOR, | 17 PAGE_ZOOM_VALUE_TYPE_FACTOR, |
| 16 PAGE_ZOOM_VALUE_TYPE_LEVEL, | 18 PAGE_ZOOM_VALUE_TYPE_LEVEL, |
| 17 }; | 19 }; |
| 18 | 20 |
| 19 const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0, | |
| 20 1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0, | |
| 21 5.0 }; | |
| 22 const size_t kPresetZoomFactorsSize = arraysize(kPresetZoomFactors); | |
| 23 | |
| 24 std::vector<double> PresetZoomValues(PageZoomValueType value_type, | 21 std::vector<double> PresetZoomValues(PageZoomValueType value_type, |
| 25 double custom_value) { | 22 double custom_value) { |
| 26 // Generate a vector of zoom values from an array of known preset | 23 // Generate a vector of zoom values from an array of known preset |
| 27 // factors. The values in content::kPresetZoomFactors will already be in | 24 // factors. The values in content::kPresetZoomFactors will already be in |
| 28 // sorted order. | 25 // sorted order. |
| 29 std::vector<double> zoom_values; | 26 std::vector<double> zoom_values; |
| 30 bool found_custom = false; | 27 bool found_custom = false; |
| 31 for (size_t i = 0; i < kPresetZoomFactorsSize; i++) { | 28 for (size_t i = 0; i < kPresetZoomFactorsSize; i++) { |
| 32 double zoom_value = kPresetZoomFactors[i]; | 29 double zoom_value = kPresetZoomFactors[i]; |
| 33 if (value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL) | 30 if (value_type == PAGE_ZOOM_VALUE_TYPE_LEVEL) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 | 50 |
| 54 std::vector<double> PresetZoomFactors(double custom_factor) { | 51 std::vector<double> PresetZoomFactors(double custom_factor) { |
| 55 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_FACTOR, custom_factor); | 52 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_FACTOR, custom_factor); |
| 56 } | 53 } |
| 57 | 54 |
| 58 std::vector<double> PresetZoomLevels(double custom_level) { | 55 std::vector<double> PresetZoomLevels(double custom_level) { |
| 59 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_LEVEL, custom_level); | 56 return PresetZoomValues(PAGE_ZOOM_VALUE_TYPE_LEVEL, custom_level); |
| 60 } | 57 } |
| 61 | 58 |
| 62 } // namespace chrome_page_zoom | 59 } // namespace chrome_page_zoom |
| OLD | NEW |