summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.h15
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.mm22
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm45
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_unittest.mm47
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.h37
-rw-r--r--chrome/browser/cocoa/location_bar_view_mac.mm80
-rw-r--r--chrome/browser/cocoa/tab_strip_controller_unittest.mm6
7 files changed, 114 insertions, 138 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.h b/chrome/browser/cocoa/autocomplete_text_field_cell.h
index 32f0590..6b2f156 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.h
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.h
@@ -44,10 +44,9 @@ class ExtensionAction;
// side of the field. Exclusive WRT |keywordString_|;
scoped_nsobject<NSAttributedString> hintString_;
- // View showing the state of the SSL connection. Owned by the location bar.
- // Display is exclusive WRT the |hintString_| and |keywordString_|.
- // This may be NULL during testing.
- LocationBarViewMac::SecurityImageView* security_image_view_;
+ // View showing an icon matching the current text. Owned by the location bar.
+ // Exclusive WRT |keywordString_|. This may be NULL during testing.
+ LocationBarViewMac::LocationIconView* location_icon_view_;
// List of views showing visible Page Actions. Owned by the location bar.
// Display is exclusive WRT the |hintString_| and |keywordString_|.
@@ -77,7 +76,7 @@ class ExtensionAction;
availableWidth:(CGFloat)width;
- (void)clearKeywordAndHint;
-- (void)setSecurityImageView:(LocationBarViewMac::SecurityImageView*)view;
+- (void)setLocationIconView:(LocationBarViewMac::LocationIconView*)view;
- (void)setPageActionViewList:(LocationBarViewMac::PageActionViewList*)list;
- (void)setContentSettingViewsList:
(LocationBarViewMac::ContentSettingViews*)views;
@@ -113,8 +112,8 @@ class ExtensionAction;
// Returns the total number of installed Page Actions, visible or not.
- (size_t)pageActionCount;
-// Returns the portion of the cell to use for displaying the security (SSL lock)
-// icon, leaving space for its label if any.
-- (NSRect)securityImageFrameForFrame:(NSRect)cellFrame;
+// Returns the portion of the cell to use for displaying the location icon,
+// leaving space for its label if any.
+- (NSRect)locationIconFrameForFrame:(NSRect)cellFrame;
@end
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index ecc00b8..5fb7b16 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -213,8 +213,8 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) {
page_action_views_ = list;
}
-- (void)setSecurityImageView:(LocationBarViewMac::SecurityImageView*)view {
- security_image_view_ = view;
+- (void)setLocationIconView:(LocationBarViewMac::LocationIconView*)view {
+ location_icon_view_ = view;
}
- (void)setContentSettingViewsList:
@@ -273,15 +273,15 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) {
return box;
}
-- (NSRect)securityImageFrameForFrame:(NSRect)cellFrame {
- if (!security_image_view_ || !security_image_view_->IsVisible()) {
+- (NSRect)locationIconFrameForFrame:(NSRect)cellFrame {
+ if (!location_icon_view_ || !location_icon_view_->IsVisible()) {
return NSZeroRect;
}
// Calculate the total width occupied by the image, label, and padding.
- NSSize imageSize = [security_image_view_->GetImage() size];
+ NSSize imageSize = [location_icon_view_->GetImage() size];
CGFloat widthUsed = imageSize.width + kIconHorizontalPad;
- NSAttributedString* label = security_image_view_->GetLabel();
+ NSAttributedString* label = location_icon_view_->GetLabel();
if (label) {
widthUsed += ceil([label size].width) + kHintXOffset;
}
@@ -404,12 +404,12 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) {
- (NSArray*)layedOutIcons:(NSRect)cellFrame {
NSMutableArray* result = [NSMutableArray arrayWithCapacity:0];
NSRect iconFrame = cellFrame;
- if (security_image_view_ && security_image_view_->IsVisible()) {
- NSRect securityImageFrame = [self securityImageFrameForFrame:iconFrame];
+ if (location_icon_view_ && location_icon_view_->IsVisible()) {
+ NSRect locationIconFrame = [self locationIconFrameForFrame:iconFrame];
[result addObject:
- [AutocompleteTextFieldIcon iconWithRect:securityImageFrame
- view:security_image_view_]];
- iconFrame.size.width -= NSMaxX(iconFrame) - NSMinX(securityImageFrame);
+ [AutocompleteTextFieldIcon iconWithRect:locationIconFrame
+ view:location_icon_view_]];
+ iconFrame.size.width -= NSMaxX(iconFrame) - NSMinX(locationIconFrame);
}
const size_t pageActionCount = [self pageActionCount];
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
index c400162..60418a0 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm
@@ -4,6 +4,7 @@
#import <Cocoa/Cocoa.h>
+#include "app/resource_bundle.h"
#include "base/scoped_nsobject.h"
#import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
@@ -44,7 +45,7 @@ class TestPageActionViewList : public LocationBarViewMac::PageActionViewList {
class AutocompleteTextFieldCellTest : public CocoaTest {
public:
- AutocompleteTextFieldCellTest() : security_image_view_(NULL, NULL, NULL),
+ AutocompleteTextFieldCellTest() : location_icon_view_(NULL),
page_action_views_() {
// Make sure this is wide enough to play games with the cell
// decorations.
@@ -58,7 +59,7 @@ class AutocompleteTextFieldCellTest : public CocoaTest {
[[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]);
[cell setEditable:YES];
[cell setBordered:YES];
- [cell setSecurityImageView:&security_image_view_];
+ [cell setLocationIconView:&location_icon_view_];
[cell setPageActionViewList:&page_action_views_];
[view_ setCell:cell.get()];
@@ -66,7 +67,7 @@ class AutocompleteTextFieldCellTest : public CocoaTest {
}
NSTextField* view_;
- LocationBarViewMac::SecurityImageView security_image_view_;
+ LocationBarViewMac::LocationIconView location_icon_view_;
TestPageActionViewList page_action_views_;
};
@@ -200,9 +201,10 @@ TEST_F(AutocompleteTextFieldCellTest, TextFrame) {
EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame));
EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame));
- // Security icon takes up space on the right
- security_image_view_.SetImageShown(IDR_SECURE);
- security_image_view_.SetVisible(true);
+ // Location icon takes up space on the right
+ location_icon_view_.SetImage(
+ ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE));
+ location_icon_view_.SetVisible(true);
textFrame = [cell textFrameForFrame:bounds];
EXPECT_FALSE(NSIsEmptyRect(textFrame));
@@ -265,8 +267,9 @@ TEST_F(AutocompleteTextFieldCellTest, DrawingRectForBounds) {
EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
EXPECT_TRUE(NSEqualRects(drawingRect, originalDrawingRect));
- security_image_view_.SetImageShown(IDR_SECURE);
- security_image_view_.SetVisible(true);
+ location_icon_view_.SetImage(
+ ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE));
+ location_icon_view_.SetVisible(true);
textFrame = [cell textFrameForFrame:bounds];
drawingRect = [cell drawingRectForBounds:bounds];
@@ -274,17 +277,18 @@ TEST_F(AutocompleteTextFieldCellTest, DrawingRectForBounds) {
EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
}
-// Test that the security icon is at the right side of the cell.
-TEST_F(AutocompleteTextFieldCellTest, SecurityImageFrame) {
+// Test that the location icon is at the right side of the cell.
+TEST_F(AutocompleteTextFieldCellTest, LocationIconFrame) {
AutocompleteTextFieldCell* cell =
static_cast<AutocompleteTextFieldCell*>([view_ cell]);
const NSRect bounds([view_ bounds]);
- security_image_view_.SetImageShown(IDR_SECURE);
+ location_icon_view_.SetImage(
+ ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE));
- security_image_view_.SetVisible(false);
+ location_icon_view_.SetVisible(false);
EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]);
- security_image_view_.SetVisible(true);
+ location_icon_view_.SetVisible(true);
NSArray* icons = [cell layedOutIcons:bounds];
ASSERT_EQ(1u, [icons count]);
NSRect iconRect = [[icons objectAtIndex:0] rect];
@@ -303,7 +307,7 @@ TEST_F(AutocompleteTextFieldCellTest, SecurityImageFrame) {
// Now add a label.
NSFont* font = [NSFont controlContentFontOfSize:12.0];
NSColor* color = [NSColor blackColor];
- security_image_view_.SetLabel(@"Label", font, color);
+ location_icon_view_.SetLabel(@"Label", font, color);
icons = [cell layedOutIcons:bounds];
ASSERT_EQ(1u, [icons count]);
iconRect = [[icons objectAtIndex:0] rect];
@@ -320,7 +324,7 @@ TEST_F(AutocompleteTextFieldCellTest, SecurityImageFrame) {
EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect));
// Make sure we clear correctly.
- security_image_view_.SetVisible(false);
+ location_icon_view_.SetVisible(false);
EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]);
}
@@ -347,7 +351,8 @@ TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) {
AutocompleteTextFieldCell* cell =
static_cast<AutocompleteTextFieldCell*>([view_ cell]);
const NSRect bounds([view_ bounds]);
- security_image_view_.SetImageShown(IDR_SECURE);
+ location_icon_view_.SetImage(
+ ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE));
TestPageActionImageView page_action_view;
// We'll assume that the extensions code enforces icons smaller than the
@@ -365,13 +370,13 @@ TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) {
list.Add(&page_action_view2);
[cell setPageActionViewList:&list];
- security_image_view_.SetVisible(false);
+ location_icon_view_.SetVisible(false);
page_action_view.SetVisible(false);
page_action_view2.SetVisible(false);
EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:0 inFrame:bounds]));
EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:1 inFrame:bounds]));
- // One page action, no security icon.
+ // One page action, no lock icon.
page_action_view.SetVisible(true);
NSRect iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds];
@@ -386,9 +391,9 @@ TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) {
NSRect textFrame = [cell textFrameForFrame:bounds];
EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect0));
- // Two page actions plus a security icon.
+ // Two page actions plus a lock icon.
page_action_view2.SetVisible(true);
- security_image_view_.SetVisible(true);
+ location_icon_view_.SetVisible(true);
NSArray* icons = [cell layedOutIcons:bounds];
EXPECT_EQ(3u, [icons count]);
iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds];
diff --git a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
index c5ad20f..826dfbe 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm
@@ -4,6 +4,7 @@
#import <Cocoa/Cocoa.h>
+#include "app/resource_bundle.h"
#import "base/cocoa_protocols_mac.h"
#include "base/scoped_nsobject.h"
#import "chrome/browser/cocoa/autocomplete_text_field.h"
@@ -21,12 +22,10 @@ using ::testing::Return;
using ::testing::StrictMock;
namespace {
-class MockSecurityImageView : public LocationBarViewMac::SecurityImageView {
+class MockLocationIconView : public LocationBarViewMac::LocationIconView {
public:
- MockSecurityImageView(LocationBarViewMac* owner,
- Profile* profile,
- ToolbarModel* model)
- : LocationBarViewMac::SecurityImageView(owner, profile, model) {}
+ MockLocationIconView(LocationBarViewMac* owner)
+ : LocationBarViewMac::LocationIconView(owner) {}
// We can't use gmock's MOCK_METHOD macro, because it doesn't like the
// NSRect argument to OnMousePressed.
@@ -582,30 +581,32 @@ TEST_F(AutocompleteTextFieldTest, TripleClickSelectsAll) {
EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]);
}
-// Clicking the security icon should call its OnMousePressed.
-TEST_F(AutocompleteTextFieldObserverTest, SecurityIconMouseDown) {
+// Clicking the location icon should call its OnMousePressed.
+TEST_F(AutocompleteTextFieldObserverTest, LocationIconMouseDown) {
AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
- MockSecurityImageView security_image_view(NULL, NULL, NULL);
- [cell setSecurityImageView:&security_image_view];
- security_image_view.SetImageShown(IDR_SECURE);
- security_image_view.SetVisible(true);
+ MockLocationIconView location_icon_view(NULL);
+ [cell setLocationIconView:&location_icon_view];
+ location_icon_view.SetImage(
+ ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE));
+ location_icon_view.SetVisible(true);
- NSRect iconFrame([cell securityImageFrameForFrame:[field_ bounds]]);
+ NSRect iconFrame([cell locationIconFrameForFrame:[field_ bounds]]);
NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame)));
NSEvent* event(Event(field_, location, NSLeftMouseDown, 1));
[field_ mouseDown:event];
- EXPECT_TRUE(security_image_view.mouse_was_pressed_);
+ EXPECT_TRUE(location_icon_view.mouse_was_pressed_);
}
// Clicking a Page Action icon should call its OnMousePressed.
TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) {
AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
- MockSecurityImageView security_image_view(NULL, NULL, NULL);
- security_image_view.SetImageShown(IDR_SECURE);
- [cell setSecurityImageView:&security_image_view];
+ MockLocationIconView location_icon_view(NULL);
+ location_icon_view.SetImage(
+ ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE));
+ [cell setLocationIconView:&location_icon_view];
MockPageActionImageView page_action_view;
NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"];
@@ -619,8 +620,8 @@ TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) {
list.Add(&page_action_view2);
[cell setPageActionViewList:&list];
- // One page action, no security lock.
- security_image_view.SetVisible(false);
+ // One page action, no lock.
+ location_icon_view.SetVisible(false);
page_action_view.SetVisible(true);
page_action_view2.SetVisible(false);
NSRect iconFrame([cell pageActionFrameForIndex:0 inFrame:[field_ bounds]]);
@@ -630,7 +631,7 @@ TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) {
[field_ mouseDown:event];
EXPECT_TRUE(page_action_view.MouseWasPressed());
- // Two page actions, no security lock.
+ // Two page actions, no lock.
page_action_view2.SetVisible(true);
iconFrame = [cell pageActionFrameForIndex:0 inFrame:[field_ bounds]];
location = NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame));
@@ -646,8 +647,8 @@ TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) {
[field_ mouseDown:event];
EXPECT_TRUE(page_action_view.MouseWasPressed());
- // Two page actions plus security lock.
- security_image_view.SetVisible(true);
+ // Two page actions plus lock.
+ location_icon_view.SetVisible(true);
iconFrame = [cell pageActionFrameForIndex:0 inFrame:[field_ bounds]];
location = NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame));
event = Event(field_, location, NSLeftMouseDown, 1);
@@ -662,12 +663,12 @@ TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) {
[field_ mouseDown:event];
EXPECT_TRUE(page_action_view.MouseWasPressed());
- iconFrame = [cell securityImageFrameForFrame:[field_ bounds]];
+ iconFrame = [cell locationIconFrameForFrame:[field_ bounds]];
location = NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame));
event = Event(field_, location, NSLeftMouseDown, 1);
[field_ mouseDown:event];
- EXPECT_TRUE(security_image_view.mouse_was_pressed_);
+ EXPECT_TRUE(location_icon_view.mouse_was_pressed_);
}
// Test that page action menus are properly returned.
diff --git a/chrome/browser/cocoa/location_bar_view_mac.h b/chrome/browser/cocoa/location_bar_view_mac.h
index b7f5187..afa4aec 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.h
+++ b/chrome/browser/cocoa/location_bar_view_mac.h
@@ -173,35 +173,20 @@ class LocationBarViewMac : public AutocompleteEditController,
DISALLOW_COPY_AND_ASSIGN(LocationBarImageView);
};
- // SecurityImageView is used to display the lock or warning icon when the
- // current URL's scheme is https.
- class SecurityImageView : public LocationBarImageView {
+ // LocationIconView is used to display an icon to the left of the address.
+ class LocationIconView : public LocationBarImageView {
public:
- SecurityImageView(LocationBarViewMac* owner,
- Profile* profile,
- ToolbarModel* model);
- virtual ~SecurityImageView();
-
- // Sets the image to the appropriate icon.
- void SetImageShown(int resource_id);
+ explicit LocationIconView(LocationBarViewMac* owner);
+ virtual ~LocationIconView();
// Shows the page info dialog.
virtual void OnMousePressed(NSRect bounds);
private:
- // Icons for various states. Lazily loaded the first time they're needed.
- scoped_nsobject<NSImage> ev_secure_icon_;
- scoped_nsobject<NSImage> secure_icon_;
- scoped_nsobject<NSImage> security_warning_icon_;
- scoped_nsobject<NSImage> security_error_icon_;
-
// The location bar view that owns us.
LocationBarViewMac* owner_;
- Profile* profile_;
- ToolbarModel* model_;
-
- DISALLOW_COPY_AND_ASSIGN(SecurityImageView);
+ DISALLOW_COPY_AND_ASSIGN(LocationIconView);
};
// PageActionImageView is used to display the icon for a given Page Action
@@ -374,11 +359,11 @@ class LocationBarViewMac : public AutocompleteEditController,
};
private:
- // Sets the SSL icon we should be showing.
- void SetSecurityIcon(int resource_id);
+ // Sets the location icon we should be showing.
+ void SetIcon(int resource_id);
- // Sets the label for the SSL icon.
- void SetSecurityIconLabel();
+ // Sets the label for the SSL state.
+ void SetSecurityLabel();
// Posts |notification| to the default notification center.
void PostNotification(const NSString* notification);
@@ -401,8 +386,8 @@ class LocationBarViewMac : public AutocompleteEditController,
// The user's desired disposition for how their input should be opened.
WindowOpenDisposition disposition_;
- // The view that shows the lock/warning when in HTTPS mode.
- SecurityImageView security_image_view_;
+ // A view that shows an icon to the left of the address.
+ LocationIconView location_icon_view_;
// Any installed Page Actions.
PageActionViewList page_action_views_;
diff --git a/chrome/browser/cocoa/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar_view_mac.mm
index 0035101..4660001 100644
--- a/chrome/browser/cocoa/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar_view_mac.mm
@@ -103,7 +103,7 @@ LocationBarViewMac::LocationBarViewMac(
command_updater_(command_updater),
field_(field),
disposition_(CURRENT_TAB),
- security_image_view_(this, profile, toolbar_model),
+ location_icon_view_(this),
page_action_views_(this, profile, toolbar_model),
profile_(profile),
browser_(browser),
@@ -118,7 +118,7 @@ LocationBarViewMac::LocationBarViewMac(
}
AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
- [cell setSecurityImageView:&security_image_view_];
+ [cell setLocationIconView:&location_icon_view_];
[cell setPageActionViewList:&page_action_views_];
[cell setContentSettingViewsList:&content_setting_views_];
@@ -131,7 +131,7 @@ LocationBarViewMac::~LocationBarViewMac() {
// Disconnect from cell in case it outlives us.
AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
[cell setPageActionViewList:NULL];
- [cell setSecurityImageView:NULL];
+ [cell setLocationIconView:NULL];
}
std::wstring LocationBarViewMac::GetInputString() const {
@@ -208,7 +208,7 @@ void LocationBarViewMac::SaveStateToContents(TabContents* contents) {
void LocationBarViewMac::Update(const TabContents* contents,
bool should_restore_state) {
- SetSecurityIcon(toolbar_model_->GetSecurityIcon());
+ SetIcon(edit_view_->GetIcon());
page_action_views_.RefreshViews();
RefreshContentSettingsViews();
// AutocompleteEditView restores state if the tab is non-NULL.
@@ -457,11 +457,27 @@ NSImage* LocationBarViewMac::GetTabButtonImage() {
return tab_button_image_;
}
-void LocationBarViewMac::SetSecurityIconLabel() {
- // TODO(shess): Separate from security icon and move icon to left of address.
+void LocationBarViewMac::SetIcon(int resource_id) {
+ DCHECK(resource_id != 0);
+
+ // The icon is always visible except when there is a keyword hint.
+ if (!edit_view_->model()->keyword().empty() &&
+ !edit_view_->model()->is_keyword_hint()) {
+ location_icon_view_.SetVisible(false);
+ } else {
+ location_icon_view_.SetImage(
+ ResourceBundle::GetSharedInstance().GetNSImageNamed(resource_id));
+ location_icon_view_.SetVisible(true);
+ SetSecurityLabel();
+ }
+ [field_ resetFieldEditorFrameIfNeeded];
+}
+
+void LocationBarViewMac::SetSecurityLabel() {
+ // TODO(shess): Separate from location icon and move icon to left of address.
std::wstring security_info_text(toolbar_model_->GetSecurityInfoText());
if (security_info_text.empty()) {
- security_image_view_.SetLabel(nil, nil, nil);
+ location_icon_view_.SetLabel(nil, nil, nil);
} else {
NSString* icon_label = base::SysWideToNSString(security_info_text);
NSColor* color;
@@ -477,21 +493,10 @@ void LocationBarViewMac::SetSecurityIconLabel() {
blue:kSecurityErrorTextColorBlueComponent
alpha:1.0];
}
- security_image_view_.SetLabel(icon_label, [field_ font], color);
+ location_icon_view_.SetLabel(icon_label, [field_ font], color);
}
}
-void LocationBarViewMac::SetSecurityIcon(int resource_id) {
- if (resource_id == 0) {
- security_image_view_.SetVisible(false);
- } else {
- security_image_view_.SetImageShown(resource_id);
- security_image_view_.SetVisible(true);
- SetSecurityIconLabel();
- }
- [field_ resetFieldEditorFrameIfNeeded];
-}
-
void LocationBarViewMac::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -561,39 +566,16 @@ void LocationBarViewMac::LocationBarImageView::SetVisible(bool visible) {
visible_ = visible;
}
-// SecurityImageView------------------------------------------------------------
+// LocationIconView ------------------------------------------------------------
-LocationBarViewMac::SecurityImageView::SecurityImageView(
- LocationBarViewMac* owner,
- Profile* profile,
- ToolbarModel* model)
- : ev_secure_icon_(nil),
- secure_icon_(nil),
- security_warning_icon_(nil),
- security_error_icon_(nil),
- owner_(owner),
- profile_(profile),
- model_(model) {}
-
-LocationBarViewMac::SecurityImageView::~SecurityImageView() {}
-
-void LocationBarViewMac::SecurityImageView::SetImageShown(int resource_id) {
- scoped_nsobject<NSImage>* icon;
- switch (resource_id) {
- case IDR_EV_SECURE: icon = &ev_secure_icon_; break;
- case IDR_SECURE: icon = &secure_icon_; break;
- case IDR_SECURITY_WARNING: icon = &security_warning_icon_; break;
- case IDR_SECURITY_ERROR: icon = &security_error_icon_; break;
- default: NOTREACHED(); return;
- }
- if (!icon->get()) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- icon->reset([rb.GetNSImageNamed(resource_id) retain]);
- }
- SetImage(*icon);
+LocationBarViewMac::LocationIconView::LocationIconView(
+ LocationBarViewMac* owner)
+ : owner_(owner) {
}
-void LocationBarViewMac::SecurityImageView::OnMousePressed(NSRect bounds) {
+LocationBarViewMac::LocationIconView::~LocationIconView() {}
+
+void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) {
TabContents* tab = owner_->GetTabContents();
NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
if (!nav_entry) {
diff --git a/chrome/browser/cocoa/tab_strip_controller_unittest.mm b/chrome/browser/cocoa/tab_strip_controller_unittest.mm
index 0967ae4..7cbe16e 100644
--- a/chrome/browser/cocoa/tab_strip_controller_unittest.mm
+++ b/chrome/browser/cocoa/tab_strip_controller_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -120,6 +120,10 @@ class TabStripControllerTest : public CocoaTest {
// Test adding and removing tabs and making sure that views get added to
// the tab strip.
TEST_F(TabStripControllerTest, AddRemoveTabs) {
+ // Create the objects we need, since we have a real location bar.
+ browser_helper_.profile()->CreateAutocompleteClassifier();
+ browser_helper_.profile()->CreateTemplateURLModel();
+
EXPECT_TRUE(model_->empty());
SiteInstance* instance =
SiteInstance::CreateSiteInstance(browser_helper_.profile());