| 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/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" // IDC_* | 9 #include "chrome/app/chrome_command_ids.h" // IDC_* |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 391 |
| 392 if (observer && observer->OnDoCommandBySelector(cmd)) { | 392 if (observer && observer->OnDoCommandBySelector(cmd)) { |
| 393 // The observer should already be aware of any changes to the text, so | 393 // The observer should already be aware of any changes to the text, so |
| 394 // setting |textChangedByKeyEvents_| to NO to prevent its OnDidChange() | 394 // setting |textChangedByKeyEvents_| to NO to prevent its OnDidChange() |
| 395 // method from being called unnecessarily. | 395 // method from being called unnecessarily. |
| 396 textChangedByKeyEvents_ = NO; | 396 textChangedByKeyEvents_ = NO; |
| 397 return; | 397 return; |
| 398 } | 398 } |
| 399 | 399 |
| 400 // If the escape key was pressed and no revert happened and we're in | 400 // If the escape key was pressed and no revert happened and we're in |
| 401 // fullscreen mode, make it resign key. | 401 // fullscreen mode, give focus to the web contents, which may dismiss the |
| 402 // overlay. |
| 402 if (cmd == @selector(cancelOperation:)) { | 403 if (cmd == @selector(cancelOperation:)) { |
| 403 BrowserWindowController* windowController = | 404 BrowserWindowController* windowController = |
| 404 [BrowserWindowController browserWindowControllerForView:self]; | 405 [BrowserWindowController browserWindowControllerForView:self]; |
| 405 if ([windowController inPresentationMode]) { | 406 if ([windowController isFullscreen]) { |
| 406 [windowController focusTabContents]; | 407 [windowController focusTabContents]; |
| 408 textChangedByKeyEvents_ = NO; |
| 407 return; | 409 return; |
| 408 } | 410 } |
| 409 } | 411 } |
| 410 | 412 |
| 411 [super doCommandBySelector:cmd]; | 413 [super doCommandBySelector:cmd]; |
| 412 } | 414 } |
| 413 | 415 |
| 414 - (void)setAttributedString:(NSAttributedString*)aString { | 416 - (void)setAttributedString:(NSAttributedString*)aString { |
| 415 NSTextStorage* textStorage = [self textStorage]; | 417 NSTextStorage* textStorage = [self textStorage]; |
| 416 DCHECK(textStorage); | 418 DCHECK(textStorage); |
| 417 [textStorage setAttributedString:aString]; | 419 [textStorage setAttributedString:aString]; |
| 418 | 420 |
| 419 // The text has been changed programmatically. The observer should know | 421 // The text has been changed programmatically. The observer should know |
| 420 // this change, so setting |textChangedByKeyEvents_| to NO to | 422 // this change, so setting |textChangedByKeyEvents_| to NO to |
| 421 // prevent its OnDidChange() method from being called unnecessarily. | 423 // prevent its OnDidChange() method from being called unnecessarily. |
| 422 textChangedByKeyEvents_ = NO; | 424 textChangedByKeyEvents_ = NO; |
| 423 } | 425 } |
| 424 | 426 |
| 425 - (void)mouseDown:(NSEvent*)theEvent { | 427 - (void)mouseDown:(NSEvent*)theEvent { |
| 426 // Close the popup before processing the event. | 428 // Close the popup before processing the event. |
| 427 AutocompleteTextFieldObserver* observer = [self observer]; | 429 AutocompleteTextFieldObserver* observer = [self observer]; |
| 428 if (observer) | 430 if (observer) |
| 429 observer->ClosePopup(); | 431 observer->ClosePopup(); |
| 430 | 432 |
| 431 [super mouseDown:theEvent]; | 433 [super mouseDown:theEvent]; |
| 432 } | 434 } |
| 433 | 435 |
| 434 @end | 436 @end |
| OLD | NEW |