OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/location_bar/autocomplete_text_field_editor.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | |
7 #include "base/string_util.h" | 8 #include "base/string_util.h" |
8 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" // IDC_* | 10 #include "chrome/app/chrome_command_ids.h" // IDC_* |
10 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
13 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 14 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
14 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 #include "ui/base/l10n/l10n_util_mac.h" | 17 #include "ui/base/l10n/l10n_util_mac.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 | 392 |
392 if (observer && observer->OnDoCommandBySelector(cmd)) { | 393 if (observer && observer->OnDoCommandBySelector(cmd)) { |
393 // The observer should already be aware of any changes to the text, so | 394 // The observer should already be aware of any changes to the text, so |
394 // setting |textChangedByKeyEvents_| to NO to prevent its OnDidChange() | 395 // setting |textChangedByKeyEvents_| to NO to prevent its OnDidChange() |
395 // method from being called unnecessarily. | 396 // method from being called unnecessarily. |
396 textChangedByKeyEvents_ = NO; | 397 textChangedByKeyEvents_ = NO; |
397 return; | 398 return; |
398 } | 399 } |
399 | 400 |
400 // If the escape key was pressed and no revert happened and we're in | 401 // If the escape key was pressed and no revert happened and we're in |
401 // fullscreen mode, make it resign key. | 402 // presentaion mode, make the window resign key. If we're in Lion full-screen |
403 // mode, Esc should toggle out of fullscreen. | |
Mark Mentovai
2011/08/09 16:41:15
So the idea is that in presentation mode, we take
rohitrao (ping after 24h)
2011/08/09 16:46:23
That's the other part of the equation, and once th
Mark Mentovai
2011/08/09 16:48:52
Seems like if we’re going to make enough Esc keypr
| |
402 if (cmd == @selector(cancelOperation:)) { | 404 if (cmd == @selector(cancelOperation:)) { |
403 BrowserWindowController* windowController = | 405 BrowserWindowController* windowController = |
404 [BrowserWindowController browserWindowControllerForView:self]; | 406 [BrowserWindowController browserWindowControllerForView:self]; |
405 if ([windowController inPresentationMode]) { | 407 if ([windowController inPresentationMode]) { |
406 [windowController focusTabContents]; | 408 [windowController focusTabContents]; |
409 textChangedByKeyEvents_ = NO; | |
410 return; | |
411 } else if ([windowController isFullscreen] && | |
412 base::mac::IsOSLionOrLater()) { | |
413 [windowController setFullscreen:NO]; | |
414 textChangedByKeyEvents_ = NO; | |
407 return; | 415 return; |
408 } | 416 } |
409 } | 417 } |
410 | 418 |
411 [super doCommandBySelector:cmd]; | 419 [super doCommandBySelector:cmd]; |
412 } | 420 } |
413 | 421 |
414 - (void)setAttributedString:(NSAttributedString*)aString { | 422 - (void)setAttributedString:(NSAttributedString*)aString { |
415 NSTextStorage* textStorage = [self textStorage]; | 423 NSTextStorage* textStorage = [self textStorage]; |
416 DCHECK(textStorage); | 424 DCHECK(textStorage); |
417 [textStorage setAttributedString:aString]; | 425 [textStorage setAttributedString:aString]; |
418 | 426 |
419 // The text has been changed programmatically. The observer should know | 427 // The text has been changed programmatically. The observer should know |
420 // this change, so setting |textChangedByKeyEvents_| to NO to | 428 // this change, so setting |textChangedByKeyEvents_| to NO to |
421 // prevent its OnDidChange() method from being called unnecessarily. | 429 // prevent its OnDidChange() method from being called unnecessarily. |
422 textChangedByKeyEvents_ = NO; | 430 textChangedByKeyEvents_ = NO; |
423 } | 431 } |
424 | 432 |
425 - (void)mouseDown:(NSEvent*)theEvent { | 433 - (void)mouseDown:(NSEvent*)theEvent { |
426 // Close the popup before processing the event. | 434 // Close the popup before processing the event. |
427 AutocompleteTextFieldObserver* observer = [self observer]; | 435 AutocompleteTextFieldObserver* observer = [self observer]; |
428 if (observer) | 436 if (observer) |
429 observer->ClosePopup(); | 437 observer->ClosePopup(); |
430 | 438 |
431 [super mouseDown:theEvent]; | 439 [super mouseDown:theEvent]; |
432 } | 440 } |
433 | 441 |
434 @end | 442 @end |
OLD | NEW |