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/views/location_bar/location_icon_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 8 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { | 102 void LocationIconView::OnClickOrTap(const ui::LocatedEvent& event) { |
103 // Do not show page info if the user has been editing the location bar or the | 103 // Do not show page info if the user has been editing the location bar or the |
104 // location bar is at the NTP. | 104 // location bar is at the NTP. |
105 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) | 105 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) |
106 return; | 106 return; |
107 ProcessLocatedEvent(event); | 107 ProcessLocatedEvent(event); |
108 } | 108 } |
109 | 109 |
110 void LocationIconView::ProcessLocatedEvent(const ui::LocatedEvent& event) { | 110 void LocationIconView::ProcessLocatedEvent(const ui::LocatedEvent& event) { |
111 if (HitTestPoint(event.location())) | 111 if (HitTestPoint(event.location())) |
112 OnActivate(); | 112 OnActivate(event); |
113 } | 113 } |
114 | 114 |
115 gfx::Size LocationIconView::GetMinimumSize() const { | 115 gfx::Size LocationIconView::GetMinimumSize() const { |
116 return GetMinimumSizeForPreferredSize(GetPreferredSize()); | 116 return GetMinimumSizeForPreferredSize(GetPreferredSize()); |
117 } | 117 } |
118 | 118 |
119 gfx::Size LocationIconView::GetMinimumSizeForLabelText( | 119 gfx::Size LocationIconView::GetMinimumSizeForLabelText( |
120 const base::string16& text) const { | 120 const base::string16& text) const { |
121 views::Label label(text, font_list()); | 121 views::Label label(text, font_list()); |
122 return GetMinimumSizeForPreferredSize( | 122 return GetMinimumSizeForPreferredSize( |
123 GetSizeForLabelWidth(label.GetPreferredSize().width())); | 123 GetSizeForLabelWidth(label.GetPreferredSize().width())); |
124 } | 124 } |
125 | 125 |
126 SkColor LocationIconView::GetTextColor() const { | 126 SkColor LocationIconView::GetTextColor() const { |
127 return location_bar_->GetColor(LocationBarView::EV_BUBBLE_TEXT_AND_BORDER); | 127 return location_bar_->GetColor(LocationBarView::EV_BUBBLE_TEXT_AND_BORDER); |
128 } | 128 } |
129 | 129 |
130 SkColor LocationIconView::GetBorderColor() const { | 130 SkColor LocationIconView::GetBorderColor() const { |
131 return GetTextColor(); | 131 return GetTextColor(); |
132 } | 132 } |
133 | 133 |
134 bool LocationIconView::OnActivate() { | 134 bool LocationIconView::OnActivate(const ui::Event& event) { |
135 WebContents* contents = location_bar_->GetWebContents(); | 135 WebContents* contents = location_bar_->GetWebContents(); |
136 if (!contents) | 136 if (!contents) |
137 return false; | 137 return false; |
138 | 138 |
139 // Important to use GetVisibleEntry to match what's showing in the omnibox. | 139 // Important to use GetVisibleEntry to match what's showing in the omnibox. |
140 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | 140 NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
141 // The visible entry can be nullptr in the case of window.open(""). | 141 // The visible entry can be nullptr in the case of window.open(""). |
142 if (!entry) | 142 if (!entry) |
143 return false; | 143 return false; |
144 | 144 |
(...skipping 14 matching lines...) Expand all Loading... |
159 return size; | 159 return size; |
160 } | 160 } |
161 | 161 |
162 void LocationIconView::SetBackground(bool should_show_ev) { | 162 void LocationIconView::SetBackground(bool should_show_ev) { |
163 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); | 163 static const int kEvBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_EV_BUBBLE); |
164 if (should_show_ev) | 164 if (should_show_ev) |
165 SetBackgroundImageGrid(kEvBackgroundImages); | 165 SetBackgroundImageGrid(kEvBackgroundImages); |
166 else | 166 else |
167 UnsetBackgroundImageGrid(); | 167 UnsetBackgroundImageGrid(); |
168 } | 168 } |
OLD | NEW |