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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/options/chromeos/change_picture_options_handle r.h" 5 #include "chrome/browser/ui/webui/options/chromeos/change_picture_options_handle r.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // User has their Profile image as the current image. 278 // User has their Profile image as the current image.
279 SendProfileImage(user->GetImage(), true); 279 SendProfileImage(user->GetImage(), true);
280 break; 280 break;
281 } 281 }
282 default: { 282 default: {
283 DCHECK(previous_image_index_ >= 0 && 283 DCHECK(previous_image_index_ >= 0 &&
284 previous_image_index_ < default_user_image::kDefaultImagesCount); 284 previous_image_index_ < default_user_image::kDefaultImagesCount);
285 if (previous_image_index_ >= 285 if (previous_image_index_ >=
286 default_user_image::kFirstDefaultImageIndex) { 286 default_user_image::kFirstDefaultImageIndex) {
287 // User has image from the current set of default images. 287 // User has image from the current set of default images.
288 base::StringValue image_url( 288 base::Value image_url(
289 default_user_image::GetDefaultImageUrl(previous_image_index_)); 289 default_user_image::GetDefaultImageUrl(previous_image_index_));
290 web_ui()->CallJavascriptFunctionUnsafe( 290 web_ui()->CallJavascriptFunctionUnsafe(
291 "ChangePictureOptions.setSelectedImage", image_url); 291 "ChangePictureOptions.setSelectedImage", image_url);
292 } else { 292 } else {
293 // User has an old default image, so present it in the same manner as a 293 // User has an old default image, so present it in the same manner as a
294 // previous image from file. 294 // previous image from file.
295 SendOldImage( 295 SendOldImage(
296 default_user_image::GetDefaultImageUrl(previous_image_index_)); 296 default_user_image::GetDefaultImageUrl(previous_image_index_));
297 } 297 }
298 } 298 }
299 } 299 }
300 } 300 }
301 301
302 void ChangePictureOptionsHandler::SendProfileImage(const gfx::ImageSkia& image, 302 void ChangePictureOptionsHandler::SendProfileImage(const gfx::ImageSkia& image,
303 bool should_select) { 303 bool should_select) {
304 base::StringValue data_url(webui::GetBitmapDataUrl(*image.bitmap())); 304 base::Value data_url(webui::GetBitmapDataUrl(*image.bitmap()));
305 base::Value select(should_select); 305 base::Value select(should_select);
306 web_ui()->CallJavascriptFunctionUnsafe("ChangePictureOptions.setProfileImage", 306 web_ui()->CallJavascriptFunctionUnsafe("ChangePictureOptions.setProfileImage",
307 data_url, select); 307 data_url, select);
308 } 308 }
309 309
310 void ChangePictureOptionsHandler::UpdateProfileImage() { 310 void ChangePictureOptionsHandler::UpdateProfileImage() {
311 UserImageManager* user_image_manager = 311 UserImageManager* user_image_manager =
312 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId()); 312 ChromeUserManager::Get()->GetUserImageManager(GetUser()->GetAccountId());
313 // If we have a downloaded profile image and haven't sent it in 313 // If we have a downloaded profile image and haven't sent it in
314 // |SendSelectedImage|, send it now (without selecting). 314 // |SendSelectedImage|, send it now (without selecting).
315 if (previous_image_index_ != user_manager::User::USER_IMAGE_PROFILE && 315 if (previous_image_index_ != user_manager::User::USER_IMAGE_PROFILE &&
316 !user_image_manager->DownloadedProfileImage().isNull()) 316 !user_image_manager->DownloadedProfileImage().isNull())
317 SendProfileImage(user_image_manager->DownloadedProfileImage(), false); 317 SendProfileImage(user_image_manager->DownloadedProfileImage(), false);
318 318
319 user_image_manager->DownloadProfileImage(kProfileDownloadReason); 319 user_image_manager->DownloadProfileImage(kProfileDownloadReason);
320 } 320 }
321 321
322 void ChangePictureOptionsHandler::SendOldImage(const std::string& image_url) { 322 void ChangePictureOptionsHandler::SendOldImage(const std::string& image_url) {
323 previous_image_url_ = image_url; 323 previous_image_url_ = image_url;
324 base::StringValue url(image_url); 324 base::Value url(image_url);
325 web_ui()->CallJavascriptFunctionUnsafe("ChangePictureOptions.setOldImage", 325 web_ui()->CallJavascriptFunctionUnsafe("ChangePictureOptions.setOldImage",
326 url); 326 url);
327 } 327 }
328 328
329 void ChangePictureOptionsHandler::HandleSelectImage( 329 void ChangePictureOptionsHandler::HandleSelectImage(
330 const base::ListValue* args) { 330 const base::ListValue* args) {
331 std::string image_url; 331 std::string image_url;
332 std::string image_type; 332 std::string image_type;
333 if (!args || 333 if (!args ||
334 args->GetSize() != 2 || 334 args->GetSize() != 2 ||
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 Profile* profile = Profile::FromWebUI(web_ui()); 469 Profile* profile = Profile::FromWebUI(web_ui());
470 const user_manager::User* user = 470 const user_manager::User* user =
471 ProfileHelper::Get()->GetUserByProfile(profile); 471 ProfileHelper::Get()->GetUserByProfile(profile);
472 if (!user) 472 if (!user)
473 return user_manager::UserManager::Get()->GetActiveUser(); 473 return user_manager::UserManager::Get()->GetActiveUser();
474 return user; 474 return user;
475 } 475 }
476 476
477 } // namespace options 477 } // namespace options
478 } // namespace chromeos 478 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698