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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/autocomplete/autocomplete_input.h" | 12 #include "chrome/browser/autocomplete/autocomplete_input.h" |
13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/ui/cocoa/event_utils.h" | 15 #include "chrome/browser/ui/cocoa/event_utils.h" |
16 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 16 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
19 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 19 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
20 #include "chrome/browser/ui/search/search.h" | 20 #include "chrome/browser/ui/search/search.h" |
21 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 21 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
25 #import "third_party/mozilla/NSPasteboard+Utils.h" | 25 #import "third_party/mozilla/NSPasteboard+Utils.h" |
26 #include "ui/base/clipboard/clipboard.h" | 26 #include "ui/base/clipboard/clipboard.h" |
27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
28 #include "ui/gfx/mac/nsimage_cache.h" | |
29 #include "ui/gfx/rect.h" | 28 #include "ui/gfx/rect.h" |
30 | 29 |
31 using content::WebContents; | 30 using content::WebContents; |
32 | 31 |
33 // Focus-handling between |field_| and model() is a bit subtle. | 32 // Focus-handling between |field_| and model() is a bit subtle. |
34 // Other platforms detect change of focus, which is inconvenient | 33 // Other platforms detect change of focus, which is inconvenient |
35 // without subclassing NSTextField (even with a subclass, the use of a | 34 // without subclassing NSTextField (even with a subclass, the use of a |
36 // field editor may complicate things). | 35 // field editor may complicate things). |
37 // | 36 // |
38 // model() doesn't actually do anything when it gains focus, it just | 37 // model() doesn't actually do anything when it gains focus, it just |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 NSUInteger OmniboxViewMac::GetTextLength() const { | 1030 NSUInteger OmniboxViewMac::GetTextLength() const { |
1032 return ([field_ currentEditor] ? | 1031 return ([field_ currentEditor] ? |
1033 [[[field_ currentEditor] string] length] : | 1032 [[[field_ currentEditor] string] length] : |
1034 [[field_ stringValue] length]) - suggest_text_length_; | 1033 [[field_ stringValue] length]) - suggest_text_length_; |
1035 } | 1034 } |
1036 | 1035 |
1037 bool OmniboxViewMac::IsCaretAtEnd() const { | 1036 bool OmniboxViewMac::IsCaretAtEnd() const { |
1038 const NSRange selection = GetSelectedRange(); | 1037 const NSRange selection = GetSelectedRange(); |
1039 return selection.length == 0 && selection.location == GetTextLength(); | 1038 return selection.length == 0 && selection.location == GetTextLength(); |
1040 } | 1039 } |
OLD | NEW |