OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 5 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/app_mode/app_mode_utils.h" | 14 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 15 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 16 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
15 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 17 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
16 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" | 18 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" |
17 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
18 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
19 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
20 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
21 #include "components/prefs/scoped_user_pref_update.h" | 23 #include "components/prefs/scoped_user_pref_update.h" |
22 #include "ui/display/screen.h" | 24 #include "ui/display/screen.h" |
23 | 25 |
24 namespace ash { | 26 namespace ash { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value); | 287 SetPerDisplayPref(prefs, display_id, prefs::kShelfAlignment, value); |
286 if (display_id == display::Screen::GetScreen()->GetPrimaryDisplay().id()) { | 288 if (display_id == display::Screen::GetScreen()->GetPrimaryDisplay().id()) { |
287 // See comment in |kShelfAlignment| as to why we consider two prefs. | 289 // See comment in |kShelfAlignment| as to why we consider two prefs. |
288 prefs->SetString(prefs::kShelfAlignmentLocal, value); | 290 prefs->SetString(prefs::kShelfAlignmentLocal, value); |
289 prefs->SetString(prefs::kShelfAlignment, value); | 291 prefs->SetString(prefs::kShelfAlignment, value); |
290 } | 292 } |
291 } | 293 } |
292 | 294 |
293 std::vector<std::string> GetPinnedAppsFromPrefs( | 295 std::vector<std::string> GetPinnedAppsFromPrefs( |
294 const PrefService* prefs, | 296 const PrefService* prefs, |
295 const LauncherControllerHelper* helper) { | 297 LauncherControllerHelper* helper) { |
296 // Adding the app list item to the list of items requires that the ID is not | 298 // Adding the app list item to the list of items requires that the ID is not |
297 // a valid and known ID for the extension system. The ID was constructed that | 299 // a valid and known ID for the extension system. The ID was constructed that |
298 // way - but just to make sure... | 300 // way - but just to make sure... |
299 DCHECK(!helper->IsValidIDForCurrentUser(kPinnedAppsPlaceholder)); | 301 DCHECK(!helper->IsValidIDForCurrentUser(kPinnedAppsPlaceholder)); |
300 | 302 |
301 std::vector<std::string> apps; | 303 std::vector<std::string> apps; |
302 const auto* pinned = prefs->GetList(prefs::kPinnedLauncherApps); | 304 const auto* pinned = prefs->GetList(prefs::kPinnedLauncherApps); |
303 const auto* policy = prefs->GetList(prefs::kPolicyPinnedLauncherApps); | 305 const auto* policy = prefs->GetList(prefs::kPolicyPinnedLauncherApps); |
304 | 306 |
305 // Get the sanitized preference value for the index of the Chrome app icon. | 307 // Get the sanitized preference value for the index of the Chrome app icon. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 dictionary->GetString(kPinnedAppsPrefAppIDPath, &app_id) && | 362 dictionary->GetString(kPinnedAppsPrefAppIDPath, &app_id) && |
361 helper->IsValidIDForCurrentUser(app_id) && | 363 helper->IsValidIDForCurrentUser(app_id) && |
362 std::find(apps.begin(), apps.end(), app_id) == apps.end() && | 364 std::find(apps.begin(), apps.end(), app_id) == apps.end() && |
363 (!dictionary->GetBoolean(kPinnedAppsPrefPinnedByPolicy, | 365 (!dictionary->GetBoolean(kPinnedAppsPrefPinnedByPolicy, |
364 &pinned_by_policy) || | 366 &pinned_by_policy) || |
365 !pinned_by_policy)) { | 367 !pinned_by_policy)) { |
366 apps.push_back(app_id); | 368 apps.push_back(app_id); |
367 } | 369 } |
368 } | 370 } |
369 | 371 |
| 372 if (arc::ArcAuthService::IsAllowedForProfile(helper->profile()) && |
| 373 helper->IsValidIDForCurrentUser(ArcSupportHost::kHostAppId)) { |
| 374 apps.push_back(ArcSupportHost::kHostAppId); |
| 375 } |
| 376 |
370 // If not added yet, the chrome item will be the last item in the list. | 377 // If not added yet, the chrome item will be the last item in the list. |
371 if (!chrome_listed) | 378 if (!chrome_listed) |
372 apps.push_back(extension_misc::kChromeAppId); | 379 apps.push_back(extension_misc::kChromeAppId); |
373 | 380 |
374 // If not added yet, place the app list item at the beginning of the list. | 381 // If not added yet, place the app list item at the beginning of the list. |
375 if (std::find(apps.begin(), apps.end(), kPinnedAppsPlaceholder) == apps.end()) | 382 if (std::find(apps.begin(), apps.end(), kPinnedAppsPlaceholder) == apps.end()) |
376 apps.insert(apps.begin(), kPinnedAppsPlaceholder); | 383 apps.insert(apps.begin(), kPinnedAppsPlaceholder); |
377 | 384 |
378 return apps; | 385 return apps; |
379 } | 386 } |
380 | 387 |
381 } // namespace ash | 388 } // namespace ash |
OLD | NEW |