OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/autofill_notification_controller.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 gfx::SkColorToCalibratedNSColor(notification->GetBorderColor())]; | 79 gfx::SkColorToCalibratedNSColor(notification->GetBorderColor())]; |
80 [self setView:view]; | 80 [self setView:view]; |
81 | 81 |
82 textview_.reset([[HyperlinkTextView alloc] initWithFrame:NSZeroRect]); | 82 textview_.reset([[HyperlinkTextView alloc] initWithFrame:NSZeroRect]); |
83 NSColor* textColor = | 83 NSColor* textColor = |
84 gfx::SkColorToCalibratedNSColor(notification->GetTextColor()); | 84 gfx::SkColorToCalibratedNSColor(notification->GetTextColor()); |
85 [textview_ setMessage:base::SysUTF16ToNSString(notification->display_text()) | 85 [textview_ setMessage:base::SysUTF16ToNSString(notification->display_text()) |
86 withFont:[NSFont labelFontOfSize:[[textview_ font] pointSize]] | 86 withFont:[NSFont labelFontOfSize:[[textview_ font] pointSize]] |
87 messageColor:textColor]; | 87 messageColor:textColor]; |
88 if (!notification->link_range().is_empty()) { | 88 if (!notification->link_range().is_empty()) { |
| 89 linkURL_ = notification->link_url(); |
89 [textview_ setDelegate:self]; | 90 [textview_ setDelegate:self]; |
90 [textview_ addLinkRange:notification->link_range().ToNSRange() | 91 [textview_ addLinkRange:notification->link_range().ToNSRange() |
91 withName:self | 92 withURL:base::SysUTF8ToNSString(linkURL_.spec()) |
92 linkColor:[NSColor blueColor]]; | 93 linkColor:[NSColor blueColor]]; |
93 linkURL_ = notification->link_url(); | |
94 } | 94 } |
95 | 95 |
96 tooltipController_.reset([[AutofillTooltipController alloc] | 96 tooltipController_.reset([[AutofillTooltipController alloc] |
97 initWithArrowLocation:info_bubble::kTopRight]); | 97 initWithArrowLocation:info_bubble::kTopRight]); |
98 [tooltipController_ setImage: | 98 [tooltipController_ setImage: |
99 ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 99 ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
100 IDR_AUTOFILL_TOOLTIP_ICON).ToNSImage()]; | 100 IDR_AUTOFILL_TOOLTIP_ICON).ToNSImage()]; |
101 [tooltipController_ setMessage: | 101 [tooltipController_ setMessage: |
102 base::SysUTF16ToNSString(notification->tooltip_text())]; | 102 base::SysUTF16ToNSString(notification->tooltip_text())]; |
103 [[tooltipController_ view] setHidden: | 103 [[tooltipController_ view] setHidden: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 | 181 |
182 - (BOOL)textView:(NSTextView *)textView | 182 - (BOOL)textView:(NSTextView *)textView |
183 clickedOnLink:(id)link | 183 clickedOnLink:(id)link |
184 atIndex:(NSUInteger)charIndex { | 184 atIndex:(NSUInteger)charIndex { |
185 delegate_->LinkClicked(linkURL_); | 185 delegate_->LinkClicked(linkURL_); |
186 return YES; | 186 return YES; |
187 } | 187 } |
188 | 188 |
189 @end | 189 @end |
OLD | NEW |