Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/ui/cocoa/infobars/alternate_nav_infobar_controller.mm

Issue 1364113003: Only (and always) put URLs in NSLinkAttributeName. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@infobar1
Patch Set: stray deletion Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import "chrome/browser/ui/cocoa/infobars/alternate_nav_infobar_controller.h" 5 #import "chrome/browser/ui/cocoa/infobars/alternate_nav_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/ui/cocoa/infobars/infobar_cocoa.h" 9 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
10 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" 10 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h"
(...skipping 20 matching lines...) Expand all
31 base::string16 message = delegate->GetMessageTextWithOffset(&offset); 31 base::string16 message = delegate->GetMessageTextWithOffset(&offset);
32 base::string16 link = delegate->GetLinkText(); 32 base::string16 link = delegate->GetLinkText();
33 message.insert(offset, link); 33 message.insert(offset, link);
34 NSFont* font = [NSFont labelFontOfSize: 34 NSFont* font = [NSFont labelFontOfSize:
35 [NSFont systemFontSizeForControlSize:NSRegularControlSize]]; 35 [NSFont systemFontSizeForControlSize:NSRegularControlSize]];
36 HyperlinkTextView* view = (HyperlinkTextView*)label_.get(); 36 HyperlinkTextView* view = (HyperlinkTextView*)label_.get();
37 [view setMessage:base::SysUTF16ToNSString(message) 37 [view setMessage:base::SysUTF16ToNSString(message)
38 withFont:font 38 withFont:font
39 messageColor:[NSColor blackColor]]; 39 messageColor:[NSColor blackColor]];
40 [view addLinkRange:NSMakeRange(offset, link.length()) 40 [view addLinkRange:NSMakeRange(offset, link.length())
41 withName:@"" 41 withURL:base::SysUTF8ToNSString(delegate->GetLinkURL().spec())
42 linkColor:[NSColor blueColor]]; 42 linkColor:[NSColor blueColor]];
43 } 43 }
44 44
45 // Called when someone clicks on the link in the infobar. This method 45 // Called when someone clicks on the link in the infobar. This method
46 // is called by the InfobarTextField on its delegate (the 46 // is called by the InfobarTextField on its delegate (the
47 // AlternateNavInfoBarController). 47 // AlternateNavInfoBarController).
48 - (void)linkClicked { 48 - (void)linkClicked {
49 if (![self isOwned]) 49 if (![self isOwned])
50 return; 50 return;
51 WindowOpenDisposition disposition = 51 WindowOpenDisposition disposition =
52 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); 52 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]);
53 AlternateNavInfoBarDelegate* delegate = 53 AlternateNavInfoBarDelegate* delegate =
54 static_cast<AlternateNavInfoBarDelegate*>([self delegate]); 54 static_cast<AlternateNavInfoBarDelegate*>([self delegate]);
55 if (delegate->LinkClicked(disposition)) 55 if (delegate->LinkClicked(disposition))
56 [self removeSelf]; 56 [self removeSelf];
57 } 57 }
58 58
59 @end 59 @end
60 60
61 // static 61 // static
62 scoped_ptr<infobars::InfoBar> AlternateNavInfoBarDelegate::CreateInfoBar( 62 scoped_ptr<infobars::InfoBar> AlternateNavInfoBarDelegate::CreateInfoBar(
63 scoped_ptr<AlternateNavInfoBarDelegate> delegate) { 63 scoped_ptr<AlternateNavInfoBarDelegate> delegate) {
64 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass())); 64 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass()));
65 base::scoped_nsobject<AlternateNavInfoBarController> controller( 65 base::scoped_nsobject<AlternateNavInfoBarController> controller(
66 [[AlternateNavInfoBarController alloc] initWithInfoBar:infobar.get()]); 66 [[AlternateNavInfoBarController alloc] initWithInfoBar:infobar.get()]);
67 infobar->set_controller(controller); 67 infobar->set_controller(controller);
68 return infobar.Pass(); 68 return infobar.Pass();
69 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698