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

Unified Diff: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_data.cc

Issue 2778053002: Fetch ARC Kiosk app name and icon from Android side. (Closed)
Patch Set: some nits Created 3 years, 8 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/arc/arc_kiosk_app_data.cc
diff --git a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_data.cc b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0fd43e74d8f38b8e774c4f571bd532724e8a9dcd
--- /dev/null
+++ b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_data.cc
@@ -0,0 +1,82 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_data.h"
+
+#include <utility>
+
+#include "base/path_service.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h"
+#include "chrome/common/chrome_paths.h"
+#include "components/prefs/pref_service.h"
+#include "components/prefs/scoped_user_pref_update.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace chromeos {
+
+namespace {
+
+constexpr char kIconCacheDir[] = "arc-kiosk/icon";
+
+} // namespace
+
+ArcKioskAppData::ArcKioskAppData(const std::string& app_id,
+ const AccountId& account_id,
+ const std::string& name)
+ : KioskAppDataBase(ArcKioskAppManager::kArcKioskDictionaryName,
+ app_id,
+ account_id) {
+ name_ = name;
+}
+
+ArcKioskAppData::~ArcKioskAppData() = default;
+
+bool ArcKioskAppData::operator==(const std::string& other_app_id) const {
+ return app_id() == other_app_id;
+}
+
+bool ArcKioskAppData::LoadFromCache() {
+ PrefService* local_state = g_browser_process->local_state();
+ const base::DictionaryValue* dict =
+ local_state->GetDictionary(dictionary_name());
+
+ return LoadFromDictionary(*dict);
+}
+
+void ArcKioskAppData::SetCache(const std::string& name,
+ const gfx::ImageSkia& icon) {
+ DCHECK(!name.empty());
+ DCHECK(!icon.isNull());
+ name_ = name;
+ icon_ = icon;
+
+ base::FilePath user_data_dir;
+ if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
+ LOG(ERROR) << "Failed to get user directory.";
+ return;
+ }
+ base::FilePath cache_dir = user_data_dir.AppendASCII(kIconCacheDir);
+
+ SaveIcon(*icon_.bitmap(), cache_dir);
+
+ PrefService* local_state = g_browser_process->local_state();
+ DictionaryPrefUpdate dict_update(local_state, dictionary_name());
+
+ SaveToDictionary(dict_update);
+}
+
+void ArcKioskAppData::OnIconLoadSuccess(const gfx::ImageSkia& icon) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ kiosk_app_icon_loader_.release();
+ icon_ = icon;
+}
+
+void ArcKioskAppData::OnIconLoadFailure() {
+ kiosk_app_icon_loader_.release();
+ LOG(ERROR) << "Icon Load Failure";
+ // Do nothing
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698