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

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

Issue 2707133006: Start ARC and sign in after Chrome OS login (Closed)
Patch Set: rebase to ToT Created 3 years, 9 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/chromeos/arc/arc_util.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #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"
18 #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"
19 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h" 19 #include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h"
20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 20 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/session_manager_client.h" 22 #include "chromeos/dbus/session_manager_client.h"
23 #include "components/arc/arc_bridge_service.h" 23 #include "components/arc/arc_bridge_service.h"
24 #include "components/arc/arc_service_manager.h" 24 #include "components/arc/arc_service_manager.h"
25 #include "components/arc/arc_util.h"
25 #include "components/arc/common/intent_helper.mojom.h" 26 #include "components/arc/common/intent_helper.mojom.h"
26 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
27 #include "ui/display/display.h" 28 #include "ui/display/display.h"
28 #include "ui/display/screen.h" 29 #include "ui/display/screen.h"
29 #include "ui/events/event_constants.h" 30 #include "ui/events/event_constants.h"
30 31
31 // Helper macro which returns the AppInstance. 32 // Helper macro which returns the AppInstance.
32 #define GET_APP_INSTANCE(method_name) \ 33 #define GET_APP_INSTANCE(method_name) \
33 (arc::ArcServiceManager::Get() \ 34 (arc::ArcServiceManager::Get() \
34 ? ARC_GET_INSTANCE_FOR_METHOD( \ 35 ? ARC_GET_INSTANCE_FOR_METHOD( \
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 261 }
261 262
262 bool LaunchApp(content::BrowserContext* context, 263 bool LaunchApp(content::BrowserContext* context,
263 const std::string& app_id, 264 const std::string& app_id,
264 bool landscape_layout, 265 bool landscape_layout,
265 int event_flags) { 266 int event_flags) {
266 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); 267 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context);
267 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); 268 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
268 if (app_info && !app_info->ready) { 269 if (app_info && !app_info->ready) {
269 Profile* profile = Profile::FromBrowserContext(context); 270 Profile* profile = Profile::FromBrowserContext(context);
270 bool play_store_activated = false; 271
271 if (!IsArcPlayStoreEnabledForProfile(profile)) { 272 if (!IsArcPlayStoreEnabledForProfile(profile)) {
272 if (!prefs->IsDefault(app_id)) { 273 if (prefs->IsDefault(app_id)) {
273 NOTREACHED(); 274 // The setting can fail if the preference is managed. However, the
274 return false; 275 // caller is responsible to not call this function in such case. DCHECK
276 // is here to prevent possible mistake.
277 SetArcPlayStoreEnabledForProfile(profile, true);
278 DCHECK(IsArcPlayStoreEnabledForProfile(profile));
279
280 // PlayStore item has special handling for shelf controllers. In order
281 // to avoid unwanted initial animation for PlayStore item do not create
282 // deferred launch request when PlayStore item enables Google Play
283 // Store.
284 if (app_id == kPlayStoreAppId) {
285 prefs->SetLastLaunchTime(app_id, base::Time::Now());
286 return true;
287 }
288 } else {
289 // Only reachable when ARC always starts.
290 DCHECK(arc::ShouldArcAlwaysStart());
275 } 291 }
276
277 SetArcPlayStoreEnabledForProfile(profile, true);
278 if (!IsArcPlayStoreEnabledForProfile(profile)) {
279 NOTREACHED();
280 return false;
281 }
282 play_store_activated = true;
283 } 292 }
284 293
285 // PlayStore item has special handling for shelf controllers. In order to 294 ChromeLauncherController* chrome_controller =
286 // avoid unwanted initial animation for PlayStore item do not create 295 ChromeLauncherController::instance();
287 // deferred launch request when PlayStore item enables Google Play Store. 296 DCHECK(chrome_controller || !ash::Shell::HasInstance());
288 if (!play_store_activated || app_id != kPlayStoreAppId) { 297 if (chrome_controller) {
289 ChromeLauncherController* chrome_controller = 298 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(
290 ChromeLauncherController::instance(); 299 app_id, event_flags);
291 DCHECK(chrome_controller || !ash::Shell::HasInstance());
292 if (chrome_controller) {
293 chrome_controller->GetArcDeferredLauncher()->RegisterDeferredLaunch(
294 app_id, event_flags);
295 300
296 // On some boards, ARC is booted with a restricted set of resources by 301 // On some boards, ARC is booted with a restricted set of resources by
297 // default to avoid slowing down Chrome's user session restoration. 302 // default to avoid slowing down Chrome's user session restoration.
298 // However, the restriction should be lifted once the user explicitly 303 // However, the restriction should be lifted once the user explicitly
299 // tries to launch an ARC app. 304 // tries to launch an ARC app.
300 VLOG(2) << "Prioritizing the instance"; 305 VLOG(2) << "Prioritizing the instance";
301 chromeos::SessionManagerClient* session_manager_client = 306 chromeos::SessionManagerClient* session_manager_client =
302 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); 307 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
303 session_manager_client->SetArcCpuRestriction( 308 session_manager_client->SetArcCpuRestriction(
304 login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND, 309 login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND,
305 base::Bind(SetArcCpuRestrictionCallback)); 310 base::Bind(SetArcCpuRestrictionCallback));
306 }
307 } 311 }
308 prefs->SetLastLaunchTime(app_id, base::Time::Now()); 312 prefs->SetLastLaunchTime(app_id, base::Time::Now());
309 return true; 313 return true;
310 } 314 }
311
312 return (new LaunchAppWithoutSize(context, app_id, landscape_layout, 315 return (new LaunchAppWithoutSize(context, app_id, landscape_layout,
313 event_flags)) 316 event_flags))
314 ->LaunchAndRelease(); 317 ->LaunchAndRelease();
315 } 318 }
316 319
317 void SetTaskActive(int task_id) { 320 void SetTaskActive(int task_id) {
318 arc::mojom::AppInstance* app_instance = GET_APP_INSTANCE(SetTaskActive); 321 arc::mojom::AppInstance* app_instance = GET_APP_INSTANCE(SetTaskActive);
319 if (!app_instance) 322 if (!app_instance)
320 return; 323 return;
321 app_instance->SetTaskActive(task_id); 324 app_instance->SetTaskActive(task_id);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 return false; 437 return false;
435 438
436 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context); 439 const ArcAppListPrefs* const arc_prefs = ArcAppListPrefs::Get(context);
437 if (!arc_prefs) 440 if (!arc_prefs)
438 return false; 441 return false;
439 442
440 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id()); 443 return arc_prefs->IsRegistered(ArcAppShelfId::FromString(id).app_id());
441 } 444 }
442 445
443 } // namespace arc 446 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698