| 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/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 18 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 18 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 19 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 19 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
| 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
| 21 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 21 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 23 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 23 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 28 #import "third_party/mozilla/NSPasteboard+Utils.h" | 28 #import "third_party/mozilla/NSPasteboard+Utils.h" |
| 29 #import "ui/base/cocoa/cocoa_base_utils.h" |
| 29 #include "ui/base/clipboard/clipboard.h" | 30 #include "ui/base/clipboard/clipboard.h" |
| 30 #import "ui/base/cocoa/cocoa_event_utils.h" | |
| 31 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/gfx/font_list.h" | 32 #include "ui/gfx/font_list.h" |
| 33 #include "ui/gfx/geometry/rect.h" | 33 #include "ui/gfx/geometry/rect.h" |
| 34 | 34 |
| 35 using content::WebContents; | 35 using content::WebContents; |
| 36 | 36 |
| 37 // Focus-handling between |field_| and model() is a bit subtle. | 37 // Focus-handling between |field_| and model() is a bit subtle. |
| 38 // Other platforms detect change of focus, which is inconvenient | 38 // Other platforms detect change of focus, which is inconvenient |
| 39 // without subclassing NSTextField (even with a subclass, the use of a | 39 // without subclassing NSTextField (even with a subclass, the use of a |
| 40 // field editor may complicate things). | 40 // field editor may complicate things). |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 | 979 |
| 980 NSUInteger OmniboxViewMac::GetTextLength() const { | 980 NSUInteger OmniboxViewMac::GetTextLength() const { |
| 981 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 981 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
| 982 [[field_ stringValue] length]; | 982 [[field_ stringValue] length]; |
| 983 } | 983 } |
| 984 | 984 |
| 985 bool OmniboxViewMac::IsCaretAtEnd() const { | 985 bool OmniboxViewMac::IsCaretAtEnd() const { |
| 986 const NSRange selection = GetSelectedRange(); | 986 const NSRange selection = GetSelectedRange(); |
| 987 return NSMaxRange(selection) == GetTextLength(); | 987 return NSMaxRange(selection) == GetTextLength(); |
| 988 } | 988 } |
| OLD | NEW |