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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_utils.cc

Issue 2702723002: Extract kArcEnabled preference from ArcSessionManager part 1. (Closed)
Patch Set: Address comments. Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/app_list/arc/arc_app_utils.h" 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/chromeos/arc/arc_util.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #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"
17 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 18 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
18 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" 19 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h"
19 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
20 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
21 #include "chromeos/dbus/session_manager_client.h" 22 #include "chromeos/dbus/session_manager_client.h"
22 #include "components/arc/arc_bridge_service.h" 23 #include "components/arc/arc_bridge_service.h"
23 #include "components/arc/arc_service_manager.h" 24 #include "components/arc/arc_service_manager.h"
24 #include "components/arc/common/intent_helper.mojom.h" 25 #include "components/arc/common/intent_helper.mojom.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 return LaunchApp(context, app_id, kUseLandscapeLayout, event_flags); 259 return LaunchApp(context, app_id, kUseLandscapeLayout, event_flags);
259 } 260 }
260 261
261 bool LaunchApp(content::BrowserContext* context, 262 bool LaunchApp(content::BrowserContext* context,
262 const std::string& app_id, 263 const std::string& app_id,
263 bool landscape_layout, 264 bool landscape_layout,
264 int event_flags) { 265 int event_flags) {
265 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); 266 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
266 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); 267 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
267 if (app_info && !app_info->ready) { 268 if (app_info && !app_info->ready) {
268 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); 269 Profile* profile = Profile::FromBrowserContext(context);
269 DCHECK(arc_session_manager); 270 bool play_store_activated = false;
270 271 if (!IsArcPlayStoreEnabledForProfile(profile)) {
271 bool arc_activated = false;
272 if (!arc_session_manager->IsArcPlayStoreEnabled()) {
273 if (!prefs->IsDefault(app_id)) { 272 if (!prefs->IsDefault(app_id)) {
274 NOTREACHED(); 273 NOTREACHED();
275 return false; 274 return false;
276 } 275 }
277 276
278 arc_session_manager->SetArcPlayStoreEnabled(true); 277 SetArcPlayStoreEnabledForProfile(profile, true);
279 if (!arc_session_manager->IsArcPlayStoreEnabled()) { 278 if (!IsArcPlayStoreEnabledForProfile(profile)) {
280 NOTREACHED(); 279 NOTREACHED();
281 return false; 280 return false;
282 } 281 }
283 arc_activated = true; 282 play_store_activated = true;
284 } 283 }
285 284
286 // PlayStore item has special handling for shelf controllers. In order to 285 // PlayStore item has special handling for shelf controllers. In order to
287 // avoid unwanted initial animation for PlayStore item do not create 286 // avoid unwanted initial animation for PlayStore item do not create
288 // deferred launch request when PlayStore item enables ARC. 287 // deferred launch request when PlayStore item enables Google Play Store.
289 if (!arc_activated || app_id != kPlayStoreAppId) { 288 if (!play_store_activated || app_id != kPlayStoreAppId) {
290 ChromeLauncherController* chrome_controller = 289 ChromeLauncherController* chrome_controller =
291 ChromeLauncherController::instance(); 290 ChromeLauncherController::instance();
292 DCHECK(chrome_controller || !ash::Shell::HasInstance()); 291 DCHECK(chrome_controller || !ash::Shell::HasInstance());
293 if (chrome_controller) { 292 if (chrome_controller) {
294 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch( 293 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(
295 app_id, event_flags); 294 app_id, event_flags);
296 295
297 // On some boards, ARC is booted with a restricted set of resources by 296 // On some boards, ARC is booted with a restricted set of resources by
298 // default to avoid slowing down Chrome's user session restoration. 297 // default to avoid slowing down Chrome's user session restoration.
299 // However, the restriction should be lifted once the user explicitly 298 // However, the restriction should be lifted once the user explicitly
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 return false; 434 return false;
436 435
437 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); 436 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context);
438 if (!arc_prefs) 437 if (!arc_prefs)
439 return false; 438 return false;
440 439
441 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); 440 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id());
442 } 441 }
443 442
444 } // namespace arc 443 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_unittest.cc ('k') | chrome/browser/ui/ash/launcher/arc_app_launcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698