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

Side by Side Diff: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm

Issue 494033002: Move AppWindow to extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded include in chrome_shell_delegate.cc Created 6 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 | Annotate | Revision Log
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/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 "apps/app_shim/extension_app_shim_handler_mac.h" 7 #include "apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "apps/app_window.h"
9 #include "apps/app_window_registry.h"
10 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
13 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" 11 #import "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h"
14 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
13 #include "extensions/browser/app_window/app_window.h"
14 #include "extensions/browser/app_window/app_window_registry.h"
15 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/l10n/l10n_util_mac.h" 17 #include "ui/base/l10n/l10n_util_mac.h"
18 18
19 namespace { 19 namespace {
20 20
21 // Gets an item from the main menu given the tag of the top level item 21 // Gets an item from the main menu given the tag of the top level item
22 // |menu_tag| and the tag of the item |item_tag|. 22 // |menu_tag| and the tag of the item |item_tag|.
23 NSMenuItem* GetItemByTag(NSInteger menu_tag, NSInteger item_tag) { 23 NSMenuItem* GetItemByTag(NSInteger menu_tag, NSInteger item_tag) {
24 return [[[[NSApp mainMenu] itemWithTag:menu_tag] submenu] 24 return [[[[NSApp mainMenu] itemWithTag:menu_tag] submenu]
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 addObserver:self 273 addObserver:self
274 selector:@selector(windowMainStatusChanged:) 274 selector:@selector(windowMainStatusChanged:)
275 name:NSWindowWillCloseNotification 275 name:NSWindowWillCloseNotification
276 object:nil]; 276 object:nil];
277 } 277 }
278 278
279 - (void)windowMainStatusChanged:(NSNotification*)notification { 279 - (void)windowMainStatusChanged:(NSNotification*)notification {
280 id window = [notification object]; 280 id window = [notification object];
281 NSString* name = [notification name]; 281 NSString* name = [notification name];
282 if ([name isEqualToString:NSWindowDidBecomeMainNotification]) { 282 if ([name isEqualToString:NSWindowDidBecomeMainNotification]) {
283 apps::AppWindow* appWindow = 283 extensions::AppWindow* appWindow =
284 apps::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile(window); 284 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile(
285 window);
285 286
286 const extensions::Extension* extension = NULL; 287 const extensions::Extension* extension = NULL;
287 if (appWindow) 288 if (appWindow)
288 extension = appWindow->GetExtension(); 289 extension = appWindow->GetExtension();
289 290
290 if (extension) 291 if (extension)
291 [self addMenuItems:extension]; 292 [self addMenuItems:extension];
292 else 293 else
293 [self removeMenuItems]; 294 [self removeMenuItems];
294 } else if ([name isEqualToString:NSWindowWillCloseNotification]) { 295 } else if ([name isEqualToString:NSWindowWillCloseNotification]) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 [item setHidden:NO]; 354 [item setHidden:NO];
354 355
355 [aboutDoppelganger_ disable]; 356 [aboutDoppelganger_ disable];
356 [hideDoppelganger_ disable]; 357 [hideDoppelganger_ disable];
357 [quitDoppelganger_ disable]; 358 [quitDoppelganger_ disable];
358 [newDoppelganger_ disable]; 359 [newDoppelganger_ disable];
359 [openDoppelganger_ disable]; 360 [openDoppelganger_ disable];
360 } 361 }
361 362
362 - (void)quitCurrentPlatformApp { 363 - (void)quitCurrentPlatformApp {
363 apps::AppWindow* appWindow = 364 extensions::AppWindow* appWindow =
364 apps::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( 365 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile(
365 [NSApp keyWindow]); 366 [NSApp keyWindow]);
366 if (appWindow) 367 if (appWindow)
367 apps::ExtensionAppShimHandler::QuitAppForWindow(appWindow); 368 apps::ExtensionAppShimHandler::QuitAppForWindow(appWindow);
368 } 369 }
369 370
370 - (void)hideCurrentPlatformApp { 371 - (void)hideCurrentPlatformApp {
371 apps::AppWindow* appWindow = 372 extensions::AppWindow* appWindow =
372 apps::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( 373 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile(
373 [NSApp keyWindow]); 374 [NSApp keyWindow]);
374 if (appWindow) 375 if (appWindow)
375 apps::ExtensionAppShimHandler::HideAppForWindow(appWindow); 376 apps::ExtensionAppShimHandler::HideAppForWindow(appWindow);
376 } 377 }
377 378
378 - (void)focusCurrentPlatformApp { 379 - (void)focusCurrentPlatformApp {
379 apps::AppWindow* appWindow = 380 extensions::AppWindow* appWindow =
380 apps::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( 381 extensions::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile(
381 [NSApp keyWindow]); 382 [NSApp keyWindow]);
382 if (appWindow) 383 if (appWindow)
383 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow); 384 apps::ExtensionAppShimHandler::FocusAppForWindow(appWindow);
384 } 385 }
385 386
386 @end 387 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698