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