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

Side by Side Diff: chrome/browser/chromeos/extensions/wallpaper_api.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 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/chromeos/extensions/wallpaper_api.h" 5 #include "chrome/browser/chromeos/extensions/wallpaper_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 scoped_ptr<net::URLFetcher> url_fetcher_; 87 scoped_ptr<net::URLFetcher> url_fetcher_;
88 FetchCallback callback_; 88 FetchCallback callback_;
89 }; 89 };
90 90
91 base::LazyInstance<WallpaperFetcher> g_wallpaper_fetcher = 91 base::LazyInstance<WallpaperFetcher> g_wallpaper_fetcher =
92 LAZY_INSTANCE_INITIALIZER; 92 LAZY_INSTANCE_INITIALIZER;
93 93
94 } // namespace 94 } // namespace
95 95
96 WallpaperSetWallpaperFunction::WallpaperSetWallpaperFunction() { 96 WallpaperSetWallpaperFunction::WallpaperSetWallpaperFunction() : user_id_(std::s tring(), std::string()) {
Denis Kuznetsov (DE-MUC) 2015/06/10 16:50:45 EmptyUserID() ?
97 } 97 }
98 98
99 WallpaperSetWallpaperFunction::~WallpaperSetWallpaperFunction() { 99 WallpaperSetWallpaperFunction::~WallpaperSetWallpaperFunction() {
100 } 100 }
101 101
102 bool WallpaperSetWallpaperFunction::RunAsync() { 102 bool WallpaperSetWallpaperFunction::RunAsync() {
103 DCHECK_CURRENTLY_ON(BrowserThread::UI); 103 DCHECK_CURRENTLY_ON(BrowserThread::UI);
104 params_ = set_wallpaper::Params::Create(*args_); 104 params_ = set_wallpaper::Params::Create(*args_);
105 EXTENSION_FUNCTION_VALIDATE(params_); 105 EXTENSION_FUNCTION_VALIDATE(params_);
106 106
107 // Gets email address and username hash while at UI thread. 107 // Gets user id and username hash while at UI thread.
108 user_id_ = user_manager::UserManager::Get()->GetLoggedInUser()->email(); 108 user_id_ = user_manager::UserManager::Get()->GetLoggedInUser()->GetUserID();
109 user_id_hash_ = 109 user_id_hash_ =
110 user_manager::UserManager::Get()->GetLoggedInUser()->username_hash(); 110 user_manager::UserManager::Get()->GetLoggedInUser()->username_hash();
111 111
112 if (params_->details.data) { 112 if (params_->details.data) {
113 StartDecode(*params_->details.data); 113 StartDecode(*params_->details.data);
114 } else { 114 } else {
115 GURL wallpaper_url(*params_->details.url); 115 GURL wallpaper_url(*params_->details.url);
116 if (wallpaper_url.is_valid()) { 116 if (wallpaper_url.is_valid()) {
117 g_wallpaper_fetcher.Get().FetchWallpaper( 117 g_wallpaper_fetcher.Get().FetchWallpaper(
118 wallpaper_url, 118 wallpaper_url,
(...skipping 16 matching lines...) Expand all
135 135
136 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken( 136 sequence_token_ = BrowserThread::GetBlockingPool()->GetNamedSequenceToken(
137 wallpaper::kWallpaperSequenceTokenName); 137 wallpaper::kWallpaperSequenceTokenName);
138 scoped_refptr<base::SequencedTaskRunner> task_runner = 138 scoped_refptr<base::SequencedTaskRunner> task_runner =
139 BrowserThread::GetBlockingPool()-> 139 BrowserThread::GetBlockingPool()->
140 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, 140 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_,
141 base::SequencedWorkerPool::BLOCK_SHUTDOWN); 141 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
142 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum( 142 wallpaper::WallpaperLayout layout = wallpaper_api_util::GetLayoutEnum(
143 extensions::api::wallpaper::ToString(params_->details.layout)); 143 extensions::api::wallpaper::ToString(params_->details.layout));
144 bool update_wallpaper = 144 bool update_wallpaper =
145 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->email(); 145 user_id_ == user_manager::UserManager::Get()->GetActiveUser()->GetUserID() ;
146 wallpaper_manager->SetCustomWallpaper(user_id_, 146 wallpaper_manager->SetCustomWallpaper(user_id_,
147 user_id_hash_, 147 user_id_hash_,
148 params_->details.filename, 148 params_->details.filename,
149 layout, 149 layout,
150 user_manager::User::CUSTOMIZED, 150 user_manager::User::CUSTOMIZED,
151 image, 151 image,
152 update_wallpaper); 152 update_wallpaper);
153 unsafe_wallpaper_decoder_ = NULL; 153 unsafe_wallpaper_decoder_ = NULL;
154 154
155 if (params_->details.thumbnail) { 155 if (params_->details.thumbnail) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const std::string& response) { 223 const std::string& response) {
224 if (success) { 224 if (success) {
225 params_->details.data.reset( 225 params_->details.data.reset(
226 new std::vector<char>(response.begin(), response.end())); 226 new std::vector<char>(response.begin(), response.end()));
227 StartDecode(*params_->details.data); 227 StartDecode(*params_->details.data);
228 } else { 228 } else {
229 SetError(response); 229 SetError(response);
230 SendResponse(false); 230 SendResponse(false);
231 } 231 }
232 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698