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

Unified Diff: chrome/browser/chromeos/app_mode/kiosk_app_data.cc

Issue 141803014: Merge 244632 "kiosk: Do update check during launch." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1700/src/
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/app_mode/kiosk_app_data.cc
===================================================================
--- chrome/browser/chromeos/app_mode/kiosk_app_data.cc (revision 246680)
+++ chrome/browser/chromeos/app_mode/kiosk_app_data.cc (working copy)
@@ -17,14 +17,20 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_data_delegate.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/image_loader.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 "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/image/image.h"
using content::BrowserThread;
@@ -288,6 +294,28 @@
}
}
+void KioskAppData::LoadFromInstalledApp(Profile* profile,
+ const extensions::Extension* app) {
+ SetStatus(STATUS_LOADING);
+
+ if (!app) {
+ app = extensions::ExtensionSystem::Get(profile)
+ ->extension_service()
+ ->GetInstalledExtension(app_id_);
+ }
+
+ DCHECK_EQ(app_id_, app->id());
+
+ name_ = app->name();
+
+ const int kIconSize = extension_misc::EXTENSION_ICON_LARGE;
+ extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
+ app, kIconSize, ExtensionIconSet::MATCH_BIGGER);
+ extensions::ImageLoader::Get(profile)->LoadImageAsync(
+ app, image, gfx::Size(kIconSize, kIconSize),
+ base::Bind(&KioskAppData::OnExtensionIconLoaded, AsWeakPtr()));
+}
+
bool KioskAppData::IsLoading() const {
return status_ == STATUS_LOADING;
}
@@ -354,21 +382,7 @@
icon_path_ = icon_path;
}
-void KioskAppData::OnIconLoadSuccess(
- const scoped_refptr<base::RefCountedString>& raw_icon,
- const gfx::ImageSkia& icon) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- raw_icon_ = raw_icon;
- icon_ = icon;
- SetStatus(STATUS_LOADED);
-}
-
-void KioskAppData::OnIconLoadFailure() {
- // Re-fetch data from web store when failed to load cached data.
- StartFetch();
-}
-
-void KioskAppData::OnWebstoreParseSuccess(const SkBitmap& icon) {
+void KioskAppData::SetCache(const std::string& name, const SkBitmap& icon) {
icon_ = gfx::ImageSkia::CreateFrom1xBitmap(icon);
icon_.MakeThreadSafe();
@@ -387,10 +401,40 @@
FROM_HERE,
base::Bind(&SaveIconToLocalOnBlockingPool, icon_path, raw_icon_));
- SetCache(name_, icon_path);
+ SetCache(name, icon_path);
+}
+
+void KioskAppData::OnExtensionIconLoaded(const gfx::Image& icon) {
+ if (icon.IsEmpty()) {
+ LOG(WARNING) << "Failed to load icon from installed app"
+ << ", id=" << app_id_;
+ SetCache(name_, *extensions::IconsInfo::GetDefaultAppIcon().bitmap());
+ } else {
+ SetCache(name_, icon.AsBitmap());
+ }
+
SetStatus(STATUS_LOADED);
}
+void KioskAppData::OnIconLoadSuccess(
+ const scoped_refptr<base::RefCountedString>& raw_icon,
+ const gfx::ImageSkia& icon) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ raw_icon_ = raw_icon;
+ icon_ = icon;
+ SetStatus(STATUS_LOADED);
+}
+
+void KioskAppData::OnIconLoadFailure() {
+ // Re-fetch data from web store when failed to load cached data.
+ StartFetch();
+}
+
+void KioskAppData::OnWebstoreParseSuccess(const SkBitmap& icon) {
+ SetCache(name_, icon);
+ SetStatus(STATUS_LOADED);
+}
+
void KioskAppData::OnWebstoreParseFailure() {
SetStatus(STATUS_ERROR);
}
« no previous file with comments | « chrome/browser/chromeos/app_mode/kiosk_app_data.h ('k') | chrome/browser/chromeos/app_mode/kiosk_app_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698