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

Unified Diff: chrome/browser/ui/app_list/arc_app_prefs.h

Issue 1413153007: arc-app-launcher: Minimal support for ARC app launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/ui/app_list/arc_app_prefs.h
diff --git a/chrome/browser/ui/app_list/arc_app_prefs.h b/chrome/browser/ui/app_list/arc_app_prefs.h
new file mode 100644
index 0000000000000000000000000000000000000000..6950782fc70e53317922f0b90cc27c7a3d8ac406
--- /dev/null
+++ b/chrome/browser/ui/app_list/arc_app_prefs.h
@@ -0,0 +1,106 @@
+// Copyright 2015 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.
+
+#ifndef CHROME_BROWSER_UI_APP_LIST_ARC_APP_PREFS_H_
+#define CHROME_BROWSER_UI_APP_LIST_ARC_APP_PREFS_H_
+
+#include <set>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "chromeos/dbus/arc_bridge_client.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "ui/base/layout.h"
+
+class PrefService;
+
+namespace content {
+class BrowserContext;
+}
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+class ArcAppPrefs : public KeyedService,
+ private chromeos::ArcBridgeClient::AppObserver {
+ public:
+ struct IconInfo {
+ ui::ScaleFactor scale_factor;
+ base::FilePath path;
+ };
+
+ struct AppInfo {
+ std::string name;
+ std::string package;
+ std::string activity;
+ bool enabled;
elijahtaylor1 2015/10/28 06:32:39 maybe call this "ready" here and elsewhere to matc
khmel1 2015/10/29 08:12:18 Good point. Done
+ std::vector<IconInfo> icons;
+ };
+
+ class Observer {
+ public:
+ virtual void OnAppRegistered(const std::string& app_id,
+ const AppInfo& app_info) = 0;
+ virtual void OnAppEnabled(const std::string& id, bool enabled) = 0;
+ virtual void OnAppIconUpdated(const std::string& id,
+ const IconInfo& icon) = 0;
+ };
+
+ static ArcAppPrefs* Create(content::BrowserContext* browser_context,
+ const base::FilePath& base_path,
+ PrefService* prefs);
+ // Convenience function to get the ArcAppPrefs for a BrowserContext.
+ static ArcAppPrefs* Get(content::BrowserContext* context);
+ static std::string GetAppId(const std::string& package,
+ const std::string& activity);
+
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
+ ~ArcAppPrefs() override;
+
+ std::vector<std::string> GetAppIds() const;
+ scoped_ptr<AppInfo> GetApp(const std::string& app_id) const;
+
+ bool IsRegistered(const std::string& app_id);
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ private:
+ content::BrowserContext* browser_context_;
+ // Owned by the BrowserContext.
+ PrefService* prefs_;
+ base::ObserverList<Observer> observer_list_;
+ base::FilePath base_path_;
+ std::set<std::string> enable_apps_;
+
+ // See the Create methods.
+ ArcAppPrefs(content::BrowserContext* browser_context,
+ const base::FilePath& base_path,
+ PrefService* prefs);
+
+ // ArcBridgeClient::AppObserver
+ void OnAppReady(const chromeos::ArcBridgeClient::AppInfo& app) override;
+ void OnAppsRefreshed(
+ const std::vector<chromeos::ArcBridgeClient::AppInfo>& apps) override;
+
+ // Install an icon to file system in the special folder of the profile
+ // directory.
+ void InstallIcon(const std::string& app_id,
+ ui::ScaleFactor scale_factor,
+ const std::vector<uint8>& contentPng);
+ void InstallIconFromFileThread(const std::string& app_id,
+ ui::ScaleFactor scale_factor,
+ const std::vector<uint8>& contentPng);
+ void OnIconInstalled(const std::string& app_id,
+ const IconInfo& icon_info);
+
+ DISALLOW_COPY_AND_ASSIGN(ArcAppPrefs);
+};
+
+#endif // CHROME_BROWSER_UI_APP_LIST_ARC_APP_PREFS_H_

Powered by Google App Engine
This is Rietveld 408576698