OLD | NEW |
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_function_base.h" | 5 #include "chrome/browser/chromeos/extensions/wallpaper_function_base.h" |
6 | 6 |
7 #include "base/synchronization/cancellation_flag.h" | 7 #include "base/synchronization/cancellation_flag.h" |
8 #include "chrome/browser/image_decoder.h" | 8 #include "chrome/browser/image_decoder.h" |
9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
10 #include "chromeos/login/login_state.h" | 10 #include "chromeos/login/login_state.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 void Start(const std::string& image_data) { | 50 void Start(const std::string& image_data) { |
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
52 | 52 |
53 // This function can only be called after user login. It is fine to use | 53 // This function can only be called after user login. It is fine to use |
54 // unsafe image decoder here. Before user login, a robust jpeg decoder will | 54 // unsafe image decoder here. Before user login, a robust jpeg decoder will |
55 // be used. | 55 // be used. |
56 CHECK(chromeos::LoginState::Get()->IsUserLoggedIn()); | 56 CHECK(chromeos::LoginState::Get()->IsUserLoggedIn()); |
57 unsafe_image_decoder_ = new ImageDecoder(this, image_data, | 57 unsafe_image_decoder_ = new ImageDecoder(this, image_data, |
58 ImageDecoder::DEFAULT_CODEC); | 58 ImageDecoder::DEFAULT_CODEC); |
59 unsafe_image_decoder_->set_shrink_to_fit(true); | |
60 | |
61 scoped_refptr<base::MessageLoopProxy> task_runner = | 59 scoped_refptr<base::MessageLoopProxy> task_runner = |
62 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 60 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
63 unsafe_image_decoder_->Start(task_runner); | 61 unsafe_image_decoder_->Start(task_runner); |
64 } | 62 } |
65 | 63 |
66 void Cancel() { | 64 void Cancel() { |
67 cancel_flag_.Set(); | 65 cancel_flag_.Set(); |
68 } | 66 } |
69 | 67 |
70 virtual void OnImageDecoded(const ImageDecoder* decoder, | 68 virtual void OnImageDecoded(const ImageDecoder* decoder, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 unsafe_wallpaper_decoder_ = NULL; | 117 unsafe_wallpaper_decoder_ = NULL; |
120 SetError(wallpaper_api_util::kCancelWallpaperMessage); | 118 SetError(wallpaper_api_util::kCancelWallpaperMessage); |
121 SendResponse(false); | 119 SendResponse(false); |
122 } | 120 } |
123 | 121 |
124 void WallpaperFunctionBase::OnFailure(const std::string& error) { | 122 void WallpaperFunctionBase::OnFailure(const std::string& error) { |
125 unsafe_wallpaper_decoder_ = NULL; | 123 unsafe_wallpaper_decoder_ = NULL; |
126 SetError(error); | 124 SetError(error); |
127 SendResponse(false); | 125 SendResponse(false); |
128 } | 126 } |
OLD | NEW |