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

Side by Side Diff: chrome/browser/cocoa/location_bar_view_mac.mm

Issue 1566004: [Mac] Rearrange SSL status icon/label in omnibox. (Closed)
Patch Set: Rohit's points. Created 10 years, 8 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
« no previous file with comments | « chrome/browser/cocoa/location_bar_view_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/location_bar_view_mac.h" 5 #import "chrome/browser/cocoa/location_bar_view_mac.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/nsimage_cache_mac.h" 10 #include "base/nsimage_cache_mac.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 CommandUpdater* command_updater, 97 CommandUpdater* command_updater,
98 ToolbarModel* toolbar_model, 98 ToolbarModel* toolbar_model,
99 Profile* profile, 99 Profile* profile,
100 Browser* browser) 100 Browser* browser)
101 : edit_view_(new AutocompleteEditViewMac(this, bubble_positioner, 101 : edit_view_(new AutocompleteEditViewMac(this, bubble_positioner,
102 toolbar_model, profile, command_updater, field)), 102 toolbar_model, profile, command_updater, field)),
103 command_updater_(command_updater), 103 command_updater_(command_updater),
104 field_(field), 104 field_(field),
105 disposition_(CURRENT_TAB), 105 disposition_(CURRENT_TAB),
106 location_icon_view_(this), 106 location_icon_view_(this),
107 security_label_view_(),
107 page_action_views_(this, profile, toolbar_model), 108 page_action_views_(this, profile, toolbar_model),
108 profile_(profile), 109 profile_(profile),
109 browser_(browser), 110 browser_(browser),
110 toolbar_model_(toolbar_model), 111 toolbar_model_(toolbar_model),
111 transition_(PageTransition::TYPED) { 112 transition_(PageTransition::TYPED) {
112 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 113 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
113 ContentSettingImageView* content_setting_view = 114 ContentSettingImageView* content_setting_view =
114 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, 115 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this,
115 profile_); 116 profile_);
116 content_setting_views_.push_back(content_setting_view); 117 content_setting_views_.push_back(content_setting_view);
117 content_setting_view->SetVisible(false); 118 content_setting_view->SetVisible(false);
118 } 119 }
119 120
120 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; 121 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
121 [cell setLocationIconView:&location_icon_view_]; 122 [cell setLocationIconView:&location_icon_view_];
123 [cell setSecurityLabelView:&security_label_view_];
122 [cell setPageActionViewList:&page_action_views_]; 124 [cell setPageActionViewList:&page_action_views_];
123 [cell setContentSettingViewsList:&content_setting_views_]; 125 [cell setContentSettingViewsList:&content_setting_views_];
124 126
125 registrar_.Add(this, 127 registrar_.Add(this,
126 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 128 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
127 NotificationService::AllSources()); 129 NotificationService::AllSources());
128 } 130 }
129 131
130 LocationBarViewMac::~LocationBarViewMac() { 132 LocationBarViewMac::~LocationBarViewMac() {
131 // Disconnect from cell in case it outlives us. 133 // Disconnect from cell in case it outlives us.
132 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; 134 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
133 [cell setPageActionViewList:NULL]; 135 [cell setPageActionViewList:NULL];
134 [cell setLocationIconView:NULL]; 136 [cell setLocationIconView:NULL];
137 [cell setSecurityLabelView:NULL];
135 } 138 }
136 139
137 std::wstring LocationBarViewMac::GetInputString() const { 140 std::wstring LocationBarViewMac::GetInputString() const {
138 return location_input_; 141 return location_input_;
139 } 142 }
140 143
141 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const { 144 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const {
142 return disposition_; 145 return disposition_;
143 } 146 }
144 147
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } else { 470 } else {
468 location_icon_view_.SetImage( 471 location_icon_view_.SetImage(
469 ResourceBundle::GetSharedInstance().GetNSImageNamed(resource_id)); 472 ResourceBundle::GetSharedInstance().GetNSImageNamed(resource_id));
470 location_icon_view_.SetVisible(true); 473 location_icon_view_.SetVisible(true);
471 SetSecurityLabel(); 474 SetSecurityLabel();
472 } 475 }
473 [field_ resetFieldEditorFrameIfNeeded]; 476 [field_ resetFieldEditorFrameIfNeeded];
474 } 477 }
475 478
476 void LocationBarViewMac::SetSecurityLabel() { 479 void LocationBarViewMac::SetSecurityLabel() {
477 // TODO(shess): Separate from location icon and move icon to left of address.
478 std::wstring security_info_text(toolbar_model_->GetSecurityInfoText()); 480 std::wstring security_info_text(toolbar_model_->GetSecurityInfoText());
479 if (security_info_text.empty()) { 481 if (security_info_text.empty()) {
480 location_icon_view_.SetLabel(nil, nil, nil); 482 security_label_view_.SetLabel(nil, nil, nil);
483 security_label_view_.SetVisible(false);
481 } else { 484 } else {
482 NSString* icon_label = base::SysWideToNSString(security_info_text); 485 NSString* icon_label = base::SysWideToNSString(security_info_text);
483 NSColor* color; 486 NSColor* color;
484 if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { 487 if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) {
485 color = [NSColor colorWithCalibratedRed:kEVSecureTextColorRedComponent 488 color = [NSColor colorWithCalibratedRed:kEVSecureTextColorRedComponent
486 green:kEVSecureTextColorGreenComponent 489 green:kEVSecureTextColorGreenComponent
487 blue:kEVSecureTextColorBlueComponent 490 blue:kEVSecureTextColorBlueComponent
488 alpha:1.0]; 491 alpha:1.0];
489 } else { 492 } else {
490 color = 493 color =
491 [NSColor colorWithCalibratedRed:kSecurityErrorTextColorRedComponent 494 [NSColor colorWithCalibratedRed:kSecurityErrorTextColorRedComponent
492 green:kSecurityErrorTextColorGreenComponent 495 green:kSecurityErrorTextColorGreenComponent
493 blue:kSecurityErrorTextColorBlueComponent 496 blue:kSecurityErrorTextColorBlueComponent
494 alpha:1.0]; 497 alpha:1.0];
495 } 498 }
496 location_icon_view_.SetLabel(icon_label, [field_ font], color); 499 security_label_view_.SetLabel(icon_label, [field_ font], color);
500 security_label_view_.SetVisible(true);
497 } 501 }
498 } 502 }
499 503
500 void LocationBarViewMac::Observe(NotificationType type, 504 void LocationBarViewMac::Observe(NotificationType type,
501 const NotificationSource& source, 505 const NotificationSource& source,
502 const NotificationDetails& details) { 506 const NotificationDetails& details) {
503 switch (type.value) { 507 switch (type.value) {
504 case NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { 508 case NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: {
505 TabContents* contents = GetTabContents(); 509 TabContents* contents = GetTabContents();
506 if (Details<TabContents>(contents) != details) 510 if (Details<TabContents>(contents) != details)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 NSAttributedString* attrStr = 563 NSAttributedString* attrStr =
560 [[NSAttributedString alloc] initWithString:text attributes:attributes]; 564 [[NSAttributedString alloc] initWithString:text attributes:attributes];
561 label_.reset(attrStr); 565 label_.reset(attrStr);
562 } 566 }
563 } 567 }
564 568
565 void LocationBarViewMac::LocationBarImageView::SetVisible(bool visible) { 569 void LocationBarViewMac::LocationBarImageView::SetVisible(bool visible) {
566 visible_ = visible; 570 visible_ = visible;
567 } 571 }
568 572
573 NSSize LocationBarViewMac::LocationBarImageView::GetDefaultImageSize() const {
574 return NSZeroSize;
575 }
576
577 NSSize LocationBarViewMac::LocationBarImageView::GetImageSize() const {
578 NSImage* image = GetImage();
579 if (image)
580 return [image size];
581 return GetDefaultImageSize();
582 }
583
569 // LocationIconView ------------------------------------------------------------ 584 // LocationIconView ------------------------------------------------------------
570 585
571 LocationBarViewMac::LocationIconView::LocationIconView( 586 LocationBarViewMac::LocationIconView::LocationIconView(
572 LocationBarViewMac* owner) 587 LocationBarViewMac* owner)
573 : owner_(owner) { 588 : owner_(owner) {
574 } 589 }
575 590
576 LocationBarViewMac::LocationIconView::~LocationIconView() {} 591 LocationBarViewMac::LocationIconView::~LocationIconView() {}
577 592
578 void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) { 593 void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 ImageLoadingTracker::DONT_CACHE); 630 ImageLoadingTracker::DONT_CACHE);
616 } 631 }
617 632
618 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, 633 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE,
619 Source<Profile>(profile_)); 634 Source<Profile>(profile_));
620 } 635 }
621 636
622 LocationBarViewMac::PageActionImageView::~PageActionImageView() { 637 LocationBarViewMac::PageActionImageView::~PageActionImageView() {
623 } 638 }
624 639
625 NSSize LocationBarViewMac::PageActionImageView::GetPreferredImageSize() { 640 NSSize LocationBarViewMac::PageActionImageView::GetDefaultImageSize() const {
626 NSImage* image = GetImage(); 641 return NSMakeSize(Extension::kPageActionIconMaxSize,
627 if (image) { 642 Extension::kPageActionIconMaxSize);
628 return [image size];
629 } else {
630 return NSMakeSize(Extension::kPageActionIconMaxSize,
631 Extension::kPageActionIconMaxSize);
632 }
633 } 643 }
634 644
635 // Overridden from LocationBarImageView. Either notify listeners or show a 645 // Overridden from LocationBarImageView. Either notify listeners or show a
636 // popup depending on the Page Action. 646 // popup depending on the Page Action.
637 void LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) { 647 void LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) {
638 if (current_tab_id_ < 0) { 648 if (current_tab_id_ < 0) {
639 NOTREACHED() << "No current tab."; 649 NOTREACHED() << "No current tab.";
640 // We don't want other code to try and handle this click. Returning true 650 // We don't want other code to try and handle this click. Returning true
641 // prevents this by indicating that we handled it. 651 // prevents this by indicating that we handled it.
642 return; 652 return;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 ++result; 929 ++result;
920 } 930 }
921 return result; 931 return result;
922 } 932 }
923 933
924 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, 934 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame,
925 size_t index) { 935 size_t index) {
926 ViewAt(index)->OnMousePressed(iconFrame); 936 ViewAt(index)->OnMousePressed(iconFrame);
927 } 937 }
928 938
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/location_bar_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698