Index: chrome/browser/chromeos/app_mode/kiosk_app_data.cc |
diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc |
index 8522d7b3c7f8ee370ade36750c0e428428fba8ee..81066472dabd954f1d3bbde4780368a292f05953 100644 |
--- a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc |
+++ b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc |
@@ -21,7 +21,6 @@ |
#include "chrome/browser/extensions/extension_util.h" |
#include "chrome/browser/extensions/webstore_data_fetcher.h" |
#include "chrome/browser/extensions/webstore_install_helper.h" |
-#include "chrome/browser/image_decoder.h" |
#include "chrome/browser/profiles/profile.h" |
#include "components/prefs/pref_service.h" |
#include "components/prefs/scoped_user_pref_update.h" |
@@ -203,119 +202,6 @@ class KioskAppData::CrxLoader : public extensions::SandboxedUnpackerClient { |
}; |
//////////////////////////////////////////////////////////////////////////////// |
-// KioskAppData::IconLoader |
-// Loads locally stored icon data and decode it. |
- |
-class KioskAppData::IconLoader { |
- public: |
- enum LoadResult { |
- SUCCESS, |
- FAILED_TO_LOAD, |
- FAILED_TO_DECODE, |
- }; |
- |
- IconLoader(const base::WeakPtr<KioskAppData>& client, |
- const base::FilePath& icon_path) |
- : client_(client), |
- icon_path_(icon_path), |
- load_result_(SUCCESS) {} |
- |
- void Start() { |
- base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
- base::SequencedWorkerPool::SequenceToken token = pool->GetSequenceToken(); |
- task_runner_ = pool->GetSequencedTaskRunnerWithShutdownBehavior( |
- token, |
- base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
- task_runner_->PostTask(FROM_HERE, |
- base::Bind(&IconLoader::LoadOnBlockingPool, |
- base::Unretained(this))); |
- } |
- |
- private: |
- friend class base::RefCountedThreadSafe<IconLoader>; |
- |
- ~IconLoader() {} |
- |
- class IconImageRequest : public ImageDecoder::ImageRequest { |
- public: |
- IconImageRequest( |
- const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
- IconLoader* icon_loader) |
- : ImageRequest(task_runner), icon_loader_(icon_loader) {} |
- |
- void OnImageDecoded(const SkBitmap& decoded_image) override { |
- icon_loader_->icon_ = gfx::ImageSkia::CreateFrom1xBitmap(decoded_image); |
- icon_loader_->icon_.MakeThreadSafe(); |
- icon_loader_->ReportResultOnBlockingPool(SUCCESS); |
- delete this; |
- } |
- |
- void OnDecodeImageFailed() override { |
- icon_loader_->ReportResultOnBlockingPool(FAILED_TO_DECODE); |
- delete this; |
- } |
- |
- private: |
- ~IconImageRequest() override {} |
- IconLoader* icon_loader_; |
- }; |
- |
- // Loads the icon from locally stored |icon_path_| on the blocking pool |
- void LoadOnBlockingPool() { |
- DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
- |
- std::string data; |
- if (!base::ReadFileToString(base::FilePath(icon_path_), &data)) { |
- ReportResultOnBlockingPool(FAILED_TO_LOAD); |
- return; |
- } |
- raw_icon_ = base::RefCountedString::TakeString(&data); |
- |
- IconImageRequest* image_request = new IconImageRequest(task_runner_, this); |
- ImageDecoder::Start(image_request, raw_icon_->data()); |
- } |
- |
- void ReportResultOnBlockingPool(LoadResult result) { |
- DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
- |
- load_result_ = result; |
- BrowserThread::PostTask( |
- BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&IconLoader::ReportResultOnUIThread, |
- base::Unretained(this))); |
- } |
- |
- void NotifyClient() { |
- if (!client_) |
- return; |
- |
- if (load_result_ == SUCCESS) |
- client_->OnIconLoadSuccess(icon_); |
- else |
- client_->OnIconLoadFailure(); |
- } |
- |
- void ReportResultOnUIThread() { |
- DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- |
- NotifyClient(); |
- delete this; |
- } |
- |
- base::WeakPtr<KioskAppData> client_; |
- base::FilePath icon_path_; |
- |
- LoadResult load_result_; |
- scoped_refptr<base::SequencedTaskRunner> task_runner_; |
- |
- gfx::ImageSkia icon_; |
- scoped_refptr<base::RefCountedString> raw_icon_; |
- |
- DISALLOW_COPY_AND_ASSIGN(IconLoader); |
-}; |
- |
-//////////////////////////////////////////////////////////////////////////////// |
// KioskAppData::WebstoreDataParser |
// Use WebstoreInstallHelper to parse the manifest and decode the icon. |
@@ -541,8 +427,8 @@ bool KioskAppData::LoadFromCache() { |
} |
icon_path_ = base::FilePath(icon_path_string); |
- // IconLoader deletes itself when done. |
- (new IconLoader(AsWeakPtr(), icon_path_))->Start(); |
+ // KioskAppIconLoader deletes itself when done. |
+ (new KioskAppIconLoader(AsWeakPtr(), icon_path_))->Start(); |
return true; |
} |