OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/origin_chip_view.h" | 5 #include "chrome/browser/ui/views/location_bar/origin_chip_view.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 profile_(profile), | 143 profile_(profile), |
144 showing_16x16_icon_(false), | 144 showing_16x16_icon_(false), |
145 fade_in_animation_(this), | 145 fade_in_animation_(this), |
146 security_level_(ToolbarModel::NONE), | 146 security_level_(ToolbarModel::NONE), |
147 url_malware_(false) { | 147 url_malware_(false) { |
148 EnableCanvasFlippingForRTLUI(true); | 148 EnableCanvasFlippingForRTLUI(true); |
149 | 149 |
150 scoped_refptr<SafeBrowsingService> sb_service = | 150 scoped_refptr<SafeBrowsingService> sb_service = |
151 g_browser_process->safe_browsing_service(); | 151 g_browser_process->safe_browsing_service(); |
152 // |sb_service| may be NULL in tests. | 152 // |sb_service| may be NULL in tests. |
153 if (sb_service && sb_service->ui_manager()) | 153 if (sb_service.get() && sb_service->ui_manager().get()) |
154 sb_service->ui_manager()->AddObserver(this); | 154 sb_service->ui_manager()->AddObserver(this); |
155 | 155 |
156 SetFontList(font_list); | 156 SetFontList(font_list); |
157 | 157 |
158 // TODO(gbillock): Would be nice to just use stock LabelButton stuff here. | 158 // TODO(gbillock): Would be nice to just use stock LabelButton stuff here. |
159 location_icon_view_ = new LocationIconView(location_bar_view_); | 159 location_icon_view_ = new LocationIconView(location_bar_view_); |
160 // Make location icon hover events count as hovering the origin chip. | 160 // Make location icon hover events count as hovering the origin chip. |
161 location_icon_view_->set_interactive(false); | 161 location_icon_view_->set_interactive(false); |
162 location_icon_view_->ShowTooltip(true); | 162 location_icon_view_->ShowTooltip(true); |
163 AddChildView(location_icon_view_); | 163 AddChildView(location_icon_view_); |
(...skipping 11 matching lines...) Expand all Loading... |
175 fade_in_animation_.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); | 175 fade_in_animation_.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN); |
176 fade_in_animation_.SetSlideDuration(175); | 176 fade_in_animation_.SetSlideDuration(175); |
177 | 177 |
178 // Ensure |pressed_text_color_| and |background_colors_| are initialized. | 178 // Ensure |pressed_text_color_| and |background_colors_| are initialized. |
179 SetBorderImages(kNormalImages); | 179 SetBorderImages(kNormalImages); |
180 } | 180 } |
181 | 181 |
182 OriginChipView::~OriginChipView() { | 182 OriginChipView::~OriginChipView() { |
183 scoped_refptr<SafeBrowsingService> sb_service = | 183 scoped_refptr<SafeBrowsingService> sb_service = |
184 g_browser_process->safe_browsing_service(); | 184 g_browser_process->safe_browsing_service(); |
185 if (sb_service.get() && sb_service->ui_manager()) | 185 if (sb_service.get() && sb_service->ui_manager().get()) |
186 sb_service->ui_manager()->RemoveObserver(this); | 186 sb_service->ui_manager()->RemoveObserver(this); |
187 } | 187 } |
188 | 188 |
189 void OriginChipView::OnChanged() { | 189 void OriginChipView::OnChanged() { |
190 content::WebContents* web_contents = location_bar_view_->GetWebContents(); | 190 content::WebContents* web_contents = location_bar_view_->GetWebContents(); |
191 if (!web_contents) | 191 if (!web_contents) |
192 return; | 192 return; |
193 | 193 |
194 // Note: security level can change async as the connection is made. | 194 // Note: security level can change async as the connection is made. |
195 GURL url = location_bar_view_->GetToolbarModel()->GetURL(); | 195 GURL url = location_bar_view_->GetToolbarModel()->GetURL(); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 408 |
409 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will | 409 // Note: When OnSafeBrowsingHit would be called, OnSafeBrowsingMatch will |
410 // have already been called. | 410 // have already been called. |
411 void OriginChipView::OnSafeBrowsingHit( | 411 void OriginChipView::OnSafeBrowsingHit( |
412 const SafeBrowsingUIManager::UnsafeResource& resource) {} | 412 const SafeBrowsingUIManager::UnsafeResource& resource) {} |
413 | 413 |
414 void OriginChipView::OnSafeBrowsingMatch( | 414 void OriginChipView::OnSafeBrowsingMatch( |
415 const SafeBrowsingUIManager::UnsafeResource& resource) { | 415 const SafeBrowsingUIManager::UnsafeResource& resource) { |
416 OnChanged(); | 416 OnChanged(); |
417 } | 417 } |
OLD | NEW |