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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/user_image_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
« no previous file with comments | « chrome/browser/ui/webui/fileicon_source.cc ('k') | chrome/browser/web_applications/web_app.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/options/chromeos/user_image_source.h" 5 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h"
6 6
7 #include "base/memory/ref_counted_memory.h" 7 #include "base/memory/ref_counted_memory.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "chrome/browser/chromeos/login/users/default_user_image/default_user_im ages.h" 10 #include "chrome/browser/chromeos/login/users/default_user_image/default_user_im ages.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "chrome/grit/theme_resources.h" 12 #include "chrome/grit/theme_resources.h"
13 #include "components/signin/core/account_id/account_id.h" 13 #include "components/signin/core/account_id/account_id.h"
14 #include "components/user_manager/known_user.h" 14 #include "components/user_manager/known_user.h"
15 #include "components/user_manager/user_manager.h" 15 #include "components/user_manager/user_manager.h"
16 #include "net/base/escape.h" 16 #include "net/base/escape.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" 18 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h"
19 #include "ui/gfx/codec/png_codec.h" 19 #include "ui/gfx/codec/png_codec.h"
20 #include "url/third_party/mozilla/url_parse.h" 20 #include "url/third_party/mozilla/url_parse.h"
21 21
22 namespace { 22 namespace {
23 23
24 // Parses the user image URL, which looks like 24 // Parses the user image URL, which looks like
25 // "chrome://userimage/serialized-user-id?key1=value1&...&key_n=value_n", 25 // "chrome://userimage/serialized-user-id?key1=value1&...&key_n=value_n",
26 // to user email. 26 // to user email.
27 void ParseRequest(const GURL& url, std::string* email) { 27 void ParseRequest(const GURL& url, std::string* email) {
28 DCHECK(url.is_valid()); 28 DCHECK(url.is_valid());
29 const std::string serialized_account_id = net::UnescapeURLComponent( 29 const std::string serialized_account_id = net::UnescapeURLComponent(
30 url.path().substr(1), 30 url.path().as_string().substr(1),
31 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS | 31 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
32 net::UnescapeRule::PATH_SEPARATORS | net::UnescapeRule::SPACES); 32 net::UnescapeRule::PATH_SEPARATORS | net::UnescapeRule::SPACES);
33 AccountId account_id(EmptyAccountId()); 33 AccountId account_id(EmptyAccountId());
34 const bool status = 34 const bool status =
35 AccountId::Deserialize(serialized_account_id, &account_id); 35 AccountId::Deserialize(serialized_account_id, &account_id);
36 // TODO(alemate): DCHECK(status) - should happen after options page is 36 // TODO(alemate): DCHECK(status) - should happen after options page is
37 // migrated. 37 // migrated.
38 if (!status) { 38 if (!status) {
39 LOG(WARNING) << "Failed to deserialize account_id."; 39 LOG(WARNING) << "Failed to deserialize account_id.";
40 account_id = user_manager::known_user::GetAccountId( 40 account_id = user_manager::known_user::GetAccountId(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 std::string UserImageSource::GetMimeType(const std::string& path) const { 104 std::string UserImageSource::GetMimeType(const std::string& path) const {
105 // We need to explicitly return a mime type, otherwise if the user tries to 105 // We need to explicitly return a mime type, otherwise if the user tries to
106 // drag the image they get no extension. 106 // drag the image they get no extension.
107 return "image/png"; 107 return "image/png";
108 } 108 }
109 109
110 } // namespace options 110 } // namespace options
111 } // namespace chromeos 111 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/fileicon_source.cc ('k') | chrome/browser/web_applications/web_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698