| 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/fileicon_source.h" | 5 #include "chrome/browser/ui/webui/fileicon_source.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (size_string == "large") return IconLoader::LARGE; | 56 if (size_string == "large") return IconLoader::LARGE; |
| 57 // We default to NORMAL if we don't recognize the size_string. Including | 57 // We default to NORMAL if we don't recognize the size_string. Including |
| 58 // size_string=="normal". | 58 // size_string=="normal". |
| 59 return IconLoader::NORMAL; | 59 return IconLoader::NORMAL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Simple parser for data on the query. | 62 // Simple parser for data on the query. |
| 63 void ParseQueryParams(const std::string& query, | 63 void ParseQueryParams(const std::string& query, |
| 64 float* scale_factor, | 64 float* scale_factor, |
| 65 IconLoader::IconSize* icon_size) { | 65 IconLoader::IconSize* icon_size) { |
| 66 typedef std::pair<std::string, std::string> KVPair; | 66 base::StringPairs parameters; |
| 67 std::vector<KVPair> parameters; | |
| 68 if (icon_size) | 67 if (icon_size) |
| 69 *icon_size = IconLoader::NORMAL; | 68 *icon_size = IconLoader::NORMAL; |
| 70 if (scale_factor) | 69 if (scale_factor) |
| 71 *scale_factor = 1.0f; | 70 *scale_factor = 1.0f; |
| 72 base::SplitStringIntoKeyValuePairs(query, '=', '&', ¶meters); | 71 base::SplitStringIntoKeyValuePairs(query, '=', '&', ¶meters); |
| 73 for (std::vector<KVPair>::const_iterator iter = parameters.begin(); | 72 for (base::StringPairs::const_iterator iter = parameters.begin(); |
| 74 iter != parameters.end(); ++iter) { | 73 iter != parameters.end(); ++iter) { |
| 75 if (icon_size && iter->first == kIconSize) | 74 if (icon_size && iter->first == kIconSize) |
| 76 *icon_size = SizeStringToIconSize(iter->second); | 75 *icon_size = SizeStringToIconSize(iter->second); |
| 77 else if (scale_factor && iter->first == kScaleFactor) | 76 else if (scale_factor && iter->first == kScaleFactor) |
| 78 webui::ParseScaleFactor(iter->second, scale_factor); | 77 webui::ParseScaleFactor(iter->second, scale_factor); |
| 79 } | 78 } |
| 80 } | 79 } |
| 81 | 80 |
| 82 } // namespace | 81 } // namespace |
| 83 | 82 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 details.scale_factor).sk_bitmap(), | 153 details.scale_factor).sk_bitmap(), |
| 155 false, | 154 false, |
| 156 &icon_data->data()); | 155 &icon_data->data()); |
| 157 | 156 |
| 158 details.callback.Run(icon_data.get()); | 157 details.callback.Run(icon_data.get()); |
| 159 } else { | 158 } else { |
| 160 // TODO(glen): send a dummy icon. | 159 // TODO(glen): send a dummy icon. |
| 161 details.callback.Run(NULL); | 160 details.callback.Run(NULL); |
| 162 } | 161 } |
| 163 } | 162 } |
| OLD | NEW |