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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/screenlock_icon_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/login/screenlock_icon_source.h" 5 #include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h"
6 6
7 #include "chrome/browser/chromeos/login/lock/screen_locker.h" 7 #include "chrome/browser/chromeos/login/lock/screen_locker.h"
8 #include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_provider.h" 8 #include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_provider.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
(...skipping 26 matching lines...) Expand all
37 const std::string& path, 37 const std::string& path,
38 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, 38 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
39 const content::URLDataSource::GotDataCallback& callback) { 39 const content::URLDataSource::GotDataCallback& callback) {
40 if (!icon_provider_) { 40 if (!icon_provider_) {
41 callback.Run(GetDefaultIcon().As1xPNGBytes().get()); 41 callback.Run(GetDefaultIcon().As1xPNGBytes().get());
42 return; 42 return;
43 } 43 }
44 44
45 GURL url(chrome::kChromeUIScreenlockIconURL + path); 45 GURL url(chrome::kChromeUIScreenlockIconURL + path);
46 std::string username = net::UnescapeURLComponent( 46 std::string username = net::UnescapeURLComponent(
47 url.path().substr(1), 47 url.path().as_string().substr(1),
48 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | 48 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
49 net::UnescapeRule::PATH_SEPARATORS | net::UnescapeRule::SPACES); 49 net::UnescapeRule::PATH_SEPARATORS | net::UnescapeRule::SPACES);
50 50
51 gfx::Image image = icon_provider_->GetIcon(username); 51 gfx::Image image = icon_provider_->GetIcon(username);
52 if (image.IsEmpty()) { 52 if (image.IsEmpty()) {
53 callback.Run(GetDefaultIcon().As1xPNGBytes().get()); 53 callback.Run(GetDefaultIcon().As1xPNGBytes().get());
54 return; 54 return;
55 } 55 }
56 56
57 callback.Run(image.As1xPNGBytes().get()); 57 callback.Run(image.As1xPNGBytes().get());
58 } 58 }
59 59
60 std::string ScreenlockIconSource::GetMimeType(const std::string&) const { 60 std::string ScreenlockIconSource::GetMimeType(const std::string&) const {
61 return "image/png"; 61 return "image/png";
62 } 62 }
63 63
64 // static. 64 // static.
65 std::string ScreenlockIconSource::GetIconURLForUser( 65 std::string ScreenlockIconSource::GetIconURLForUser(
66 const std::string& username) { 66 const std::string& username) {
67 return std::string(chrome::kChromeUIScreenlockIconURL) + 67 return std::string(chrome::kChromeUIScreenlockIconURL) +
68 net::EscapePath(username); 68 net::EscapePath(username);
69 } 69 }
70 70
71 } // namespace chromeos 71 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/oobe_ui.cc ('k') | chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698