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/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 scoped_nsobject<NSMutableParagraphStyle> | 443 scoped_nsobject<NSMutableParagraphStyle> |
444 paragraph_style([[NSMutableParagraphStyle alloc] init]); | 444 paragraph_style([[NSMutableParagraphStyle alloc] init]); |
445 [paragraph_style setMaximumLineHeight:line_height_]; | 445 [paragraph_style setMaximumLineHeight:line_height_]; |
446 [paragraph_style setMinimumLineHeight:line_height_]; | 446 [paragraph_style setMinimumLineHeight:line_height_]; |
447 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style | 447 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style |
448 range:as_entire_string]; | 448 range:as_entire_string]; |
449 | 449 |
450 url_parse::Component scheme, host; | 450 url_parse::Component scheme, host; |
451 AutocompleteInput::ParseForEmphasizeComponents( | 451 AutocompleteInput::ParseForEmphasizeComponents( |
452 display_text, &scheme, &host); | 452 display_text, &scheme, &host); |
453 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); | 453 if (model()->currentTextIsURL() && |
454 if (emphasize) { | 454 (host.is_nonempty() || toolbar_model()->ShouldGreyOutURL())) { |
455 [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor() | 455 [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor() |
456 range:as_entire_string]; | 456 range:as_entire_string]; |
457 | 457 |
458 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() | 458 if (host.is_nonempty() && !toolbar_model()->ShouldGreyOutURL()) { |
Peter Kasting
2013/04/04 21:07:05
Nit: No need to add the first clause, it will alwa
Patrick Riordan
2013/04/10 02:00:24
Done.
| |
459 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() | |
459 range:ComponentToNSRange(host)]; | 460 range:ComponentToNSRange(host)]; |
461 } | |
460 } | 462 } |
461 | 463 |
462 // TODO(shess): GTK has this as a member var, figure out why. | 464 // TODO(shess): GTK has this as a member var, figure out why. |
463 // [Could it be to not change if no change? If so, I'm guessing | 465 // [Could it be to not change if no change? If so, I'm guessing |
464 // AppKit may already handle that.] | 466 // AppKit may already handle that.] |
465 const ToolbarModel::SecurityLevel security_level = | 467 const ToolbarModel::SecurityLevel security_level = |
466 toolbar_model()->GetSecurityLevel(); | 468 toolbar_model()->GetSecurityLevel(); |
467 | 469 |
468 // Emphasize the scheme for security UI display purposes (if necessary). | 470 // Emphasize the scheme for security UI display purposes (if necessary). |
469 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && | 471 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 | 989 |
988 NSUInteger OmniboxViewMac::GetTextLength() const { | 990 NSUInteger OmniboxViewMac::GetTextLength() const { |
989 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : | 991 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : |
990 [[field_ stringValue] length]; | 992 [[field_ stringValue] length]; |
991 } | 993 } |
992 | 994 |
993 bool OmniboxViewMac::IsCaretAtEnd() const { | 995 bool OmniboxViewMac::IsCaretAtEnd() const { |
994 const NSRange selection = GetSelectedRange(); | 996 const NSRange selection = GetSelectedRange(); |
995 return NSMaxRange(selection) == GetTextLength(); | 997 return NSMaxRange(selection) == GetTextLength(); |
996 } | 998 } |
OLD | NEW |