| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options2/chromeos/wallpaper_thumbnail_source.h
" | 5 #include "chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source.h
" |
| 6 | 6 |
| 7 #include "ash/desktop_background/desktop_background_resources.h" | 7 #include "ash/desktop_background/desktop_background_resources.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/synchronization/cancellation_flag.h" | 14 #include "base/synchronization/cancellation_flag.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "base/threading/worker_pool.h" | 16 #include "base/threading/worker_pool.h" |
| 17 #include "chrome/browser/chromeos/login/user_manager.h" | 17 #include "chrome/browser/chromeos/login/user_manager.h" |
| 18 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
| 18 #include "chrome/browser/io_thread.h" | 19 #include "chrome/browser/io_thread.h" |
| 19 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "grit/ui_resources.h" | 23 #include "grit/ui_resources.h" |
| 23 #include "net/base/mime_util.h" | 24 #include "net/base/mime_util.h" |
| 24 #include "ui/base/layout.h" | 25 #include "ui/base/layout.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/codec/png_codec.h" | 27 #include "ui/gfx/codec/png_codec.h" |
| 27 | 28 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 44 return request_id_; | 45 return request_id_; |
| 45 } | 46 } |
| 46 | 47 |
| 47 static void Run(scoped_refptr<ThumbnailEncodingOperation> teo) { | 48 static void Run(scoped_refptr<ThumbnailEncodingOperation> teo) { |
| 48 teo->EncodeThumbnail(); | 49 teo->EncodeThumbnail(); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void EncodeThumbnail() { | 52 void EncodeThumbnail() { |
| 52 if (cancel_flag_.IsSet()) | 53 if (cancel_flag_.IsSet()) |
| 53 return; | 54 return; |
| 54 gfx::PNGCodec::EncodeBGRASkBitmap(user_->wallpaper_thumbnail(), | 55 gfx::PNGCodec::EncodeBGRASkBitmap( |
| 55 false, &data_->data()); | 56 WallpaperManager::Get()->GetCustomWallpaperThumbnail(user_->email()), |
| 57 false, &data_->data()); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void Cancel() { | 60 void Cancel() { |
| 59 cancel_flag_.Set(); | 61 cancel_flag_.Set(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 private: | 64 private: |
| 63 friend class base::RefCountedThreadSafe< | 65 friend class base::RefCountedThreadSafe< |
| 64 WallpaperThumbnailSource::ThumbnailEncodingOperation>; | 66 WallpaperThumbnailSource::ThumbnailEncodingOperation>; |
| 65 | 67 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 SendResponse(request_id, NULL); | 236 SendResponse(request_id, NULL); |
| 235 return; | 237 return; |
| 236 } | 238 } |
| 237 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 239 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 238 SendResponse(request_id, | 240 SendResponse(request_id, |
| 239 rb.LoadDataResourceBytes(idr, ui::SCALE_FACTOR_100P)); | 241 rb.LoadDataResourceBytes(idr, ui::SCALE_FACTOR_100P)); |
| 240 } | 242 } |
| 241 | 243 |
| 242 } // namespace options2 | 244 } // namespace options2 |
| 243 } // namespace chromeos | 245 } // namespace chromeos |
| OLD | NEW |