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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/user_image_source.cc

Issue 1534173003: ChromeOS user_manager: move all KnownUser code to separate file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/FindUsingSAML/IsUsingSAML/ Created 5 years 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/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/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "components/signin/core/account_id/account_id.h" 11 #include "components/signin/core/account_id/account_id.h"
12 #include "components/user_manager/known_user.h"
12 #include "components/user_manager/user_image/default_user_images.h" 13 #include "components/user_manager/user_image/default_user_images.h"
13 #include "components/user_manager/user_manager.h" 14 #include "components/user_manager/user_manager.h"
14 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
15 #include "grit/ui_chromeos_resources.h" 16 #include "grit/ui_chromeos_resources.h"
16 #include "net/base/escape.h" 17 #include "net/base/escape.h"
17 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/codec/png_codec.h" 19 #include "ui/gfx/codec/png_codec.h"
19 #include "url/third_party/mozilla/url_parse.h" 20 #include "url/third_party/mozilla/url_parse.h"
20 21
21 namespace { 22 namespace {
22 23
23 // Parses the user image URL, which looks like 24 // Parses the user image URL, which looks like
24 // "chrome://userimage/serialized-user-id?key1=value1&...&key_n=value_n", 25 // "chrome://userimage/serialized-user-id?key1=value1&...&key_n=value_n",
25 // to user email. 26 // to user email.
26 void ParseRequest(const GURL& url, 27 void ParseRequest(const GURL& url,
27 std::string* email) { 28 std::string* email) {
28 DCHECK(url.is_valid()); 29 DCHECK(url.is_valid());
29 const std::string serialized_account_id = net::UnescapeURLComponent( 30 const std::string serialized_account_id = net::UnescapeURLComponent(
30 url.path().substr(1), 31 url.path().substr(1),
31 (net::UnescapeRule::URL_SPECIAL_CHARS | net::UnescapeRule::SPACES)); 32 (net::UnescapeRule::URL_SPECIAL_CHARS | net::UnescapeRule::SPACES));
32 AccountId account_id(EmptyAccountId()); 33 AccountId account_id(EmptyAccountId());
33 const bool status = 34 const bool status =
34 AccountId::Deserialize(serialized_account_id, &account_id); 35 AccountId::Deserialize(serialized_account_id, &account_id);
35 // TODO(alemate): DCHECK(status) - should happen after options page is 36 // TODO(alemate): DCHECK(status) - should happen after options page is
36 // migrated. 37 // migrated.
37 if (!status) { 38 if (!status) {
38 LOG(WARNING) << "Failed to deserialize '" << serialized_account_id << "'"; 39 LOG(WARNING) << "Failed to deserialize '" << serialized_account_id << "'";
39 account_id = user_manager::UserManager::Get()->GetKnownUserAccountId( 40 account_id = user_manager::known_user::GetAccountId(
40 serialized_account_id, std::string() /* gaia_id */); 41 serialized_account_id, std::string() /* gaia_id */);
41 } 42 }
42 *email = account_id.GetUserEmail(); 43 *email = account_id.GetUserEmail();
43 } 44 }
44 45
45 } // namespace 46 } // namespace
46 47
47 namespace chromeos { 48 namespace chromeos {
48 namespace options { 49 namespace options {
49 50
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 96 }
96 97
97 std::string UserImageSource::GetMimeType(const std::string& path) const { 98 std::string UserImageSource::GetMimeType(const std::string& path) const {
98 // We need to explicitly return a mime type, otherwise if the user tries to 99 // We need to explicitly return a mime type, otherwise if the user tries to
99 // drag the image they get no extension. 100 // drag the image they get no extension.
100 return "image/png"; 101 return "image/png";
101 } 102 }
102 103
103 } // namespace options 104 } // namespace options
104 } // namespace chromeos 105 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc ('k') | components/user_manager.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698