Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: chrome/browser/ui/webui/web_ui_util.cc

Issue 10837270: webui: Change slightly how the scale-factor gets parsed from a URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: indent Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/web_ui_util.h ('k') | chrome/browser/ui/webui/web_ui_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/web_ui_util.cc
diff --git a/chrome/browser/ui/webui/web_ui_util.cc b/chrome/browser/ui/webui/web_ui_util.cc
index c1ba2d569ee41488412db026c8debb6b0d311be7..08614d3d508bdb786021a80b644bd8cc08810ec9 100644
--- a/chrome/browser/ui/webui/web_ui_util.cc
+++ b/chrome/browser/ui/webui/web_ui_util.cc
@@ -79,12 +79,16 @@ WindowOpenDisposition GetDispositionFromClick(const ListValue* args,
}
-ui::ScaleFactor ParseScaleFactor(const base::StringPiece& identifier) {
+bool ParseScaleFactor(const base::StringPiece& identifier,
+ ui::ScaleFactor* scale_factor) {
+ *scale_factor = ui::SCALE_FACTOR_NONE;
for (size_t i = 0; i < arraysize(kScaleFactorMap); i++) {
- if (identifier == kScaleFactorMap[i].name)
- return kScaleFactorMap[i].scale_factor;
+ if (identifier == kScaleFactorMap[i].name) {
+ *scale_factor = kScaleFactorMap[i].scale_factor;
+ return true;
+ }
}
- return ui::SCALE_FACTOR_NONE;
+ return false;
}
void ParsePathAndScale(const GURL& url,
@@ -100,13 +104,16 @@ void ParsePathAndScale(const GURL& url,
std::size_t pos = path->rfind('@');
if (pos != std::string::npos) {
base::StringPiece stripped_path(*path);
- if (scale_factor) {
- *scale_factor = ParseScaleFactor(stripped_path.substr(
- pos + 1, stripped_path.length() - pos - 1));
+ ui::ScaleFactor factor;
+
+ if (ParseScaleFactor(stripped_path.substr(
+ pos + 1, stripped_path.length() - pos - 1), &factor)) {
+ // Strip scale factor specification from path.
+ stripped_path.remove_suffix(stripped_path.length() - pos);
+ stripped_path.CopyToString(path);
}
- // Strip scale factor specification from path.
- stripped_path.remove_suffix(stripped_path.length() - pos);
- stripped_path.CopyToString(path);
+ if (scale_factor)
+ *scale_factor = factor;
}
}
« no previous file with comments | « chrome/browser/ui/webui/web_ui_util.h ('k') | chrome/browser/ui/webui/web_ui_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698