Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 1314843007: Refactor connection_security into SecurityStateModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: palmer comments #2 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 value:HostTextColor() 536 value:HostTextColor()
537 range:ComponentToNSRange(host)]; 537 range:ComponentToNSRange(host)];
538 } 538 }
539 } 539 }
540 540
541 ChromeToolbarModel* chrome_toolbar_model = 541 ChromeToolbarModel* chrome_toolbar_model =
542 static_cast<ChromeToolbarModel*>(controller()->GetToolbarModel()); 542 static_cast<ChromeToolbarModel*>(controller()->GetToolbarModel());
543 // 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.
544 // [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
545 // AppKit may already handle that.] 545 // AppKit may already handle that.]
546 const connection_security::SecurityLevel security_level = 546 const SecurityStateModel::SecurityLevel security_level =
547 chrome_toolbar_model->GetSecurityLevel(false); 547 chrome_toolbar_model->GetSecurityLevel(false);
548 548
549 // Emphasize the scheme for security UI display purposes (if necessary). 549 // Emphasize the scheme for security UI display purposes (if necessary).
550 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 550 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
551 scheme.is_nonempty() && (security_level != connection_security::NONE)) { 551 scheme.is_nonempty() && (security_level != SecurityStateModel::NONE)) {
552 NSColor* color; 552 NSColor* color;
553 if (security_level == connection_security::EV_SECURE || 553 if (security_level == SecurityStateModel::EV_SECURE ||
554 security_level == connection_security::SECURE) { 554 security_level == SecurityStateModel::SECURE) {
555 color = SecureSchemeColor(); 555 color = SecureSchemeColor();
556 } else if (security_level == connection_security::SECURITY_ERROR) { 556 } else if (security_level == SecurityStateModel::SECURITY_ERROR) {
557 color = SecurityErrorSchemeColor(); 557 color = SecurityErrorSchemeColor();
558 // Add a strikethrough through the scheme. 558 // Add a strikethrough through the scheme.
559 [attributedString addAttribute:NSStrikethroughStyleAttributeName 559 [attributedString addAttribute:NSStrikethroughStyleAttributeName
560 value:[NSNumber numberWithInt:NSUnderlineStyleSingle] 560 value:[NSNumber numberWithInt:NSUnderlineStyleSingle]
561 range:ComponentToNSRange(scheme)]; 561 range:ComponentToNSRange(scheme)];
562 } else if (security_level == connection_security::SECURITY_WARNING) { 562 } else if (security_level == SecurityStateModel::SECURITY_WARNING) {
563 color = BaseTextColor(); 563 color = BaseTextColor();
564 } else { 564 } else {
565 NOTREACHED(); 565 NOTREACHED();
566 color = BaseTextColor(); 566 color = BaseTextColor();
567 } 567 }
568 [attributedString addAttribute:NSForegroundColorAttributeName 568 [attributedString addAttribute:NSForegroundColorAttributeName
569 value:color 569 value:color
570 range:ComponentToNSRange(scheme)]; 570 range:ComponentToNSRange(scheme)];
571 } 571 }
572 } 572 }
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 1071
1072 NSUInteger OmniboxViewMac::GetTextLength() const { 1072 NSUInteger OmniboxViewMac::GetTextLength() const {
1073 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 1073 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
1074 [[field_ stringValue] length]; 1074 [[field_ stringValue] length];
1075 } 1075 }
1076 1076
1077 bool OmniboxViewMac::IsCaretAtEnd() const { 1077 bool OmniboxViewMac::IsCaretAtEnd() const {
1078 const NSRange selection = GetSelectedRange(); 1078 const NSRange selection = GetSelectedRange();
1079 return NSMaxRange(selection) == GetTextLength(); 1079 return NSMaxRange(selection) == GetTextLength();
1080 } 1080 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698