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

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: 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 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 user_id_hash_ =
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, user_id_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_,
68 // to refresh thumbnail. Uses a null delegate here. 70 user_id_hash_,
69 wallpaper_manager->SetCustomWallpaper(email_, file_name_, layout_, 71 file_name_,
72 layout_,
70 chromeos::User::CUSTOMIZED, 73 chromeos::User::CUSTOMIZED,
71 image); 74 image);
72 unsafe_wallpaper_decoder_ = NULL; 75 unsafe_wallpaper_decoder_ = NULL;
73 76
74 if (generate_thumbnail_) { 77 if (generate_thumbnail_) {
75 wallpaper.EnsureRepsForSupportedScales(); 78 wallpaper.EnsureRepsForSupportedScales();
76 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy()); 79 scoped_ptr<gfx::ImageSkia> deep_copy(wallpaper.DeepCopy());
77 // Generates thumbnail before call api function callback. We can then 80 // Generates thumbnail before call api function callback. We can then
78 // request thumbnail in the javascript callback. 81 // request thumbnail in the javascript callback.
79 task_runner->PostTask(FROM_HERE, 82 task_runner->PostTask(FROM_HERE,
(...skipping 27 matching lines...) Expand all
107 this, data)); 110 this, data));
108 } 111 }
109 112
110 void WallpaperSetWallpaperFunction::ThumbnailGenerated( 113 void WallpaperSetWallpaperFunction::ThumbnailGenerated(
111 base::RefCountedBytes* data) { 114 base::RefCountedBytes* data) {
112 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer( 115 BinaryValue* result = BinaryValue::CreateWithCopiedBuffer(
113 reinterpret_cast<const char*>(data->front()), data->size()); 116 reinterpret_cast<const char*>(data->front()), data->size());
114 SetResult(result); 117 SetResult(result);
115 SendResponse(true); 118 SendResponse(true);
116 } 119 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/wallpaper_api.h ('k') | chrome/browser/chromeos/extensions/wallpaper_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698