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

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

Issue 1123943002: Move SecurityLevel into a class of its own (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: register in chrome_jni_registrar Created 5 years, 7 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 505
506 if (!grey_out_url) { 506 if (!grey_out_url) {
507 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() 507 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor()
508 range:ComponentToNSRange(host)]; 508 range:ComponentToNSRange(host)];
509 } 509 }
510 } 510 }
511 511
512 // TODO(shess): GTK has this as a member var, figure out why. 512 // 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 513 // [Could it be to not change if no change? If so, I'm guessing
514 // AppKit may already handle that.] 514 // AppKit may already handle that.]
515 const ToolbarModel::SecurityLevel security_level = 515 const ConnectionSecurityHelper::SecurityLevel security_level =
516 controller()->GetToolbarModel()->GetSecurityLevel(false); 516 controller()->GetToolbarModel()->GetSecurityLevel(false);
517 517
518 // Emphasize the scheme for security UI display purposes (if necessary). 518 // Emphasize the scheme for security UI display purposes (if necessary).
519 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 519 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
520 scheme.is_nonempty() && (security_level != ToolbarModel::NONE)) { 520 scheme.is_nonempty() &&
521 (security_level != ConnectionSecurityHelper::NONE)) {
521 NSColor* color; 522 NSColor* color;
522 if (security_level == ToolbarModel::EV_SECURE || 523 if (security_level == ConnectionSecurityHelper::EV_SECURE ||
523 security_level == ToolbarModel::SECURE) { 524 security_level == ConnectionSecurityHelper::SECURE) {
524 color = SecureSchemeColor(); 525 color = SecureSchemeColor();
525 } else if (security_level == ToolbarModel::SECURITY_ERROR) { 526 } else if (security_level == ConnectionSecurityHelper::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 == ConnectionSecurityHelper::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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm ('k') | chrome/browser/ui/toolbar/test_toolbar_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698