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

Side by Side Diff: chrome/browser/chromeos/extensions/wallpaper_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 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 "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/threading/worker_pool.h" 9 #include "base/threading/worker_pool.h"
10 #include "chrome/browser/chromeos/login/user.h" 10 #include "chrome/browser/chromeos/login/user.h"
(...skipping 20 matching lines...) Expand all
31 std::string layout_string; 31 std::string layout_string;
32 details->GetString("layout", &layout_string); 32 details->GetString("layout", &layout_string);
33 EXTENSION_FUNCTION_VALIDATE(!layout_string.empty()); 33 EXTENSION_FUNCTION_VALIDATE(!layout_string.empty());
34 layout_ = wallpaper_api_util::GetLayoutEnum(layout_string); 34 layout_ = wallpaper_api_util::GetLayoutEnum(layout_string);
35 35
36 details->GetBoolean("thumbnail", &generate_thumbnail_); 36 details->GetBoolean("thumbnail", &generate_thumbnail_);
37 details->GetString("name", &file_name_); 37 details->GetString("name", &file_name_);
38 38
39 EXTENSION_FUNCTION_VALIDATE(!file_name_.empty()); 39 EXTENSION_FUNCTION_VALIDATE(!file_name_.empty());
40 40
41 // Gets email address while at UI thread. 41 // Gets email address and username hash while at UI thread.
42 email_ = chromeos::UserManager::Get()->GetLoggedInUser()->email(); 42 email_ = chromeos::UserManager::Get()->GetLoggedInUser()->email();
43 username_hash_ =
Nikita (slow) 2013/09/25 14:47:11 This may be empty string if multi-profiles are not
bshe 2013/09/26 16:49:57 I tested w/o --multi-profiles switch. It seems wor
44 chromeos::UserManager::Get()->GetLoggedInUser()->username_hash();
43 45
44 image_data_.assign(input->GetBuffer(), input->GetSize()); 46 image_data_.assign(input->GetBuffer(), input->GetSize());
45 StartDecode(image_data_); 47 StartDecode(image_data_);
46 48
47 return true; 49 return true;
48 } 50 }
49 51
50 void WallpaperSetWallpaperFunction::OnWallpaperDecoded( 52 void WallpaperSetWallpaperFunction::OnWallpaperDecoded(
51 const gfx::ImageSkia& wallpaper) { 53 const gfx::ImageSkia& wallpaper) {
52 chromeos::WallpaperManager* wallpaper_manager = 54 chromeos::WallpaperManager* wallpaper_manager =
53 chromeos::WallpaperManager::Get(); 55 chromeos::WallpaperManager::Get();
54 chromeos::UserImage::RawImage raw_image(image_data_.begin(), 56 chromeos::UserImage::RawImage raw_image(image_data_.begin(),
55 image_data_.end()); 57 image_data_.end());
56 chromeos::UserImage image(wallpaper, raw_image); 58 chromeos::UserImage image(wallpaper, raw_image);
57 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath( 59 base::FilePath thumbnail_path = wallpaper_manager->GetCustomWallpaperPath(
58 chromeos::kThumbnailWallpaperSubDir, email_, file_name_); 60 chromeos::kThumbnailWallpaperSubDir, username_hash_, file_name_);
59 61
60 sequence_token_ = BrowserThread::GetBlockingPool()-> 62 sequence_token_ = BrowserThread::GetBlockingPool()->
61 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName); 63 GetNamedSequenceToken(chromeos::kWallpaperSequenceTokenName);
62 scoped_refptr<base::SequencedTaskRunner> task_runner = 64 scoped_refptr<base::SequencedTaskRunner> task_runner =
63 BrowserThread::GetBlockingPool()-> 65 BrowserThread::GetBlockingPool()->
64 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_, 66 GetSequencedTaskRunnerWithShutdownBehavior(sequence_token_,
65 base::SequencedWorkerPool::BLOCK_SHUTDOWN); 67 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
66 68
67 // In the new wallpaper picker UI, we do not depend on WallpaperDelegate 69 wallpaper_manager->SetCustomWallpaper(email_, username_hash_, file_name_,
Nikita (slow) 2013/09/25 14:47:11 nit: One parameter per line please.
bshe 2013/09/26 16:49:57 Done.
68 // to refresh thumbnail. Uses a null delegate here. 70 layout_, chromeos::User::CUSTOMIZED,
69 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_,
70 chromeos::User::CUSTOMIZED,
71 image); 71 image);
72 unsafe_wallpaper_decoder_ = NULL; 72 unsafe_wallpaper_decoder_ = NULL;
73 73
74 if (generate_thumbnail_) { 74 if (generate_thumbnail_) {
75 wallpaper.EnsureRepsForSupportedScaleFactors(); 75 wallpaper.EnsureRepsForSupportedScaleFactors();
76 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); 76 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy());
77 // Generates thumbnail before call api function callback. We can then 77 // Generates thumbnail before call api function callback. We can then
78 // request thumbnail in the javascript callback. 78 // request thumbnail in the javascript callback.
79 task_runner->PostTask(FROM_HERE, 79 task_runner->PostTask(FROM_HERE,
80 base::Bind( 80 base::Bind(
(...skipping 26 matching lines...) Expand all
107 this, data)); 107 this, data));
108 } 108 }
109 109
110 void WallpaperSetWallpaperFunction::ThumbnailGenerated( 110 void WallpaperSetWallpaperFunction::ThumbnailGenerated(
111 base::RefCountedBytes* data) { 111 base::RefCountedBytes* data) {
112 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( 112 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer(
113 reinterpret_cast<const char*>(data->front()), data->size()); 113 reinterpret_cast<const char*>(data->front()), data->size());
114 SetResult(result); 114 SetResult(result);
115 SendResponse(true); 115 SendResponse(true);
116 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698