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

Side by Side Diff: chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.mm

Issue 1886463003: Remove the Presentation Mode Command ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some 10.6 logic Created 4 years, 8 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 (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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 @interface ExclusiveAccessBubbleWindowController (PrivateMethods) 45 @interface ExclusiveAccessBubbleWindowController (PrivateMethods)
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.
56 + (std::unique_ptr<ui::PlatformAcceleratorCocoa>)acceleratorForToggleFullscreen;
57
58 // Returns a string representation fit for display of
59 // +acceleratorForToggleFullscreen.
60 + (NSString*)keyCommandString;
61
62 + (NSString*)keyCombinationForAccelerator: 55 + (NSString*)keyCombinationForAccelerator:
63 (const ui::PlatformAcceleratorCocoa&)item; 56 (const ui::PlatformAcceleratorCocoa&)item;
64 @end 57 @end
65 58
66 @implementation ExclusiveAccessBubbleWindowController 59 @implementation ExclusiveAccessBubbleWindowController
67 60
68 - (id)initWithOwner:(NSWindowController*)owner 61 - (id)initWithOwner:(NSWindowController*)owner
69 exclusive_access_manager:(ExclusiveAccessManager*)exclusive_access_manager 62 exclusive_access_manager:(ExclusiveAccessManager*)exclusive_access_manager
70 profile:(Profile*)profile 63 profile:(Profile*)profile
71 url:(const GURL&)url 64 url:(const GURL&)url
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 275
283 - (NSString*)getLabelText { 276 - (NSString*)getLabelText {
284 if (bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) 277 if (bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE)
285 return @""; 278 return @"";
286 extensions::ExtensionRegistry* registry = 279 extensions::ExtensionRegistry* registry =
287 extensions::ExtensionRegistry::Get(profile_); 280 extensions::ExtensionRegistry::Get(profile_);
288 return SysUTF16ToNSString(exclusive_access_bubble::GetLabelTextForType( 281 return SysUTF16ToNSString(exclusive_access_bubble::GetLabelTextForType(
289 bubbleType_, url_, registry)); 282 bubbleType_, url_, registry));
290 } 283 }
291 284
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
294 // to hold the data.
295 + (std::unique_ptr<ui::PlatformAcceleratorCocoa>)
296 acceleratorForToggleFullscreen {
297 NSMenu* mainMenu = [NSApp mainMenu];
298 // Get the application menu (i.e. Chromium).
299 for (NSMenuItem* menu in [mainMenu itemArray]) {
300 for (NSMenuItem* item in [[menu submenu] itemArray]) {
301 // Find the toggle presentation mode item.
302 if ([item tag] == IDC_PRESENTATION_MODE) {
303 return std::unique_ptr<ui::PlatformAcceleratorCocoa>(
304 new ui::PlatformAcceleratorCocoa([item keyEquivalent],
305 [item keyEquivalentModifierMask]));
306 }
307 }
308 }
309 // Default to Cmd+Shift+F.
310 return std::unique_ptr<ui::PlatformAcceleratorCocoa>(
311 new ui::PlatformAcceleratorCocoa(@"f",
312 NSCommandKeyMask | NSShiftKeyMask));
313 }
314
315 // This looks at the Main Menu and determines what the user has set as the
316 // key combination for quit. It then gets the modifiers and builds a string
317 // to display them.
318 + (NSString*)keyCommandString {
319 std::unique_ptr<ui::PlatformAcceleratorCocoa> accelerator(
320 [[self class] acceleratorForToggleFullscreen]);
321 return [[self class] keyCombinationForAccelerator:*accelerator];
322 }
323
324 + (NSString*)keyCombinationForAccelerator: 285 + (NSString*)keyCombinationForAccelerator:
325 (const ui::PlatformAcceleratorCocoa&)item { 286 (const ui::PlatformAcceleratorCocoa&)item {
326 NSMutableString* string = [NSMutableString string]; 287 NSMutableString* string = [NSMutableString string];
327 NSUInteger modifiers = item.modifier_mask(); 288 NSUInteger modifiers = item.modifier_mask();
328 289
329 if (modifiers & NSCommandKeyMask) 290 if (modifiers & NSCommandKeyMask)
330 [string appendString:@"\u2318"]; 291 [string appendString:@"\u2318"];
331 if (modifiers & NSControlKeyMask) 292 if (modifiers & NSControlKeyMask)
332 [string appendString:@"\u2303"]; 293 [string appendString:@"\u2303"];
333 if (modifiers & NSAlternateKeyMask) 294 if (modifiers & NSAlternateKeyMask)
(...skipping 10 matching lines...) Expand all
344 - (void)hideSoon { 305 - (void)hideSoon {
345 hideTimer_.reset( 306 hideTimer_.reset(
346 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay 307 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay
347 target:self 308 target:self
348 selector:@selector(hideTimerFired:) 309 selector:@selector(hideTimerFired:)
349 userInfo:nil 310 userInfo:nil
350 repeats:NO] retain]); 311 repeats:NO] retain]);
351 } 312 }
352 313
353 @end 314 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698