OLD | NEW |
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/cocoa/apps/app_shim_menu_controller_mac.h" | 5 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" |
11 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" | 13 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" |
13 #include "chrome/browser/apps/app_window_registry_util.h" | 14 #include "chrome/browser/apps/app_window_registry_util.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
17 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" | 18 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
20 #include "extensions/browser/app_window/app_window.h" | 21 #include "extensions/browser/app_window/app_window.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 - (void)appBecameMain:(const Extension*)app { | 529 - (void)appBecameMain:(const Extension*)app { |
529 if (appId_ == app->id()) | 530 if (appId_ == app->id()) |
530 return; | 531 return; |
531 | 532 |
532 if (!appId_.empty()) | 533 if (!appId_.empty()) |
533 [self removeMenuItems]; | 534 [self removeMenuItems]; |
534 | 535 |
535 appId_ = app->id(); | 536 appId_ = app->id(); |
536 [self addMenuItems:app]; | 537 [self addMenuItems:app]; |
537 if (IsAppWindowCyclingEnabled()) { | 538 if (IsAppWindowCyclingEnabled()) { |
538 base::MessageLoop::current()->PostTask( | 539 base::ThreadTaskRunnerHandle::Get()->PostTask( |
539 FROM_HERE, base::Bind(&SetAppCyclesWindows, appId_, | 540 FROM_HERE, base::Bind(&SetAppCyclesWindows, appId_, |
540 ++g_window_cycle_sequence_number)); | 541 ++g_window_cycle_sequence_number)); |
541 } | 542 } |
542 } | 543 } |
543 | 544 |
544 - (void)chromeBecameMain { | 545 - (void)chromeBecameMain { |
545 if (appId_.empty()) | 546 if (appId_.empty()) |
546 return; | 547 return; |
547 | 548 |
548 appId_.clear(); | 549 appId_.clear(); |
549 [self removeMenuItems]; | 550 [self removeMenuItems]; |
550 if (IsAppWindowCyclingEnabled()) { | 551 if (IsAppWindowCyclingEnabled()) { |
551 base::MessageLoop::current()->PostTask( | 552 base::ThreadTaskRunnerHandle::Get()->PostTask( |
552 FROM_HERE, | 553 FROM_HERE, |
553 base::Bind(&SetChromeCyclesWindows, ++g_window_cycle_sequence_number)); | 554 base::Bind(&SetChromeCyclesWindows, ++g_window_cycle_sequence_number)); |
554 } | 555 } |
555 } | 556 } |
556 | 557 |
557 - (void)addMenuItems:(const Extension*)app { | 558 - (void)addMenuItems:(const Extension*)app { |
558 DCHECK_EQ(appId_, app->id()); | 559 DCHECK_EQ(appId_, app->id()); |
559 NSString* title = base::SysUTF8ToNSString(app->name()); | 560 NSString* title = base::SysUTF8ToNSString(app->name()); |
560 | 561 |
561 // Hide Chrome menu items. | 562 // Hide Chrome menu items. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 648 |
648 - (void)focusCurrentPlatformApp { | 649 - (void)focusCurrentPlatformApp { |
649 extensions::AppWindow* appWindow = | 650 extensions::AppWindow* appWindow = |
650 AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile( | 651 AppWindowRegistryUtil::GetAppWindowForNativeWindowAnyProfile( |
651 [NSApp keyWindow]); | 652 [NSApp keyWindow]); |
652 if (appWindow) | 653 if (appWindow) |
653 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow); | 654 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow); |
654 } | 655 } |
655 | 656 |
656 @end | 657 @end |
OLD | NEW |