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

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

Issue 2290753004: Finish changing chrome/ grit includes to use qualified paths. (Closed)
Patch Set: Rebase, fix new unqualified include Created 4 years, 3 months 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/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 "grit/ui_chromeos_resources.h"
17 #include "net/base/escape.h" 16 #include "net/base/escape.h"
18 #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"
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());
(...skipping 16 matching lines...) Expand all
45 45
46 base::RefCountedMemory* GetUserImageInternal(const AccountId& account_id) { 46 base::RefCountedMemory* GetUserImageInternal(const AccountId& account_id) {
47 const user_manager::User* user = 47 const user_manager::User* user =
48 user_manager::UserManager::Get()->FindUser(account_id); 48 user_manager::UserManager::Get()->FindUser(account_id);
49 49
50 // Always use the 100% scaling. These source images are 256x256, and are 50 // Always use the 100% scaling. These source images are 256x256, and are
51 // downscaled to ~64x64 for use in WebUI pages. Therefore, they are big enough 51 // downscaled to ~64x64 for use in WebUI pages. Therefore, they are big enough
52 // for device scale factors up to 4. We do not use SCALE_FACTOR_NONE, as we 52 // for device scale factors up to 4. We do not use SCALE_FACTOR_NONE, as we
53 // specifically want 100% scale images to not transmit more data than needed. 53 // specifically want 100% scale images to not transmit more data than needed.
54 if (user) { 54 if (user) {
55 if (user->has_image_bytes()) { 55 if (user->has_image_bytes())
56 return new base::RefCountedBytes(user->image_bytes()); 56 return new base::RefCountedBytes(user->image_bytes());
57 } else if (user->image_is_stub()) { 57 if (user->image_is_stub()) {
58 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 58 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
59 IDR_PROFILE_PICTURE_LOADING, ui::SCALE_FACTOR_100P); 59 IDR_PROFILE_PICTURE_LOADING, ui::SCALE_FACTOR_100P);
60 } else if (user->HasDefaultImage()) { 60 }
61 if (user->HasDefaultImage()) {
61 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 62 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
62 chromeos::default_user_image::kDefaultImageResourceIDs 63 chromeos::default_user_image::kDefaultImageResourceIDs
63 [user->image_index()], 64 [user->image_index()],
64 ui::SCALE_FACTOR_100P); 65 ui::SCALE_FACTOR_100P);
65 } else {
66 NOTREACHED() << "User with custom image missing data bytes";
67 } 66 }
67 NOTREACHED() << "User with custom image missing data bytes";
68 } 68 }
69 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 69 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
70 IDR_LOGIN_DEFAULT_USER, ui::SCALE_FACTOR_100P); 70 IDR_LOGIN_DEFAULT_USER, ui::SCALE_FACTOR_100P);
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 namespace chromeos { 75 namespace chromeos {
76 namespace options { 76 namespace options {
77 77
(...skipping 25 matching lines...) Expand all
103 } 103 }
104 104
105 std::string UserImageSource::GetMimeType(const std::string& path) const { 105 std::string UserImageSource::GetMimeType(const std::string& path) const {
106 // We need to explicitly return a mime type, otherwise if the user tries to 106 // We need to explicitly return a mime type, otherwise if the user tries to
107 // drag the image they get no extension. 107 // drag the image they get no extension.
108 return "image/png"; 108 return "image/png";
109 } 109 }
110 110
111 } // namespace options 111 } // namespace options
112 } // namespace chromeos 112 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/display_options_handler.cc ('k') | chrome/browser/ui/webui/options/options_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698