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/ssl/security_level_policy.h" |
17 #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" |
18 #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" |
19 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
20 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 21 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
21 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 22 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
22 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 23 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
23 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
24 #include "components/omnibox/autocomplete_input.h" | 25 #include "components/omnibox/autocomplete_input.h" |
25 #include "components/omnibox/autocomplete_match.h" | 26 #include "components/omnibox/autocomplete_match.h" |
26 #include "components/omnibox/omnibox_field_trial.h" | 27 #include "components/omnibox/omnibox_field_trial.h" |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 506 |
506 if (!grey_out_url) { | 507 if (!grey_out_url) { |
507 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() | 508 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() |
508 range:ComponentToNSRange(host)]; | 509 range:ComponentToNSRange(host)]; |
509 } | 510 } |
510 } | 511 } |
511 | 512 |
512 // TODO(shess): GTK has this as a member var, figure out why. | 513 // TODO(shess): GTK has this as a member var, figure out why. |
513 // [Could it be to not change if no change? If so, I'm guessing | 514 // [Could it be to not change if no change? If so, I'm guessing |
514 // AppKit may already handle that.] | 515 // AppKit may already handle that.] |
515 const ToolbarModel::SecurityLevel security_level = | 516 const SecurityLevelPolicy::SecurityLevel security_level = |
516 controller()->GetToolbarModel()->GetSecurityLevel(false); | 517 controller()->GetToolbarModel()->GetSecurityLevel(false); |
517 | 518 |
518 // Emphasize the scheme for security UI display purposes (if necessary). | 519 // Emphasize the scheme for security UI display purposes (if necessary). |
519 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 520 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
520 scheme.is_nonempty() && (security_level != ToolbarModel::NONE)) { | 521 scheme.is_nonempty() && (security_level != SecurityLevelPolicy::NONE)) { |
521 NSColor* color; | 522 NSColor* color; |
522 if (security_level == ToolbarModel::EV_SECURE || | 523 if (security_level == SecurityLevelPolicy::EV_SECURE || |
523 security_level == ToolbarModel::SECURE) { | 524 security_level == SecurityLevelPolicy::SECURE) { |
524 color = SecureSchemeColor(); | 525 color = SecureSchemeColor(); |
525 } else if (security_level == ToolbarModel::SECURITY_ERROR) { | 526 } else if (security_level == SecurityLevelPolicy::SECURITY_ERROR) { |
526 color = SecurityErrorSchemeColor(); | 527 color = SecurityErrorSchemeColor(); |
527 // Add a strikethrough through the scheme. | 528 // Add a strikethrough through the scheme. |
528 [as addAttribute:NSStrikethroughStyleAttributeName | 529 [as addAttribute:NSStrikethroughStyleAttributeName |
529 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] | 530 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] |
530 range:ComponentToNSRange(scheme)]; | 531 range:ComponentToNSRange(scheme)]; |
531 } else if (security_level == ToolbarModel::SECURITY_WARNING) { | 532 } else if (security_level == SecurityLevelPolicy::SECURITY_WARNING) { |
532 color = BaseTextColor(); | 533 color = BaseTextColor(); |
533 } else { | 534 } else { |
534 NOTREACHED(); | 535 NOTREACHED(); |
535 color = BaseTextColor(); | 536 color = BaseTextColor(); |
536 } | 537 } |
537 [as addAttribute:NSForegroundColorAttributeName value:color | 538 [as addAttribute:NSForegroundColorAttributeName value:color |
538 range:ComponentToNSRange(scheme)]; | 539 range:ComponentToNSRange(scheme)]; |
539 } | 540 } |
540 } | 541 } |
541 | 542 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 | 1009 |
1009 NSUInteger OmniboxViewMac::GetTextLength() const { | 1010 NSUInteger OmniboxViewMac::GetTextLength() const { |
1010 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 1011 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
1011 [[field_ stringValue] length]; | 1012 [[field_ stringValue] length]; |
1012 } | 1013 } |
1013 | 1014 |
1014 bool OmniboxViewMac::IsCaretAtEnd() const { | 1015 bool OmniboxViewMac::IsCaretAtEnd() const { |
1015 const NSRange selection = GetSelectedRange(); | 1016 const NSRange selection = GetSelectedRange(); |
1016 return NSMaxRange(selection) == GetTextLength(); | 1017 return NSMaxRange(selection) == GetTextLength(); |
1017 } | 1018 } |
OLD | NEW |