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 #import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/metrics/user_metrics_action.h" | 8 #include "base/metrics/user_metrics_action.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 icon_rect_(NSZeroRect), | 72 icon_rect_(NSZeroRect), |
73 info_(this, owner->browser()->profile()), | 73 info_(this, owner->browser()->profile()), |
74 location_icon_(location_icon), | 74 location_icon_(location_icon), |
75 owner_(owner) { | 75 owner_(owner) { |
76 DCHECK(owner_); | 76 DCHECK(owner_); |
77 [attributes_ setObject:GetFont() forKey:NSFontAttributeName]; | 77 [attributes_ setObject:GetFont() forKey:NSFontAttributeName]; |
78 | 78 |
79 // May not be set for unit tests. | 79 // May not be set for unit tests. |
80 scoped_refptr<SafeBrowsingService> sb_service = | 80 scoped_refptr<SafeBrowsingService> sb_service = |
81 g_browser_process->safe_browsing_service(); | 81 g_browser_process->safe_browsing_service(); |
82 if (sb_service.get() && sb_service->ui_manager()) | 82 if (sb_service.get() && sb_service->ui_manager().get()) |
83 sb_service->ui_manager()->AddObserver(this); | 83 sb_service->ui_manager()->AddObserver(this); |
84 } | 84 } |
85 | 85 |
86 OriginChipDecoration::~OriginChipDecoration() { | 86 OriginChipDecoration::~OriginChipDecoration() { |
87 scoped_refptr<SafeBrowsingService> sb_service = | 87 scoped_refptr<SafeBrowsingService> sb_service = |
88 g_browser_process->safe_browsing_service(); | 88 g_browser_process->safe_browsing_service(); |
89 if (sb_service.get() && sb_service->ui_manager()) | 89 if (sb_service.get() && sb_service->ui_manager().get()) |
90 sb_service->ui_manager()->RemoveObserver(this); | 90 sb_service->ui_manager()->RemoveObserver(this); |
91 } | 91 } |
92 | 92 |
93 void OriginChipDecoration::Update() { | 93 void OriginChipDecoration::Update() { |
94 if (!owner_->GetToolbarModel()->ShouldShowOriginChip()) { | 94 if (!owner_->GetToolbarModel()->ShouldShowOriginChip()) { |
95 SetVisible(false); | 95 SetVisible(false); |
96 return; | 96 return; |
97 } else { | 97 } else { |
98 SetVisible(true); | 98 SetVisible(true); |
99 } | 99 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return kInnerLeftPadding + | 231 return kInnerLeftPadding + |
232 kIconSize + | 232 kIconSize + |
233 kIconLabelPadding + | 233 kIconLabelPadding + |
234 std::ceil([label_ sizeWithAttributes:attributes_].width) + | 234 std::ceil([label_ sizeWithAttributes:attributes_].width) + |
235 kInnerRightPadding; | 235 kInnerRightPadding; |
236 } | 236 } |
237 | 237 |
238 // TODO(macourteau): Implement eliding of the host. | 238 // TODO(macourteau): Implement eliding of the host. |
239 | 239 |
240 // TODO(macourteau): Implement dragging support. | 240 // TODO(macourteau): Implement dragging support. |
OLD | NEW |