OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/cocoa/infobars/confirm_infobar_controller.h" | 5 #include "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/browser/ui/chrome_style.h" | 10 #include "chrome/browser/ui/chrome_style.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 linkOffset = [message length] - [link length]; | 119 linkOffset = [message length] - [link length]; |
120 } | 120 } |
121 NSFont* font = [NSFont labelFontOfSize: | 121 NSFont* font = [NSFont labelFontOfSize: |
122 [NSFont systemFontSizeForControlSize:NSRegularControlSize]]; | 122 [NSFont systemFontSizeForControlSize:NSRegularControlSize]]; |
123 HyperlinkTextView* view = (HyperlinkTextView*)label_.get(); | 123 HyperlinkTextView* view = (HyperlinkTextView*)label_.get(); |
124 [view setMessage:message withFont:font messageColor:[NSColor blackColor]]; | 124 [view setMessage:message withFont:font messageColor:[NSColor blackColor]]; |
125 if (linkLength != 0) { | 125 if (linkLength != 0) { |
126 NSColor* linkColor = | 126 NSColor* linkColor = |
127 gfx::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); | 127 gfx::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); |
128 [view addLinkRange:NSMakeRange(linkOffset, linkLength) | 128 [view addLinkRange:NSMakeRange(linkOffset, linkLength) |
129 withName:@"" | 129 withURL:base::SysUTF8ToNSString(delegate->GetLinkURL().spec()) |
130 linkColor:linkColor]; | 130 linkColor:linkColor]; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 // Called when someone clicks on the link in the infobar. This method | 134 // Called when someone clicks on the link in the infobar. This method |
135 // is called by the InfobarTextField on its delegate (the | 135 // is called by the InfobarTextField on its delegate (the |
136 // AlternateNavInfoBarController). | 136 // AlternateNavInfoBarController). |
137 - (void)linkClicked { | 137 - (void)linkClicked { |
138 if (![self isOwned]) | 138 if (![self isOwned]) |
139 return; | 139 return; |
140 WindowOpenDisposition disposition = | 140 WindowOpenDisposition disposition = |
141 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 141 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
142 if ([self delegate]->AsConfirmInfoBarDelegate()->LinkClicked(disposition)) | 142 if ([self delegate]->AsConfirmInfoBarDelegate()->LinkClicked(disposition)) |
143 [self removeSelf]; | 143 [self removeSelf]; |
144 } | 144 } |
145 | 145 |
146 @end | 146 @end |
147 | 147 |
148 scoped_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar( | 148 scoped_ptr<infobars::InfoBar> InfoBarService::CreateConfirmInfoBar( |
149 scoped_ptr<ConfirmInfoBarDelegate> delegate) { | 149 scoped_ptr<ConfirmInfoBarDelegate> delegate) { |
150 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass())); | 150 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass())); |
151 base::scoped_nsobject<ConfirmInfoBarController> controller( | 151 base::scoped_nsobject<ConfirmInfoBarController> controller( |
152 [[ConfirmInfoBarController alloc] initWithInfoBar:infobar.get()]); | 152 [[ConfirmInfoBarController alloc] initWithInfoBar:infobar.get()]); |
153 infobar->set_controller(controller); | 153 infobar->set_controller(controller); |
154 return infobar.Pass(); | 154 return infobar.Pass(); |
155 } | 155 } |
OLD | NEW |