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

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: rebase Created 7 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 | 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 username_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, username_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 // In the new wallpaper picker UI, we do not depend on WallpaperDelegate
498 // to refresh thumbnail. Uses a null delegate here. 503 // to refresh thumbnail. Uses a null delegate here.
499 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_, 504 wallpaper_manager->SetCustomWallpaper(email_, username_hash_, file_name_,
Nikita (slow) 2013/09/25 14:47:11 nit: One parameter per line.
bshe 2013/09/26 16:49:57 Done.
500 chromeos::User::CUSTOMIZED, 505 layout_, chromeos::User::CUSTOMIZED,
501 image); 506 image);
502 unsafe_wallpaper_decoder_ = NULL; 507 unsafe_wallpaper_decoder_ = NULL;
503 508
504 if (generate_thumbnail_) { 509 if (generate_thumbnail_) {
505 wallpaper.EnsureRepsForSupportedScaleFactors(); 510 wallpaper.EnsureRepsForSupportedScaleFactors();
506 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); 511 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy());
507 // Generates thumbnail before call api function callback. We can then 512 // Generates thumbnail before call api function callback. We can then
508 // request thumbnail in the javascript callback. 513 // request thumbnail in the javascript callback.
509 task_runner->PostTask(FROM_HERE, 514 task_runner->PostTask(FROM_HERE,
510 base::Bind( 515 base::Bind(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 std::string file_name; 627 std::string file_name;
623 base::FilePath thumbnail_path; 628 base::FilePath thumbnail_path;
624 std::string email = chromeos::UserManager::Get()->GetLoggedInUser()->email(); 629 std::string email = chromeos::UserManager::Get()->GetLoggedInUser()->email();
625 if (source == kOnlineSource) { 630 if (source == kOnlineSource) {
626 file_name = GURL(urlOrFile).ExtractFileName(); 631 file_name = GURL(urlOrFile).ExtractFileName();
627 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS, 632 CHECK(PathService::Get(chrome::DIR_CHROMEOS_WALLPAPER_THUMBNAILS,
628 &thumbnail_path)); 633 &thumbnail_path));
629 thumbnail_path = thumbnail_path.Append(file_name); 634 thumbnail_path = thumbnail_path.Append(file_name);
630 } else { 635 } else {
631 file_name = urlOrFile; 636 file_name = urlOrFile;
637 std::string username_hash =
638 chromeos::UserManager::Get()->GetLoggedInUser()->username_hash();
632 thumbnail_path = chromeos::WallpaperManager::Get()-> 639 thumbnail_path = chromeos::WallpaperManager::Get()->
633 GetCustomWallpaperPath(chromeos::kThumbnailWallpaperSubDir, email, 640 GetCustomWallpaperPath(chromeos::kThumbnailWallpaperSubDir,
641 username_hash,
634 file_name); 642 file_name);
635 } 643 }
636 644
637 sequence_token_ = BrowserThread::GetBlockingPool()-> 645 sequence_token_ = BrowserThread::GetBlockingPool()->
638 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); 646 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName);
639 scoped_refptr<base::SequencedTaskRunner> task_runner = 647 scoped_refptr<base::SequencedTaskRunner> task_runner =
640 BrowserThread::GetBlockingPool()-> 648 BrowserThread::GetBlockingPool()->
641 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, 649 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_,
642 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 650 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
643 651
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 this, file_list)); 811 this, file_list));
804 } 812 }
805 813
806 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( 814 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete(
807 const std::vector<std::string>& file_list) { 815 const std::vector<std::string>& file_list) {
808 ListValue* results = new ListValue(); 816 ListValue* results = new ListValue();
809 results->AppendStrings(file_list); 817 results->AppendStrings(file_list);
810 SetResult(results); 818 SetResult(results);
811 SendResponse(true); 819 SendResponse(true);
812 } 820 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698