Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
|
tapted
2016/06/23 23:47:30
remove (c)
| |
| 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 "chrome/browser/profiles/profile.h" | |
| 8 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | |
| 9 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | |
| 10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | |
| 11 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | |
| 12 #include "chrome/browser/ui/browser.h" | |
| 13 #include "chrome/common/pref_names.h" | |
| 14 #include "components/prefs/scoped_user_pref_update.h" | |
| 15 #include "extensions/browser/extension_registry.h" | |
| 16 #include "extensions/common/extension.h" | |
| 17 | |
| 18 #if defined(MOJO_SHELL_CLIENT) | |
| 19 #include "content/public/common/mojo_shell_connection.h" | |
|
tapted
2016/06/23 23:47:30
is this used for anything? Some other things above
StarAZ
2016/06/24 14:15:17
Done.
| |
| 20 #endif | |
| 21 | |
| 22 bool IsBrowserFromActiveUser(Browser* browser) { | |
| 23 // If running multi user mode with separate desktops, we have to check if the | |
| 24 // browser is from the active user. | |
| 25 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != | |
| 26 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) | |
| 27 return true; | |
| 28 return multi_user_util::IsProfileFromActiveUser(browser->profile()); | |
| 29 } | |
| 30 | |
| 31 const extensions::Extension* GetExtensionForAppID(const std::string& app_id, | |
| 32 Profile* profile) { | |
| 33 return extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | |
| 34 app_id, extensions::ExtensionRegistry::EVERYTHING); | |
| 35 } | |
| 36 | |
| 37 AppListControllerDelegate::Pinnable GetPinnableForAppID( | |
| 38 const std::string& app_id, | |
| 39 Profile* profile) { | |
| 40 const base::ListValue* pref = | |
| 41 profile->GetPrefs()->GetList(prefs::kPolicyPinnedLauncherApps); | |
| 42 if (!pref) | |
| 43 return AppListControllerDelegate::PIN_EDITABLE; | |
| 44 // Pinned ARC apps policy defines the package name of the apps, that must | |
| 45 // be pinned. All the launch activities of any package in policy are pinned. | |
| 46 // In turn the input parameter to this function is app_id, which | |
| 47 // is 32 chars hash. In case of ARC app this is a hash of | |
| 48 // (package name + activity). This means that we must identify the package | |
| 49 // from the hash, and check if this package is pinned by policy. | |
| 50 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(profile); | |
| 51 std::string arc_app_packege_name; | |
| 52 if (arc_prefs) { | |
| 53 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | |
| 54 arc_prefs->GetApp(app_id); | |
| 55 if (app_info) | |
| 56 arc_app_packege_name = app_info->package_name; | |
| 57 } | |
| 58 for (size_t index = 0; index < pref->GetSize(); ++index) { | |
| 59 const base::DictionaryValue* app = nullptr; | |
| 60 std::string app_id_or_package; | |
| 61 if (pref->GetDictionary(index, &app) && | |
| 62 app->GetString(ash::launcher::kPinnedAppsPrefAppIDPath, | |
| 63 &app_id_or_package) && | |
| 64 (app_id == app_id_or_package || | |
| 65 arc_app_packege_name == app_id_or_package)) { | |
| 66 return AppListControllerDelegate::PIN_FIXED; | |
| 67 } | |
| 68 } | |
| 69 return AppListControllerDelegate::PIN_EDITABLE; | |
| 70 } | |
| OLD | NEW |