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

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

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove binary changes Created 7 years, 3 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 "apps/app_launcher.h" 10 #include "apps/app_launcher.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/ui/web_applications/web_app_ui.h" 29 #include "chrome/browser/ui/web_applications/web_app_ui.h"
30 #include "chrome/browser/web_applications/web_app.h" 30 #include "chrome/browser/web_applications/web_app.h"
31 #include "chrome/browser/web_applications/web_app_mac.h" 31 #include "chrome/browser/web_applications/web_app_mac.h"
32 #include "chrome/common/chrome_version_info.h" 32 #include "chrome/common/chrome_version_info.h"
33 #include "chrome/common/mac/app_mode_common.h" 33 #include "chrome/common/mac/app_mode_common.h"
34 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
35 #include "grit/chrome_unscaled_resources.h" 35 #include "grit/chrome_unscaled_resources.h"
36 #include "grit/google_chrome_strings.h" 36 #include "grit/google_chrome_strings.h"
37 #import "ui/app_list/cocoa/app_list_view_controller.h" 37 #import "ui/app_list/cocoa/app_list_view_controller.h"
38 #import "ui/app_list/cocoa/app_list_window_controller.h" 38 #import "ui/app_list/cocoa/app_list_window_controller.h"
39 #include "ui/app_list/search_box_model.h"
39 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
40 #include "ui/base/resource/resource_bundle.h" 41 #include "ui/base/resource/resource_bundle.h"
41 #include "ui/gfx/display.h" 42 #include "ui/gfx/display.h"
42 #include "ui/gfx/screen.h" 43 #include "ui/gfx/screen.h"
43 44
44 namespace gfx { 45 namespace gfx {
45 class ImageSkia; 46 class ImageSkia;
46 } 47 }
47 48
48 // Controller for animations that show or hide the app list. 49 // Controller for animations that show or hide the app list.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 virtual bool CanDoCreateShortcutsFlow(bool is_platform_app) OVERRIDE; 90 virtual bool CanDoCreateShortcutsFlow(bool is_platform_app) OVERRIDE;
90 virtual void CreateNewWindow(Profile* profile, bool incognito) OVERRIDE; 91 virtual void CreateNewWindow(Profile* profile, bool incognito) OVERRIDE;
91 virtual void DoCreateShortcutsFlow(Profile* profile, 92 virtual void DoCreateShortcutsFlow(Profile* profile,
92 const std::string& extension_id) OVERRIDE; 93 const std::string& extension_id) OVERRIDE;
93 virtual void ActivateApp(Profile* profile, 94 virtual void ActivateApp(Profile* profile,
94 const extensions::Extension* extension, 95 const extensions::Extension* extension,
95 int event_flags) OVERRIDE; 96 int event_flags) OVERRIDE;
96 virtual void LaunchApp(Profile* profile, 97 virtual void LaunchApp(Profile* profile,
97 const extensions::Extension* extension, 98 const extensions::Extension* extension,
98 int event_flags) OVERRIDE; 99 int event_flags) OVERRIDE;
100 virtual void ShowForProfileByPath(
101 const base::FilePath& profile_path) OVERRIDE;
99 102
100 DISALLOW_COPY_AND_ASSIGN(AppListControllerDelegateCocoa); 103 DISALLOW_COPY_AND_ASSIGN(AppListControllerDelegateCocoa);
101 }; 104 };
102 105
103 ShellIntegration::ShortcutInfo GetAppListShortcutInfo( 106 ShellIntegration::ShortcutInfo GetAppListShortcutInfo(
104 const base::FilePath& profile_path) { 107 const base::FilePath& profile_path) {
105 ShellIntegration::ShortcutInfo shortcut_info; 108 ShellIntegration::ShortcutInfo shortcut_info;
106 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 109 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
107 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { 110 if (channel == chrome::VersionInfo::CHANNEL_CANARY) {
108 shortcut_info.title = 111 shortcut_info.title =
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Profile* profile, const extensions::Extension* extension, int event_flags) { 240 Profile* profile, const extensions::Extension* extension, int event_flags) {
238 LaunchApp(profile, extension, event_flags); 241 LaunchApp(profile, extension, event_flags);
239 } 242 }
240 243
241 void AppListControllerDelegateCocoa::LaunchApp( 244 void AppListControllerDelegateCocoa::LaunchApp(
242 Profile* profile, const extensions::Extension* extension, int event_flags) { 245 Profile* profile, const extensions::Extension* extension, int event_flags) {
243 chrome::OpenApplication(chrome::AppLaunchParams( 246 chrome::OpenApplication(chrome::AppLaunchParams(
244 profile, extension, NEW_FOREGROUND_TAB)); 247 profile, extension, NEW_FOREGROUND_TAB));
245 } 248 }
246 249
250 void AppListControllerDelegateCocoa::ShowForProfileByPath(
251 const base::FilePath& profile_path) {
252 AppListService* service = AppListServiceMac::GetInstance();
253 service->SetProfilePath(profile_path);
254 service->Show();
255 }
256
247 enum DockLocation { 257 enum DockLocation {
248 DockLocationOtherDisplay, 258 DockLocationOtherDisplay,
249 DockLocationBottom, 259 DockLocationBottom,
250 DockLocationLeft, 260 DockLocationLeft,
251 DockLocationRight, 261 DockLocationRight,
252 }; 262 };
253 263
254 DockLocation DockLocationInDisplay(const gfx::Display& display) { 264 DockLocation DockLocationInDisplay(const gfx::Display& display) {
255 // Assume the dock occupies part of the work area either on the left, right or 265 // Assume the dock occupies part of the work area either on the left, right or
256 // bottom of the display. Note in the autohide case, it is always 4 pixels. 266 // bottom of the display. Note in the autohide case, it is always 4 pixels.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 412
403 init_called = true; 413 init_called = true;
404 apps::AppShimHandler::RegisterHandler(app_mode::kAppListModeId, 414 apps::AppShimHandler::RegisterHandler(app_mode::kAppListModeId,
405 AppListServiceMac::GetInstance()); 415 AppListServiceMac::GetInstance());
406 } 416 }
407 417
408 void AppListServiceMac::CreateForProfile(Profile* requested_profile) { 418 void AppListServiceMac::CreateForProfile(Profile* requested_profile) {
409 if (profile() == requested_profile) 419 if (profile() == requested_profile)
410 return; 420 return;
411 421
412 // The Objective C objects might be released at some unknown point in the 422 SetProfile(requested_profile);
413 // future, so explicitly clear references to C++ objects.
414 [[window_controller_ appListViewController]
415 setDelegate:scoped_ptr<app_list::AppListViewDelegate>()];
416 423
417 SetProfile(requested_profile); 424 if (window_controller_) {
425 // Clear the search box.
426 [[window_controller_ appListViewController] searchBoxModel]
427 ->SetText(base::string16());
428 } else {
429 window_controller_.reset([[AppListWindowController alloc] init]);
430 }
431
418 scoped_ptr<app_list::AppListViewDelegate> delegate( 432 scoped_ptr<app_list::AppListViewDelegate> delegate(
419 new AppListViewDelegate(new AppListControllerDelegateCocoa(), profile())); 433 new AppListViewDelegate(new AppListControllerDelegateCocoa(), profile()));
420 window_controller_.reset([[AppListWindowController alloc] init]);
421 [[window_controller_ appListViewController] setDelegate:delegate.Pass()]; 434 [[window_controller_ appListViewController] setDelegate:delegate.Pass()];
422 } 435 }
423 436
424 void AppListServiceMac::ShowForProfile(Profile* requested_profile) { 437 void AppListServiceMac::ShowForProfile(Profile* requested_profile) {
425 if (requested_profile->IsManaged()) 438 if (requested_profile->IsManaged())
426 return; 439 return;
427 440
428 InvalidatePendingProfileLoads(); 441 InvalidatePendingProfileLoads();
429 442
430 if (IsAppListVisible() && (requested_profile == profile())) { 443 if (requested_profile == profile()) {
431 ShowWindowNearDock(); 444 ShowWindowNearDock();
432 return; 445 return;
433 } 446 }
434 447
435 SetProfilePath(requested_profile->GetPath()); 448 SetProfilePath(requested_profile->GetPath());
436
437 DismissAppList();
438 CreateForProfile(requested_profile); 449 CreateForProfile(requested_profile);
439 ShowWindowNearDock(); 450 ShowWindowNearDock();
440 } 451 }
441 452
442 void AppListServiceMac::DismissAppList() { 453 void AppListServiceMac::DismissAppList() {
443 if (!IsAppListVisible()) 454 if (!IsAppListVisible())
444 return; 455 return;
445 456
446 // If the app list is currently the main window, it will activate the next 457 // If the app list is currently the main window, it will activate the next
447 // Chrome window when dismissed. But if a different application was active 458 // Chrome window when dismissed. But if a different application was active
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 void AppListServiceMac::OnShimFocus(apps::AppShimHandler::Host* host, 510 void AppListServiceMac::OnShimFocus(apps::AppShimHandler::Host* host,
500 apps::AppShimFocusType focus_type, 511 apps::AppShimFocusType focus_type,
501 const std::vector<base::FilePath>& files) {} 512 const std::vector<base::FilePath>& files) {}
502 513
503 void AppListServiceMac::OnShimSetHidden(apps::AppShimHandler::Host* host, 514 void AppListServiceMac::OnShimSetHidden(apps::AppShimHandler::Host* host,
504 bool hidden) {} 515 bool hidden) {}
505 516
506 void AppListServiceMac::OnShimQuit(apps::AppShimHandler::Host* host) {} 517 void AppListServiceMac::OnShimQuit(apps::AppShimHandler::Host* host) {}
507 518
508 void AppListServiceMac::ShowWindowNearDock() { 519 void AppListServiceMac::ShowWindowNearDock() {
520 if (IsAppListVisible())
521 return;
522
509 NSWindow* window = GetAppListWindow(); 523 NSWindow* window = GetAppListWindow();
510 DCHECK(window); 524 DCHECK(window);
511 NSPoint target_origin; 525 NSPoint target_origin;
512 GetAppListWindowOrigins(window, &target_origin, &last_start_origin_); 526 GetAppListWindowOrigins(window, &target_origin, &last_start_origin_);
513 [window setFrameOrigin:last_start_origin_]; 527 [window setFrameOrigin:last_start_origin_];
514 528
515 // Before activating, see if an application other than Chrome is currently the 529 // Before activating, see if an application other than Chrome is currently the
516 // active application, so that it can be reactivated when dismissing. 530 // active application, so that it can be reactivated when dismissing.
517 previously_active_application_.reset([ActiveApplicationNotChrome() retain]); 531 previously_active_application_.reset([ActiveApplicationNotChrome() retain]);
518 532
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 [animation_ startAnimation]; 590 [animation_ startAnimation];
577 } 591 }
578 592
579 - (void)animationDidEnd:(NSAnimation*)animation { 593 - (void)animationDidEnd:(NSAnimation*)animation {
580 [window_ close]; 594 [window_ close];
581 window_.reset(); 595 window_.reset();
582 animation_.reset(); 596 animation_.reset();
583 } 597 }
584 598
585 @end 599 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_controller_delegate.h ('k') | chrome/browser/ui/app_list/app_list_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698