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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.cc

Issue 2090133003: Moved methods that don't rely on internal state out of ChromeLauncherController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit changes Created 4 years, 6 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/ash/launcher/chrome_launcher_controller_util.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..14e31020ff4ab63d6d36f5cc8f5d368fdb4730bf
--- /dev/null
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 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/ui/ash/launcher/chrome_launcher_controller_util.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
+#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
+#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
+#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_service.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/common/extension.h"
+
+bool IsBrowserFromActiveUser(Browser* browser) {
+ // If running multi user mode with separate desktops, we have to check if the
+ // browser is from the active user.
+ if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
+ chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
+ return true;
+ return multi_user_util::IsProfileFromActiveUser(browser->profile());
+}
+
+const extensions::Extension* GetExtensionForAppID(const std::string& app_id,
+ Profile* profile) {
+ return extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
+ app_id, extensions::ExtensionRegistry::EVERYTHING);
+}
+
+AppListControllerDelegate::Pinnable GetPinnableForAppID(
+ const std::string& app_id,
+ Profile* profile) {
+ const base::ListValue* pref =
+ profile->GetPrefs()->GetList(prefs::kPolicyPinnedLauncherApps);
+ if (!pref)
+ return AppListControllerDelegate::PIN_EDITABLE;
+ // Pinned ARC apps policy defines the package name of the apps, that must
+ // be pinned. All the launch activities of any package in policy are pinned.
+ // In turn the input parameter to this function is app_id, which
+ // is 32 chars hash. In case of ARC app this is a hash of
+ // (package name + activity). This means that we must identify the package
+ // from the hash, and check if this package is pinned by policy.
+ const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(profile);
+ std::string arc_app_packege_name;
+ if (arc_prefs) {
+ std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
+ arc_prefs->GetApp(app_id);
+ if (app_info)
+ arc_app_packege_name = app_info->package_name;
+ }
+ for (size_t index = 0; index < pref->GetSize(); ++index) {
+ const base::DictionaryValue* app = nullptr;
+ std::string app_id_or_package;
+ if (pref->GetDictionary(index, &app) &&
+ app->GetString(ash::launcher::kPinnedAppsPrefAppIDPath,
+ &app_id_or_package) &&
+ (app_id == app_id_or_package ||
+ arc_app_packege_name == app_id_or_package)) {
+ return AppListControllerDelegate::PIN_FIXED;
+ }
+ }
+ return AppListControllerDelegate::PIN_EDITABLE;
+}

Powered by Google App Engine
This is Rietveld 408576698