Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/app_controller_mac.h" | 5 #import "chrome/browser/app_controller_mac.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" | 60 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
| 61 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 61 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
| 62 #include "chrome/browser/ui/extensions/application_launch.h" | 62 #include "chrome/browser/ui/extensions/application_launch.h" |
| 63 #include "chrome/browser/ui/host_desktop.h" | 63 #include "chrome/browser/ui/host_desktop.h" |
| 64 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 64 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 65 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 65 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 66 #include "chrome/common/chrome_notification_types.h" | 66 #include "chrome/common/chrome_notification_types.h" |
| 67 #include "chrome/common/chrome_paths_internal.h" | 67 #include "chrome/common/chrome_paths_internal.h" |
| 68 #include "chrome/common/chrome_switches.h" | 68 #include "chrome/common/chrome_switches.h" |
| 69 #include "chrome/common/cloud_print/cloud_print_class_mac.h" | 69 #include "chrome/common/cloud_print/cloud_print_class_mac.h" |
| 70 #include "chrome/common/extensions/extension.h" | |
| 70 #include "chrome/common/extensions/extension_constants.h" | 71 #include "chrome/common/extensions/extension_constants.h" |
| 71 #include "chrome/common/mac/app_mode_common.h" | 72 #include "chrome/common/mac/app_mode_common.h" |
| 72 #include "chrome/common/pref_names.h" | 73 #include "chrome/common/pref_names.h" |
| 73 #include "chrome/common/service_messages.h" | 74 #include "chrome/common/service_messages.h" |
| 74 #include "chrome/common/url_constants.h" | 75 #include "chrome/common/url_constants.h" |
| 75 #include "content/public/browser/browser_thread.h" | 76 #include "content/public/browser/browser_thread.h" |
| 76 #include "content/public/browser/download_manager.h" | 77 #include "content/public/browser/download_manager.h" |
| 77 #include "content/public/browser/notification_service.h" | 78 #include "content/public/browser/notification_service.h" |
| 78 #include "content/public/browser/notification_types.h" | 79 #include "content/public/browser/notification_types.h" |
| 79 #include "content/public/browser/plugin_service.h" | 80 #include "content/public/browser/plugin_service.h" |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1303 [self performSelector:@selector(delayedScreenParametersUpdate) | 1304 [self performSelector:@selector(delayedScreenParametersUpdate) |
| 1304 withObject:nil | 1305 withObject:nil |
| 1305 afterDelay:0]; | 1306 afterDelay:0]; |
| 1306 } | 1307 } |
| 1307 | 1308 |
| 1308 - (void)delayedScreenParametersUpdate { | 1309 - (void)delayedScreenParametersUpdate { |
| 1309 FOR_EACH_OBSERVER(ui::WorkAreaWatcherObserver, workAreaChangeObservers_, | 1310 FOR_EACH_OBSERVER(ui::WorkAreaWatcherObserver, workAreaChangeObservers_, |
| 1310 WorkAreaChanged()); | 1311 WorkAreaChanged()); |
| 1311 } | 1312 } |
| 1312 | 1313 |
| 1314 - (void)setMenuBarToApp:(NSString*)app_id | |
| 1315 withTitle:(NSString*)title { | |
| 1316 NSMenu* mainMenu = [NSApp mainMenu]; | |
| 1317 | |
| 1318 for (NSMenuItem* item in [mainMenu itemArray]) | |
| 1319 [item setHidden:YES]; | |
| 1320 | |
| 1321 NSMenuItem* itemForApp = [mainMenu itemWithTitle:app_id]; | |
| 1322 if (!itemForApp) { | |
| 1323 NSMenuItem* appMenuItem = [[NSMenuItem alloc] | |
|
tapted
2013/06/28 04:09:43
there's a memory leak here ;) - you need
scoped_n
jackhou1
2013/07/04 01:57:55
Done.
| |
| 1324 initWithTitle:app_id | |
| 1325 action:@selector(itemSelected:) | |
|
tapted
2013/06/28 04:09:43
I think the action can be `nil`, since we aren't s
jackhou1
2013/07/04 01:57:55
Done.
| |
| 1326 keyEquivalent:@""]; | |
| 1327 NSMenu* appMenu = [[NSMenu alloc] initWithTitle:title]; | |
|
tapted
2013/06/28 04:09:43
scoped_nsobject<NSMenu>
jackhou1
2013/07/04 01:57:55
Done.
| |
| 1328 [appMenuItem setSubmenu:appMenu]; | |
| 1329 [mainMenu addItem:appMenuItem]; | |
| 1330 } | |
| 1331 [itemForApp setHidden:NO]; | |
|
tapted
2013/06/28 04:09:43
maybe in an else {? you're not re-assigning, so it
jackhou1
2013/07/04 01:57:55
Done.
| |
| 1332 } | |
| 1333 | |
| 1334 - (void)setMenuBarToChrome { | |
| 1335 NSMenu* mainMenu = [NSApp mainMenu]; | |
|
tapted
2013/06/28 04:09:43
nit: probably don't need this temporary
jackhou1
2013/07/04 01:57:55
Done.
| |
| 1336 for (NSMenuItem* item in [mainMenu itemArray]) { | |
| 1337 const std::string& title = base::SysNSStringToUTF8([item title]); | |
| 1338 [item setHidden:extensions::Extension::IdIsValid(title)]; | |
|
tapted
2013/06/28 04:09:43
hm.. this feels a bit odd.. Swapping out [NSApp ma
jackhou1
2013/07/04 01:57:55
Done.
| |
| 1339 } | |
| 1340 } | |
| 1341 | |
| 1313 @end // @implementation AppController | 1342 @end // @implementation AppController |
| 1314 | 1343 |
| 1315 //--------------------------------------------------------------------------- | 1344 //--------------------------------------------------------------------------- |
| 1316 | 1345 |
| 1317 namespace app_controller_mac { | 1346 namespace app_controller_mac { |
| 1318 | 1347 |
| 1319 bool IsOpeningNewWindow() { | 1348 bool IsOpeningNewWindow() { |
| 1320 return g_is_opening_new_window; | 1349 return g_is_opening_new_window; |
| 1321 } | 1350 } |
| 1322 | 1351 |
| 1323 } // namespace app_controller_mac | 1352 } // namespace app_controller_mac |
| OLD | NEW |