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

Side by Side Diff: chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler.cc

Issue 2833173002: mash: Support ShelfModel access in Chrome. (Closed)
Patch Set: Address comments; fix test failures. Created 3 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/chromeos/arc/arc_play_store_enabled_preference_handler. h" 5 #include "chrome/browser/chromeos/arc/arc_play_store_enabled_preference_handler. h"
6 6
7 #include "ash/shelf/shelf_model.h"
8 #include "ash/shell.h"
9 #include "base/bind.h" 7 #include "base/bind.h"
10 #include "base/command_line.h" 8 #include "base/command_line.h"
11 #include "base/logging.h" 9 #include "base/logging.h"
12 #include "chrome/browser/chromeos/arc/arc_auth_notification.h" 10 #include "chrome/browser/chromeos/arc/arc_auth_notification.h"
13 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" 11 #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
14 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 12 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
15 #include "chrome/browser/chromeos/arc/arc_util.h" 13 #include "chrome/browser/chromeos/arc/arc_util.h"
16 #include "chrome/browser/prefs/pref_service_syncable_util.h" 14 #include "chrome/browser/prefs/pref_service_syncable_util.h"
17 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 16 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
19 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
20 #include "chromeos/chromeos_switches.h" 19 #include "chromeos/chromeos_switches.h"
21 #include "components/arc/arc_util.h" 20 #include "components/arc/arc_util.h"
22 #include "components/sync_preferences/pref_service_syncable.h" 21 #include "components/sync_preferences/pref_service_syncable.h"
23 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
24 23
25 namespace arc { 24 namespace arc {
26 25
27 ArcPlayStoreEnabledPreferenceHandler::ArcPlayStoreEnabledPreferenceHandler( 26 ArcPlayStoreEnabledPreferenceHandler::ArcPlayStoreEnabledPreferenceHandler(
28 Profile* profile, 27 Profile* profile,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 arc_session_manager_->RequestArcDataRemoval(); 74 arc_session_manager_->RequestArcDataRemoval();
76 } 75 }
77 76
78 // ArcAuthNotification may need to be shown. 77 // ArcAuthNotification may need to be shown.
79 PrefServiceSyncableFromProfile(profile_)->AddObserver(this); 78 PrefServiceSyncableFromProfile(profile_)->AddObserver(this);
80 OnIsSyncingChanged(); 79 OnIsSyncingChanged();
81 } 80 }
82 81
83 void ArcPlayStoreEnabledPreferenceHandler::OnPreferenceChanged() { 82 void ArcPlayStoreEnabledPreferenceHandler::OnPreferenceChanged() {
84 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 83 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
85
86 const bool is_play_store_enabled = IsArcPlayStoreEnabledForProfile(profile_); 84 const bool is_play_store_enabled = IsArcPlayStoreEnabledForProfile(profile_);
87 if (!IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_)) { 85 if (!IsArcPlayStoreEnabledPreferenceManagedForProfile(profile_)) {
88 // Update UMA only for non-Managed cases. 86 // Update UMA only for non-Managed cases.
89 UpdateOptInActionUMA(is_play_store_enabled ? OptInActionType::OPTED_IN 87 UpdateOptInActionUMA(is_play_store_enabled ? OptInActionType::OPTED_IN
90 : OptInActionType::OPTED_OUT); 88 : OptInActionType::OPTED_OUT);
91 89
92 if (!is_play_store_enabled) { 90 if (!is_play_store_enabled) {
93 // Remove the pinned Play Store icon launcher in Shelf. 91 // Remove the pinned Play Store icon launcher in Shelf.
94 // This is only for non-Managed cases. In managed cases, it is expected 92 // This is only for non-Managed cases. In managed cases, it is expected
95 // to be "disabled" rather than "removed", so keep it here. 93 // to be "disabled" rather than "removed", so keep it here.
96 auto* shelf_model = ash::Shell::HasInstance() 94 auto* chrome_launcher_controller = ChromeLauncherController::instance();
97 ? ash::Shell::Get()->shelf_model() 95 if (chrome_launcher_controller)
98 : nullptr; 96 chrome_launcher_controller->UnpinAppWithID(kPlayStoreAppId);
99 if (shelf_model)
100 shelf_model->UnpinAppWithID(kPlayStoreAppId);
101 } 97 }
102 } 98 }
103 99
104 // Hide auth notification if it was opened before and arc.enabled pref was 100 // Hide auth notification if it was opened before and arc.enabled pref was
105 // explicitly set to true or false. 101 // explicitly set to true or false.
106 if (profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) 102 if (profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled))
107 ArcAuthNotification::Hide(); 103 ArcAuthNotification::Hide();
108 104
109 UpdateArcSessionManager(); 105 UpdateArcSessionManager();
110 106
(...skipping 26 matching lines...) Expand all
137 // TODO(hidehiko): Extract kEnableArcOOBEOptIn check as a utility method. 133 // TODO(hidehiko): Extract kEnableArcOOBEOptIn check as a utility method.
138 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 134 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
139 chromeos::switches::kEnableArcOOBEOptIn) && 135 chromeos::switches::kEnableArcOOBEOptIn) &&
140 profile_->IsNewProfile() && 136 profile_->IsNewProfile() &&
141 !profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) { 137 !profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) {
142 ArcAuthNotification::Show(profile_); 138 ArcAuthNotification::Show(profile_);
143 } 139 }
144 } 140 }
145 141
146 } // namespace arc 142 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698