| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/logging.h" // for NOTREACHED() | 7 #include "base/logging.h" // for NOTREACHED() |
| 8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // Sets |exitLabel_| based on |exitLabelPlaceholder_|, | 46 // Sets |exitLabel_| based on |exitLabelPlaceholder_|, |
| 47 // sets |exitLabelPlaceholder_| to nil, | 47 // sets |exitLabelPlaceholder_| to nil, |
| 48 // sets |denyButton_| text based on |bubbleType_|. | 48 // sets |denyButton_| text based on |bubbleType_|. |
| 49 - (void)initializeLabelAndButton; | 49 - (void)initializeLabelAndButton; |
| 50 | 50 |
| 51 - (NSString*)getLabelText; | 51 - (NSString*)getLabelText; |
| 52 | 52 |
| 53 - (void)hideSoon; | 53 - (void)hideSoon; |
| 54 | 54 |
| 55 // Returns the Accelerator for the Toggle Fullscreen menu item. | 55 // Returns the Accelerator for the Toggle Fullscreen menu item. |
| 56 + (scoped_ptr<ui::PlatformAcceleratorCocoa>)acceleratorForToggleFullscreen; | 56 + (std::unique_ptr<ui::PlatformAcceleratorCocoa>)acceleratorForToggleFullscreen; |
| 57 | 57 |
| 58 // Returns a string representation fit for display of | 58 // Returns a string representation fit for display of |
| 59 // +acceleratorForToggleFullscreen. | 59 // +acceleratorForToggleFullscreen. |
| 60 + (NSString*)keyCommandString; | 60 + (NSString*)keyCommandString; |
| 61 | 61 |
| 62 + (NSString*)keyCombinationForAccelerator: | 62 + (NSString*)keyCombinationForAccelerator: |
| 63 (const ui::PlatformAcceleratorCocoa&)item; | 63 (const ui::PlatformAcceleratorCocoa&)item; |
| 64 @end | 64 @end |
| 65 | 65 |
| 66 @implementation ExclusiveAccessBubbleWindowController | 66 @implementation ExclusiveAccessBubbleWindowController |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 return @""; | 285 return @""; |
| 286 extensions::ExtensionRegistry* registry = | 286 extensions::ExtensionRegistry* registry = |
| 287 extensions::ExtensionRegistry::Get(profile_); | 287 extensions::ExtensionRegistry::Get(profile_); |
| 288 return SysUTF16ToNSString(exclusive_access_bubble::GetLabelTextForType( | 288 return SysUTF16ToNSString(exclusive_access_bubble::GetLabelTextForType( |
| 289 bubbleType_, url_, registry)); | 289 bubbleType_, url_, registry)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 // This looks at the Main Menu and determines what the user has set as the | 292 // This looks at the Main Menu and determines what the user has set as the |
| 293 // key combination for quit. It then gets the modifiers and builds an object | 293 // key combination for quit. It then gets the modifiers and builds an object |
| 294 // to hold the data. | 294 // to hold the data. |
| 295 + (scoped_ptr<ui::PlatformAcceleratorCocoa>)acceleratorForToggleFullscreen { | 295 + (std::unique_ptr<ui::PlatformAcceleratorCocoa>) |
| 296 acceleratorForToggleFullscreen { |
| 296 NSMenu* mainMenu = [NSApp mainMenu]; | 297 NSMenu* mainMenu = [NSApp mainMenu]; |
| 297 // Get the application menu (i.e. Chromium). | 298 // Get the application menu (i.e. Chromium). |
| 298 for (NSMenuItem* menu in [mainMenu itemArray]) { | 299 for (NSMenuItem* menu in [mainMenu itemArray]) { |
| 299 for (NSMenuItem* item in [[menu submenu] itemArray]) { | 300 for (NSMenuItem* item in [[menu submenu] itemArray]) { |
| 300 // Find the toggle presentation mode item. | 301 // Find the toggle presentation mode item. |
| 301 if ([item tag] == IDC_PRESENTATION_MODE) { | 302 if ([item tag] == IDC_PRESENTATION_MODE) { |
| 302 return scoped_ptr<ui::PlatformAcceleratorCocoa>( | 303 return std::unique_ptr<ui::PlatformAcceleratorCocoa>( |
| 303 new ui::PlatformAcceleratorCocoa([item keyEquivalent], | 304 new ui::PlatformAcceleratorCocoa([item keyEquivalent], |
| 304 [item keyEquivalentModifierMask])); | 305 [item keyEquivalentModifierMask])); |
| 305 } | 306 } |
| 306 } | 307 } |
| 307 } | 308 } |
| 308 // Default to Cmd+Shift+F. | 309 // Default to Cmd+Shift+F. |
| 309 return scoped_ptr<ui::PlatformAcceleratorCocoa>( | 310 return std::unique_ptr<ui::PlatformAcceleratorCocoa>( |
| 310 new ui::PlatformAcceleratorCocoa(@"f", | 311 new ui::PlatformAcceleratorCocoa(@"f", |
| 311 NSCommandKeyMask | NSShiftKeyMask)); | 312 NSCommandKeyMask | NSShiftKeyMask)); |
| 312 } | 313 } |
| 313 | 314 |
| 314 // This looks at the Main Menu and determines what the user has set as the | 315 // This looks at the Main Menu and determines what the user has set as the |
| 315 // key combination for quit. It then gets the modifiers and builds a string | 316 // key combination for quit. It then gets the modifiers and builds a string |
| 316 // to display them. | 317 // to display them. |
| 317 + (NSString*)keyCommandString { | 318 + (NSString*)keyCommandString { |
| 318 scoped_ptr<ui::PlatformAcceleratorCocoa> accelerator( | 319 std::unique_ptr<ui::PlatformAcceleratorCocoa> accelerator( |
| 319 [[self class] acceleratorForToggleFullscreen]); | 320 [[self class] acceleratorForToggleFullscreen]); |
| 320 return [[self class] keyCombinationForAccelerator:*accelerator]; | 321 return [[self class] keyCombinationForAccelerator:*accelerator]; |
| 321 } | 322 } |
| 322 | 323 |
| 323 + (NSString*)keyCombinationForAccelerator: | 324 + (NSString*)keyCombinationForAccelerator: |
| 324 (const ui::PlatformAcceleratorCocoa&)item { | 325 (const ui::PlatformAcceleratorCocoa&)item { |
| 325 NSMutableString* string = [NSMutableString string]; | 326 NSMutableString* string = [NSMutableString string]; |
| 326 NSUInteger modifiers = item.modifier_mask(); | 327 NSUInteger modifiers = item.modifier_mask(); |
| 327 | 328 |
| 328 if (modifiers & NSCommandKeyMask) | 329 if (modifiers & NSCommandKeyMask) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 343 - (void)hideSoon { | 344 - (void)hideSoon { |
| 344 hideTimer_.reset( | 345 hideTimer_.reset( |
| 345 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay | 346 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay |
| 346 target:self | 347 target:self |
| 347 selector:@selector(hideTimerFired:) | 348 selector:@selector(hideTimerFired:) |
| 348 userInfo:nil | 349 userInfo:nil |
| 349 repeats:NO] retain]); | 350 repeats:NO] retain]); |
| 350 } | 351 } |
| 351 | 352 |
| 352 @end | 353 @end |
| OLD | NEW |