OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <utility> |
| 6 |
5 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" | 7 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
6 #include "chrome/browser/ui/chrome_style.h" | 8 #include "chrome/browser/ui/chrome_style.h" |
7 #include "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h" | 9 #include "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h" |
8 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" | 10 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" |
9 #include "components/infobars/core/infobar.h" | 11 #include "components/infobars/core/infobar.h" |
10 #include "skia/ext/skia_utils_mac.h" | 12 #include "skia/ext/skia_utils_mac.h" |
11 #include "ui/base/cocoa/controls/hyperlink_text_view.h" | 13 #include "ui/base/cocoa/controls/hyperlink_text_view.h" |
12 | 14 |
13 @interface SavePasswordInfobarController : ConfirmInfoBarController | 15 @interface SavePasswordInfobarController : ConfirmInfoBarController |
14 @end | 16 @end |
15 | 17 |
16 @implementation SavePasswordInfobarController | 18 @implementation SavePasswordInfobarController |
17 | 19 |
18 - (void)addAdditionalControls { | 20 - (void)addAdditionalControls { |
19 [super addAdditionalControls]; | 21 [super addAdditionalControls]; |
20 // Set the link inside the message. | 22 // Set the link inside the message. |
21 SavePasswordInfoBarDelegate* delegate = | 23 SavePasswordInfoBarDelegate* delegate = |
22 static_cast<SavePasswordInfoBarDelegate*>([self delegate]); | 24 static_cast<SavePasswordInfoBarDelegate*>([self delegate]); |
23 gfx::Range linkRange = delegate->message_link_range(); | 25 gfx::Range linkRange = delegate->message_link_range(); |
24 if (!linkRange.is_empty()) { | 26 if (!linkRange.is_empty()) { |
25 NSColor* linkColor = | 27 NSColor* linkColor = |
26 skia::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); | 28 skia::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); |
27 HyperlinkTextView* view = (HyperlinkTextView*)label_.get(); | 29 HyperlinkTextView* view = (HyperlinkTextView*)label_.get(); |
28 [view addLinkRange:linkRange.ToNSRange() withURL:nil linkColor:linkColor]; | 30 [view addLinkRange:linkRange.ToNSRange() withURL:nil linkColor:linkColor]; |
29 } | 31 } |
30 } | 32 } |
31 | 33 |
32 scoped_ptr<infobars::InfoBar> CreateSavePasswordInfoBar | 34 scoped_ptr<infobars::InfoBar> CreateSavePasswordInfoBar |
33 (scoped_ptr<SavePasswordInfoBarDelegate> delegate) { | 35 (scoped_ptr<SavePasswordInfoBarDelegate> delegate) { |
34 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass())); | 36 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(std::move(delegate))); |
35 base::scoped_nsobject<SavePasswordInfobarController> controller( | 37 base::scoped_nsobject<SavePasswordInfobarController> controller( |
36 [[SavePasswordInfobarController alloc] initWithInfoBar:infobar.get()]); | 38 [[SavePasswordInfobarController alloc] initWithInfoBar:infobar.get()]); |
37 infobar->set_controller(controller); | 39 infobar->set_controller(controller); |
38 return infobar.Pass(); | 40 return std::move(infobar); |
39 } | 41 } |
40 | 42 |
41 @end | 43 @end |
OLD | NEW |