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.
5 #include "chrome/browser/password_manager/save_password_infobar_delegate.h"
6 #include "chrome/browser/ui/chrome_style.h"
7 #include "chrome/browser/ui/cocoa/infobars/confirm_infobar_controller.h"
8 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
9 #include "components/infobars/core/infobar.h"
10 #include "skia/ext/skia_utils_mac.h"
11 #include "ui/base/cocoa/controls/hyperlink_text_view.h"
13 @interface SavePasswordInfobarController : ConfirmInfoBarController
16 @implementation SavePasswordInfobarController
18 - (void)addAdditionalControls {
19 [super addAdditionalControls];
20 // Set the link inside the message.
21 SavePasswordInfoBarDelegate* delegate =
22 static_cast<SavePasswordInfoBarDelegate*>([self delegate]);
23 gfx::Range linkRange = delegate->message_link_range();
24 if (!linkRange.is_empty()) {
26 gfx::SkColorToCalibratedNSColor(chrome_style::GetLinkColor());
27 HyperlinkTextView* view = (HyperlinkTextView*)label_.get();
28 [view addLinkRange:linkRange.ToNSRange()
34 scoped_ptr<infobars::InfoBar> CreateSavePasswordInfoBar
35 (scoped_ptr<SavePasswordInfoBarDelegate> delegate) {
36 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass()));
37 base::scoped_nsobject<SavePasswordInfobarController> controller(
38 [[SavePasswordInfobarController alloc] initWithInfoBar:infobar.get()]);
39 infobar->set_controller(controller);
40 return infobar.Pass();