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/chrome_autocomplete_scheme_classifier.h" | 14 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/search/search.h" | 16 #include "chrome/browser/search/search.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/chrome_omnibox_client.h" | 20 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" |
21 #include "chrome/browser/ui/omnibox/clipboard_utils.h" | 21 #include "chrome/browser/ui/omnibox/clipboard_utils.h" |
22 #include "chrome/browser/ui/toolbar/chrome_toolbar_model.h" | |
23 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
24 #include "components/omnibox/browser/autocomplete_input.h" | 23 #include "components/omnibox/browser/autocomplete_input.h" |
25 #include "components/omnibox/browser/autocomplete_match.h" | 24 #include "components/omnibox/browser/autocomplete_match.h" |
26 #include "components/omnibox/browser/omnibox_edit_controller.h" | 25 #include "components/omnibox/browser/omnibox_edit_controller.h" |
27 #include "components/omnibox/browser/omnibox_field_trial.h" | 26 #include "components/omnibox/browser/omnibox_field_trial.h" |
28 #include "components/omnibox/browser/omnibox_popup_model.h" | 27 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 28 #include "components/security_state/security_state_model.h" |
| 29 #include "components/toolbar/toolbar_model.h" |
29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
30 #include "extensions/common/constants.h" | 31 #include "extensions/common/constants.h" |
31 #import "third_party/mozilla/NSPasteboard+Utils.h" | 32 #import "third_party/mozilla/NSPasteboard+Utils.h" |
32 #include "ui/base/clipboard/clipboard.h" | 33 #include "ui/base/clipboard/clipboard.h" |
33 #import "ui/base/cocoa/cocoa_base_utils.h" | 34 #import "ui/base/cocoa/cocoa_base_utils.h" |
34 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
35 #include "ui/gfx/font.h" | 36 #include "ui/gfx/font.h" |
36 #include "ui/gfx/font_list.h" | 37 #include "ui/gfx/font_list.h" |
37 #include "ui/gfx/geometry/rect.h" | 38 #include "ui/gfx/geometry/rect.h" |
38 | 39 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 value:BaseTextColor() | 533 value:BaseTextColor() |
533 range:as_entire_string]; | 534 range:as_entire_string]; |
534 | 535 |
535 if (!grey_out_url) { | 536 if (!grey_out_url) { |
536 [attributedString addAttribute:NSForegroundColorAttributeName | 537 [attributedString addAttribute:NSForegroundColorAttributeName |
537 value:HostTextColor() | 538 value:HostTextColor() |
538 range:ComponentToNSRange(host)]; | 539 range:ComponentToNSRange(host)]; |
539 } | 540 } |
540 } | 541 } |
541 | 542 |
542 ChromeToolbarModel* chrome_toolbar_model = | |
543 static_cast<ChromeToolbarModel*>(controller()->GetToolbarModel()); | |
544 // TODO(shess): GTK has this as a member var, figure out why. | 543 // TODO(shess): GTK has this as a member var, figure out why. |
545 // [Could it be to not change if no change? If so, I'm guessing | 544 // [Could it be to not change if no change? If so, I'm guessing |
546 // AppKit may already handle that.] | 545 // AppKit may already handle that.] |
547 const security_state::SecurityStateModel::SecurityLevel security_level = | 546 const security_state::SecurityStateModel::SecurityLevel security_level = |
548 chrome_toolbar_model->GetSecurityLevel(false); | 547 controller()->GetToolbarModel()->GetSecurityLevel(false); |
549 | 548 |
550 // Emphasize the scheme for security UI display purposes (if necessary). | 549 // Emphasize the scheme for security UI display purposes (if necessary). |
551 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 550 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
552 scheme.is_nonempty() && | 551 scheme.is_nonempty() && |
553 (security_level != security_state::SecurityStateModel::NONE)) { | 552 (security_level != security_state::SecurityStateModel::NONE)) { |
554 NSColor* color; | 553 NSColor* color; |
555 if (security_level == security_state::SecurityStateModel::EV_SECURE || | 554 if (security_level == security_state::SecurityStateModel::EV_SECURE || |
556 security_level == security_state::SecurityStateModel::SECURE) { | 555 security_level == security_state::SecurityStateModel::SECURE) { |
557 color = SecureSchemeColor(); | 556 color = SecureSchemeColor(); |
558 } else if (security_level == | 557 } else if (security_level == |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 | 1074 |
1076 NSUInteger OmniboxViewMac::GetTextLength() const { | 1075 NSUInteger OmniboxViewMac::GetTextLength() const { |
1077 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1076 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
1078 [[field_ stringValue] length]; | 1077 [[field_ stringValue] length]; |
1079 } | 1078 } |
1080 | 1079 |
1081 bool OmniboxViewMac::IsCaretAtEnd() const { | 1080 bool OmniboxViewMac::IsCaretAtEnd() const { |
1082 const NSRange selection = GetSelectedRange(); | 1081 const NSRange selection = GetSelectedRange(); |
1083 return NSMaxRange(selection) == GetTextLength(); | 1082 return NSMaxRange(selection) == GetTextLength(); |
1084 } | 1083 } |
OLD | NEW |