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

Side by Side Diff: chrome/browser/ui/webui/fileicon_source.cc

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
(...skipping 24 matching lines...) Expand all
35 35
36 // Assuming the url is of the form '/path?query', convert the path portion into 36 // Assuming the url is of the form '/path?query', convert the path portion into
37 // a FilePath and return the resulting |file_path| and |query|. The path 37 // a FilePath and return the resulting |file_path| and |query|. The path
38 // portion may have been encoded using encodeURIComponent(). 38 // portion may have been encoded using encodeURIComponent().
39 void GetFilePathAndQuery(const std::string& url, 39 void GetFilePathAndQuery(const std::string& url,
40 base::FilePath* file_path, 40 base::FilePath* file_path,
41 std::string* query) { 41 std::string* query) {
42 // We receive the url with chrome://fileicon/ stripped but GURL expects it. 42 // We receive the url with chrome://fileicon/ stripped but GURL expects it.
43 const GURL gurl("chrome://fileicon/" + url); 43 const GURL gurl("chrome://fileicon/" + url);
44 std::string path = net::UnescapeURLComponent( 44 std::string path = net::UnescapeURLComponent(
45 gurl.path().substr(1), 45 gurl.path().substr(1).as_string(),
46 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | 46 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
47 net::UnescapeRule::PATH_SEPARATORS | net::UnescapeRule::SPACES); 47 net::UnescapeRule::PATH_SEPARATORS | net::UnescapeRule::SPACES);
48 48
49 *file_path = base::FilePath::FromUTF8Unsafe(path); 49 *file_path = base::FilePath::FromUTF8Unsafe(path);
50 *file_path = file_path->NormalizePathSeparators(); 50 *file_path = file_path->NormalizePathSeparators();
51 query->assign(gurl.query()); 51 query->assign(gurl.query());
52 } 52 }
53 53
54 IconLoader::IconSize SizeStringToIconSize(const std::string& size_string) { 54 IconLoader::IconSize SizeStringToIconSize(const std::string& size_string) {
55 if (size_string == "small") return IconLoader::SMALL; 55 if (size_string == "small") return IconLoader::SMALL;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 details.scale_factor).sk_bitmap(), 155 details.scale_factor).sk_bitmap(),
156 false, 156 false,
157 &icon_data->data()); 157 &icon_data->data());
158 158
159 details.callback.Run(icon_data.get()); 159 details.callback.Run(icon_data.get());
160 } else { 160 } else {
161 // TODO(glen): send a dummy icon. 161 // TODO(glen): send a dummy icon.
162 details.callback.Run(NULL); 162 details.callback.Run(NULL);
163 } 163 }
164 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698