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

Side by Side Diff: chrome/browser/ui/app_list/app_list_service_mac.mm

Issue 856733004: Loading the Launcher with a Locked Profile launched UserManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tapted@: test fixes and remove a const-ref. Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #import "chrome/browser/ui/app_list/app_list_service_mac.h" 5 #import "chrome/browser/ui/app_list/app_list_service_mac.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #import "chrome/browser/app_controller_mac.h" 17 #import "chrome/browser/app_controller_mac.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/profiles/profile_info_cache.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/ui/app_list/app_list_controller_delegate_impl.h" 22 #include "chrome/browser/ui/app_list/app_list_controller_delegate_impl.h"
22 #include "chrome/browser/ui/app_list/app_list_positioner.h" 23 #include "chrome/browser/ui/app_list/app_list_positioner.h"
23 #include "chrome/browser/ui/app_list/app_list_service.h" 24 #include "chrome/browser/ui/app_list/app_list_service.h"
24 #include "chrome/browser/ui/app_list/app_list_service_impl.h" 25 #include "chrome/browser/ui/app_list/app_list_service_impl.h"
25 #include "chrome/browser/ui/app_list/app_list_util.h" 26 #include "chrome/browser/ui/app_list/app_list_util.h"
26 #include "chrome/browser/ui/app_list/app_list_view_delegate.h" 27 #include "chrome/browser/ui/app_list/app_list_view_delegate.h"
27 #include "chrome/browser/ui/browser_commands.h" 28 #include "chrome/browser/ui/browser_commands.h"
28 #include "chrome/browser/ui/extensions/application_launch.h" 29 #include "chrome/browser/ui/extensions/application_launch.h"
29 #include "chrome/browser/web_applications/web_app.h" 30 #include "chrome/browser/web_applications/web_app.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 case AppListPositioner::SCREEN_EDGE_TOP: 331 case AppListPositioner::SCREEN_EDGE_TOP:
331 NOTREACHED(); 332 NOTREACHED();
332 break; 333 break;
333 case AppListPositioner::SCREEN_EDGE_BOTTOM: 334 case AppListPositioner::SCREEN_EDGE_BOTTOM:
334 start_origin->y -= kDistanceMovedOnShow; 335 start_origin->y -= kDistanceMovedOnShow;
335 break; 336 break;
336 } 337 }
337 } 338 }
338 339
339 void AppListServiceMac::Init(Profile* initial_profile) { 340 void AppListServiceMac::Init(Profile* initial_profile) {
341 InitWithProfilePath(initial_profile, initial_profile->GetPath());
342 }
343
344 void AppListServiceMac::InitWithProfilePath(
345 Profile* initial_profile,
346 const base::FilePath& profile_path) {
340 // On Mac, Init() is called multiple times for a process: any time there is no 347 // On Mac, Init() is called multiple times for a process: any time there is no
341 // browser window open and a new window is opened, and during process startup 348 // browser window open and a new window is opened, and during process startup
342 // to handle the silent launch case (e.g. for app shims). In the startup case, 349 // to handle the silent launch case (e.g. for app shims). In the startup case,
343 // a profile has not yet been determined so |initial_profile| will be NULL. 350 // a profile has not yet been determined so |initial_profile| will be NULL.
344 static bool init_called_with_profile = false; 351 static bool init_called_with_profile = false;
345 if (initial_profile && !init_called_with_profile) { 352 if (initial_profile && !init_called_with_profile) {
346 init_called_with_profile = true; 353 init_called_with_profile = true;
347 PerformStartupChecks(initial_profile); 354 PerformStartupChecks(initial_profile);
348 PrefService* local_state = g_browser_process->local_state(); 355 PrefService* local_state = g_browser_process->local_state();
349 if (!IsAppLauncherEnabled()) { 356 if (!IsAppLauncherEnabled()) {
(...skipping 14 matching lines...) Expand all
364 init_called = true; 371 init_called = true;
365 apps::AppShimHandler::RegisterHandler(app_mode::kAppListModeId, 372 apps::AppShimHandler::RegisterHandler(app_mode::kAppListModeId,
366 AppListServiceMac::GetInstance()); 373 AppListServiceMac::GetInstance());
367 374
368 // Handle the case where Chrome was not running and was started with the app 375 // Handle the case where Chrome was not running and was started with the app
369 // launcher shim. The profile has not yet been loaded. To improve response 376 // launcher shim. The profile has not yet been loaded. To improve response
370 // times, start animating an empty window which will be populated via 377 // times, start animating an empty window which will be populated via
371 // OnShimLaunch(). Note that if --silent-launch is not also passed, the window 378 // OnShimLaunch(). Note that if --silent-launch is not also passed, the window
372 // will instead populate via StartupBrowserCreator::Launch(). Shim-initiated 379 // will instead populate via StartupBrowserCreator::Launch(). Shim-initiated
373 // launches will always have --silent-launch. 380 // launches will always have --silent-launch.
374 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowAppList)) 381 if (base::CommandLine::ForCurrentProcess()->
375 ShowWindowNearDock(); 382 HasSwitch(switches::kShowAppList)) {
383 // Do not show the launcher window when the profile is locked.
384 const ProfileInfoCache& profile_info_cache =
385 g_browser_process->profile_manager()->GetProfileInfoCache();
386 size_t profile_index = profile_info_cache.
387 GetIndexOfProfileWithPath(profile_path);
388 if (profile_index != std::string::npos &&
389 !profile_info_cache.ProfileIsSigninRequiredAtIndex(profile_index))
390 ShowWindowNearDock();
391 }
376 } 392 }
377 393
378 Profile* AppListServiceMac::GetCurrentAppListProfile() { 394 Profile* AppListServiceMac::GetCurrentAppListProfile() {
379 return profile_; 395 return profile_;
380 } 396 }
381 397
382 void AppListServiceMac::ShowForProfile(Profile* requested_profile) { 398 void AppListServiceMac::ShowForProfile(Profile* requested_profile) {
383 CreateForProfile(requested_profile); 399 CreateForProfile(requested_profile);
384 ShowWindowNearDock(); 400 ShowWindowNearDock();
385 } 401 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 void AppListServiceMac::WindowAnimationDidEnd() { 539 void AppListServiceMac::WindowAnimationDidEnd() {
524 [animation_controller_ cleanupOnUIThread]; 540 [animation_controller_ cleanupOnUIThread];
525 } 541 }
526 542
527 // static 543 // static
528 AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) { 544 AppListService* AppListService::Get(chrome::HostDesktopType desktop_type) {
529 return AppListServiceMac::GetInstance(); 545 return AppListServiceMac::GetInstance();
530 } 546 }
531 547
532 // static 548 // static
533 void AppListService::InitAll(Profile* initial_profile) { 549 void AppListService::InitAll(Profile* initial_profile,
534 AppListServiceMac::GetInstance()->Init(initial_profile); 550 const base::FilePath& profile_path) {
551 AppListServiceMac::GetInstance()->InitWithProfilePath(initial_profile,
552 profile_path);
535 } 553 }
536 554
537 @implementation AppListAnimationController 555 @implementation AppListAnimationController
538 556
539 - (BOOL)isClosing { 557 - (BOOL)isClosing {
540 return !!window_; 558 return !!window_;
541 } 559 }
542 560
543 - (void)animateWindow:(NSWindow*)window 561 - (void)animateWindow:(NSWindow*)window
544 targetOrigin:(NSPoint)targetOrigin 562 targetOrigin:(NSPoint)targetOrigin
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 614
597 - (void)animationDidEnd:(NSAnimation*)animation { 615 - (void)animationDidEnd:(NSAnimation*)animation {
598 content::BrowserThread::PostTask( 616 content::BrowserThread::PostTask(
599 content::BrowserThread::UI, 617 content::BrowserThread::UI,
600 FROM_HERE, 618 FROM_HERE,
601 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, 619 base::Bind(&AppListServiceMac::WindowAnimationDidEnd,
602 base::Unretained(AppListServiceMac::GetInstance()))); 620 base::Unretained(AppListServiceMac::GetInstance())));
603 } 621 }
604 622
605 @end 623 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service_mac.h ('k') | chrome/browser/ui/app_list/profile_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698