OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/web_ui_util.h" | 5 #include "chrome/browser/ui/webui/web_ui_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 CHECK(args->GetDouble(start_index++, &button)); | 72 CHECK(args->GetDouble(start_index++, &button)); |
73 CHECK(args->GetBoolean(start_index++, &alt_key)); | 73 CHECK(args->GetBoolean(start_index++, &alt_key)); |
74 CHECK(args->GetBoolean(start_index++, &ctrl_key)); | 74 CHECK(args->GetBoolean(start_index++, &ctrl_key)); |
75 CHECK(args->GetBoolean(start_index++, &meta_key)); | 75 CHECK(args->GetBoolean(start_index++, &meta_key)); |
76 CHECK(args->GetBoolean(start_index++, &shift_key)); | 76 CHECK(args->GetBoolean(start_index++, &shift_key)); |
77 return disposition_utils::DispositionFromClick(button == 1.0, alt_key, | 77 return disposition_utils::DispositionFromClick(button == 1.0, alt_key, |
78 ctrl_key, meta_key, shift_key); | 78 ctrl_key, meta_key, shift_key); |
79 | 79 |
80 } | 80 } |
81 | 81 |
82 ui::ScaleFactor ParseScaleFactor(const base::StringPiece& identifier) { | 82 bool ParseScaleFactor(const base::StringPiece& identifier, |
83 ui::ScaleFactor* scale_factor) { | |
84 *scale_factor = ui::SCALE_FACTOR_NONE; | |
83 for (size_t i = 0; i < arraysize(kScaleFactorMap); i++) { | 85 for (size_t i = 0; i < arraysize(kScaleFactorMap); i++) { |
84 if (identifier == kScaleFactorMap[i].name) | 86 if (identifier == kScaleFactorMap[i].name) { |
85 return kScaleFactorMap[i].scale_factor; | 87 *scale_factor = kScaleFactorMap[i].scale_factor; |
88 return true; | |
89 } | |
86 } | 90 } |
87 return ui::SCALE_FACTOR_NONE; | 91 return false; |
88 } | 92 } |
89 | 93 |
90 void ParsePathAndScale(const GURL& url, | 94 void ParsePathAndScale(const GURL& url, |
91 std::string* path, | 95 std::string* path, |
92 ui::ScaleFactor* scale_factor) { | 96 ui::ScaleFactor* scale_factor) { |
93 *path = net::UnescapeURLComponent(url.path().substr(1), | 97 *path = net::UnescapeURLComponent(url.path().substr(1), |
94 (net::UnescapeRule::URL_SPECIAL_CHARS | | 98 (net::UnescapeRule::URL_SPECIAL_CHARS | |
95 net::UnescapeRule::SPACES)); | 99 net::UnescapeRule::SPACES)); |
96 if (scale_factor) | 100 if (scale_factor) |
97 *scale_factor = ui::SCALE_FACTOR_100P; | 101 *scale_factor = ui::SCALE_FACTOR_100P; |
98 | 102 |
99 // Detect and parse resource string ending in @<scale>x. | 103 // Detect and parse resource string ending in @<scale>x. |
100 std::size_t pos = path->rfind('@'); | 104 std::size_t pos = path->rfind('@'); |
101 if (pos != std::string::npos) { | 105 if (pos != std::string::npos) { |
102 base::StringPiece stripped_path(*path); | 106 base::StringPiece stripped_path(*path); |
103 if (scale_factor) { | 107 ui::ScaleFactor factor; |
104 *scale_factor = ParseScaleFactor(stripped_path.substr( | 108 |
105 pos + 1, stripped_path.length() - pos - 1)); | 109 if (ParseScaleFactor(stripped_path.substr( |
110 pos + 1, stripped_path.length() - pos - 1), &factor)) { | |
Evan Stade
2012/08/16 18:57:49
2 more indent
sadrul
2012/08/16 19:00:33
Done.
| |
111 // Strip scale factor specification from path. | |
112 stripped_path.remove_suffix(stripped_path.length() - pos); | |
113 stripped_path.CopyToString(path); | |
106 } | 114 } |
107 // Strip scale factor specification from path. | 115 if (scale_factor) |
108 stripped_path.remove_suffix(stripped_path.length() - pos); | 116 *scale_factor = factor; |
109 stripped_path.CopyToString(path); | |
110 } | 117 } |
111 } | 118 } |
112 | 119 |
113 } // namespace web_ui_util | 120 } // namespace web_ui_util |
OLD | NEW |