| 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 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 
| 6 | 6 | 
| 7 #include <Carbon/Carbon.h>  // kVK_Return | 7 #include <Carbon/Carbon.h>  // kVK_Return | 
| 8 | 8 | 
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" | 
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" | 
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" | 
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" | 
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" | 
| 14 #include "chrome/browser/autocomplete/autocomplete_input.h" | 14 #include "chrome/browser/autocomplete/autocomplete_input.h" | 
| 15 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" | 
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" | 
| 17 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 17 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 
| 18 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 18 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 
| 19 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 19 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 
| 20 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 20 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 
| 21 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 21 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 
| 22 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 22 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" | 
| 24 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" | 
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" | 
| 26 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" | 
| 27 #import "third_party/mozilla/NSPasteboard+Utils.h" | 27 #import "third_party/mozilla/NSPasteboard+Utils.h" | 
|  | 28 #import "ui/base/cocoa/cocoa_base_utils.h" | 
| 28 #include "ui/base/clipboard/clipboard.h" | 29 #include "ui/base/clipboard/clipboard.h" | 
| 29 #import "ui/base/cocoa/cocoa_event_utils.h" |  | 
| 30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" | 
| 31 #include "ui/gfx/font_list.h" | 31 #include "ui/gfx/font_list.h" | 
| 32 #include "ui/gfx/geometry/rect.h" | 32 #include "ui/gfx/geometry/rect.h" | 
| 33 | 33 | 
| 34 using content::WebContents; | 34 using content::WebContents; | 
| 35 | 35 | 
| 36 // Focus-handling between |field_| and model() is a bit subtle. | 36 // Focus-handling between |field_| and model() is a bit subtle. | 
| 37 // Other platforms detect change of focus, which is inconvenient | 37 // Other platforms detect change of focus, which is inconvenient | 
| 38 // without subclassing NSTextField (even with a subclass, the use of a | 38 // without subclassing NSTextField (even with a subclass, the use of a | 
| 39 // field editor may complicate things). | 39 // field editor may complicate things). | 
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 954 | 954 | 
| 955 NSUInteger OmniboxViewMac::GetTextLength() const { | 955 NSUInteger OmniboxViewMac::GetTextLength() const { | 
| 956   return [field_ currentEditor] ?  [[[field_ currentEditor] string] length] : | 956   return [field_ currentEditor] ?  [[[field_ currentEditor] string] length] : | 
| 957                                    [[field_ stringValue] length]; | 957                                    [[field_ stringValue] length]; | 
| 958 } | 958 } | 
| 959 | 959 | 
| 960 bool OmniboxViewMac::IsCaretAtEnd() const { | 960 bool OmniboxViewMac::IsCaretAtEnd() const { | 
| 961   const NSRange selection = GetSelectedRange(); | 961   const NSRange selection = GetSelectedRange(); | 
| 962   return NSMaxRange(selection) == GetTextLength(); | 962   return NSMaxRange(selection) == GetTextLength(); | 
| 963 } | 963 } | 
| OLD | NEW | 
|---|