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

Side by Side 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: Modifications according to the comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
6
7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/shell.h"
9 #include "base/macros.h"
10 #include "build/build_config.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
14 #include "chrome/browser/ui/ash/ash_init.h"
15 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
16 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
17 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
18 #include "chrome/common/pref_names.h"
19 #include "components/prefs/scoped_user_pref_update.h"
20 #include "extensions/browser/extension_registry.h"
21 #include "extensions/common/extension.h"
22 #include "ui/aura/window_event_dispatcher.h"
23
24 #if defined(MOJO_SHELL_CLIENT)
25 #include "content/public/common/mojo_shell_connection.h"
26 #endif
27
28 bool IsBrowserFromActiveUser(Browser* browser) {
29 // If running multi user mode with separate desktops, we have to check if the
30 // browser is from the active user.
31 if (chrome::MultiUserWindowManager::GetMultiProfileMode() !=
32 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED)
33 return true;
34 return multi_user_util::IsProfileFromActiveUser(browser->profile());
35 }
36
37 const extensions::Extension* GetExtensionForAppID(const std::string& app_id,
38 Profile* profile) {
39 return extensions::ExtensionRegistry::Get(profile)->GetExtensionById(
40 app_id, extensions::ExtensionRegistry::EVERYTHING);
41 }
42
43 AppListControllerDelegate::Pinnable GetPinnableForAppID(
44 const std::string& app_id,
45 Profile* profile) {
46 const base::ListValue* pref =
47 profile->GetPrefs()->GetList(prefs::kPolicyPinnedLauncherApps);
48 if (!pref)
49 return AppListControllerDelegate::PIN_EDITABLE;
50 // Pinned ARC apps policy defines the package name of the apps, that must
51 // be pinned. All the launch activities of any package in policy are pinned.
52 // In turn the input parameter to this function is app_id, which
53 // is 32 chars hash. In case of ARC app this is a hash of
54 // (package name + activity). This means that we must identify the package
55 // from the hash, and check if this package is pinned by policy.
56 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(profile);
57 std::string arc_app_packege_name;
58 if (arc_prefs) {
59 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
60 arc_prefs->GetApp(app_id);
61 if (app_info)
62 arc_app_packege_name = app_info->package_name;
63 }
64 for (size_t index = 0; index < pref->GetSize(); ++index) {
65 const base::DictionaryValue* app = nullptr;
66 std::string app_id_or_package;
67 if (pref->GetDictionary(index, &app) &&
68 app->GetString(ash::launcher::kPinnedAppsPrefAppIDPath,
69 &app_id_or_package) &&
70 (app_id == app_id_or_package ||
71 arc_app_packege_name == app_id_or_package)) {
72 return AppListControllerDelegate::PIN_FIXED;
73 }
74 }
75 return AppListControllerDelegate::PIN_EDITABLE;
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698