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

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

Issue 23480087: Use username_hash instead of email (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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/chromeos/extensions/wallpaper_private_api.h" 5 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/mru_window_tracker.h" 10 #include "ash/wm/mru_window_tracker.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 fallback_path = wallpaper_path.Append(file_name); 236 fallback_path = wallpaper_path.Append(file_name);
237 if (layout_ != ash::WALLPAPER_LAYOUT_STRETCH && 237 if (layout_ != ash::WALLPAPER_LAYOUT_STRETCH &&
238 resolution == ash::WALLPAPER_RESOLUTION_SMALL) { 238 resolution == ash::WALLPAPER_RESOLUTION_SMALL) {
239 file_name = base::FilePath(file_name).InsertBeforeExtension( 239 file_name = base::FilePath(file_name).InsertBeforeExtension(
240 chromeos::kSmallWallpaperSuffix).value(); 240 chromeos::kSmallWallpaperSuffix).value();
241 } 241 }
242 wallpaper_path = wallpaper_path.Append(file_name); 242 wallpaper_path = wallpaper_path.Append(file_name);
243 } else { 243 } else {
244 type_ = chromeos::User::CUSTOMIZED; 244 type_ = chromeos::User::CUSTOMIZED;
245 file_name = urlOrFile_; 245 file_name = urlOrFile_;
246 std::string username_hash =
247 chromeos::UserManager::Get()->GetLoggedInUser()->username_hash();
246 const char* sub_dir = (resolution == ash::WALLPAPER_RESOLUTION_SMALL) ? 248 const char* sub_dir = (resolution == ash::WALLPAPER_RESOLUTION_SMALL) ?
247 chromeos::kSmallWallpaperSubDir : chromeos::kLargeWallpaperSubDir; 249 chromeos::kSmallWallpaperSubDir : chromeos::kLargeWallpaperSubDir;
248 wallpaper_path = chromeos::WallpaperManager::Get()->GetCustomWallpaperPath( 250 wallpaper_path = chromeos::WallpaperManager::Get()->GetCustomWallpaperPath(
249 sub_dir, email, file_name); 251 sub_dir, username_hash, file_name);
252
250 fallback_path = chromeos::WallpaperManager::Get()->GetCustomWallpaperPath( 253 fallback_path = chromeos::WallpaperManager::Get()->GetCustomWallpaperPath(
251 chromeos::kOriginalWallpaperSubDir, email, file_name); 254 chromeos::kOriginalWallpaperSubDir, username_hash, file_name);
252 } 255 }
253 256
254 sequence_token_ = BrowserThread::GetBlockingPool()-> 257 sequence_token_ = BrowserThread::GetBlockingPool()->
255 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); 258 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName);
256 scoped_refptr<base::SequencedTaskRunner> task_runner = 259 scoped_refptr<base::SequencedTaskRunner> task_runner =
257 BrowserThread::GetBlockingPool()-> 260 BrowserThread::GetBlockingPool()->
258 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, 261 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_,
259 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 262 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
260 263
261 task_runner->PostTask(FROM_HERE, 264 task_runner->PostTask(FROM_HERE,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 std::string layout_string; 464 std::string layout_string;
462 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &layout_string)); 465 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &layout_string));
463 EXTENSION_FUNCTION_VALIDATE(!layout_string.empty()); 466 EXTENSION_FUNCTION_VALIDATE(!layout_string.empty());
464 layout_ = wallpaper_api_util::GetLayoutEnum(layout_string); 467 layout_ = wallpaper_api_util::GetLayoutEnum(layout_string);
465 468
466 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(2, &generate_thumbnail_)); 469 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(2, &generate_thumbnail_));
467 470
468 EXTENSION_FUNCTION_VALIDATE(args_->GetString(3, &file_name_)); 471 EXTENSION_FUNCTION_VALIDATE(args_->GetString(3, &file_name_));
469 EXTENSION_FUNCTION_VALIDATE(!file_name_.empty()); 472 EXTENSION_FUNCTION_VALIDATE(!file_name_.empty());
470 473
471 // Gets email address while at UI thread. 474 // Gets email address and username hash while at UI thread.
472 email_ = chromeos::UserManager::Get()->GetLoggedInUser()->email(); 475 email_ = chromeos::UserManager::Get()->GetLoggedInUser()->email();
476 user_id_hash_ =
477 chromeos::UserManager::Get()->GetLoggedInUser()->username_hash();
473 478
474 image_data_.assign(input->GetBuffer(), input->GetSize()); 479 image_data_.assign(input->GetBuffer(), input->GetSize());
475 StartDecode(image_data_); 480 StartDecode(image_data_);
476 481
477 return true; 482 return true;
478 } 483 }
479 484
480 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded( 485 void WallpaperPrivateSetCustomWallpaperFunction::OnWallpaperDecoded(
481 const gfx::ImageSkia& wallpaper) { 486 const gfx::ImageSkia& wallpaper) {
482 chromeos::WallpaperManager* wallpaper_manager = 487 chromeos::WallpaperManager* wallpaper_manager =
483 chromeos::WallpaperManager::Get(); 488 chromeos::WallpaperManager::Get();
484 chromeos::UserImage::RawImage raw_image(image_data_.begin(), 489 chromeos::UserImage::RawImage raw_image(image_data_.begin(),
485 image_data_.end()); 490 image_data_.end());
486 chromeos::UserImage image(wallpaper, raw_image); 491 chromeos::UserImage image(wallpaper, raw_image);
487 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( 492 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath(
488 chromeos::kThumbnailWallpaperSubDir, email_, file_name_); 493 chromeos::kThumbnailWallpaperSubDir, user_id_hash_, file_name_);
489 494
490 sequence_token_ = BrowserThread::GetBlockingPool()-> 495 sequence_token_ = BrowserThread::GetBlockingPool()->
491 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); 496 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName);
492 scoped_refptr<base::SequencedTaskRunner> task_runner = 497 scoped_refptr<base::SequencedTaskRunner> task_runner =
493 BrowserThread::GetBlockingPool()-> 498 BrowserThread::GetBlockingPool()->
494 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, 499 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_,
495 base::SequencedWorkerPool::BLOCK_SHUTDOWN); 500 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
496 501
497 // In the new wallpaper picker UI, we do not depend on WallpaperDelegate 502 wallpaper_manager->SetCustomWallpaper(email_,
498 // to refresh thumbnail. Uses a null delegate here. 503 user_id_hash_,
499 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_, 504 file_name_,
505 layout_,
500 chromeos::User::CUSTOMIZED, 506 chromeos::User::CUSTOMIZED,
501 image); 507 image);
502 unsafe_wallpaper_decoder_ = NULL; 508 unsafe_wallpaper_decoder_ = NULL;
503 509
504 if (generate_thumbnail_) { 510 if (generate_thumbnail_) {
505 wallpaper.EnsureRepsForSupportedScales(); 511 wallpaper.EnsureRepsForSupportedScales();
506 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); 512 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy());
507 // Generates thumbnail before call api function callback. We can then 513 // Generates thumbnail before call api function callback. We can then
508 // request thumbnail in the javascript callback. 514 // request thumbnail in the javascript callback.
509 task_runner->PostTask(FROM_HERE, 515 task_runner->PostTask(FROM_HERE,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 std::string file_name; 628 std::string file_name;
623 base::FilePath thumbnail_path; 629 base::FilePath thumbnail_path;
624 std::string email = chromeos::UserManager::Get()->GetLoggedInUser()->email(); 630 std::string email = chromeos::UserManager::Get()->GetLoggedInUser()->email();
625 if (source == kOnlineSource) { 631 if (source == kOnlineSource) {
626 file_name = GURL(urlOrFile).ExtractFileName(); 632 file_name = GURL(urlOrFile).ExtractFileName();
627 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, 633 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS,
628 &thumbnail_path)); 634 &thumbnail_path));
629 thumbnail_path = thumbnail_path.Append(file_name); 635 thumbnail_path = thumbnail_path.Append(file_name);
630 } else { 636 } else {
631 file_name = urlOrFile; 637 file_name = urlOrFile;
638 std::string username_hash =
639 chromeos::UserManager::Get()->GetLoggedInUser()->username_hash();
632 thumbnail_path = chromeos::WallpaperManager::Get()-> 640 thumbnail_path = chromeos::WallpaperManager::Get()->
633 GetCustomWallpaperPath(chromeos::kThumbnailWallpaperSubDir, email, 641 GetCustomWallpaperPath(chromeos::kThumbnailWallpaperSubDir,
642 username_hash,
634 file_name); 643 file_name);
635 } 644 }
636 645
637 sequence_token_ = BrowserThread::GetBlockingPool()-> 646 sequence_token_ = BrowserThread::GetBlockingPool()->
638 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); 647 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName);
639 scoped_refptr<base::SequencedTaskRunner> task_runner = 648 scoped_refptr<base::SequencedTaskRunner> task_runner =
640 BrowserThread::GetBlockingPool()-> 649 BrowserThread::GetBlockingPool()->
641 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, 650 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_,
642 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 651 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
643 652
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 this, file_list)); 812 this, file_list));
804 } 813 }
805 814
806 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( 815 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete(
807 const std::vector<std::string>& file_list) { 816 const std::vector<std::string>& file_list) {
808 ListValue* results = new ListValue(); 817 ListValue* results = new ListValue();
809 results->AppendStrings(file_list); 818 results->AppendStrings(file_list);
810 SetResult(results); 819 SetResult(results);
811 SendResponse(true); 820 SendResponse(true);
812 } 821 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/wallpaper_private_api.h ('k') | chrome/browser/chromeos/login/wallpaper_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698