1 // Copyright 2014 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/net/spdyproxy/data_reduction_proxy_infobar_delegate.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "components/infobars/core/infobar.h"
10 #include "components/infobars/core/infobar_delegate.h"
11 #include "content/public/browser/web_contents.h"
12 #include "grit/components_strings.h"
13 #include "ui/base/l10n/l10n_util.h"
17 void DataReductionProxyInfoBarDelegate::Create(
18 content::WebContents
* web_contents
, const std::string
& link_url
) {
19 InfoBarService
* infobar_service
=
20 InfoBarService::FromWebContents(web_contents
);
21 infobar_service
->AddInfoBar(
22 DataReductionProxyInfoBarDelegate::CreateInfoBar(
24 scoped_ptr
<DataReductionProxyInfoBarDelegate
>(
25 new DataReductionProxyInfoBarDelegate(link_url
))));
28 #if !defined(OS_ANDROID)
29 // This infobar currently only supports Android.
32 scoped_ptr
<infobars::InfoBar
> DataReductionProxyInfoBarDelegate::CreateInfoBar(
33 infobars::InfoBarManager
* infobar_manager
,
34 scoped_ptr
<DataReductionProxyInfoBarDelegate
> delegate
) {
35 return infobar_manager
->CreateConfirmInfoBar(delegate
.Pass());
39 DataReductionProxyInfoBarDelegate::~DataReductionProxyInfoBarDelegate() {
42 DataReductionProxyInfoBarDelegate::DataReductionProxyInfoBarDelegate(
43 const std::string
& link_url
)
44 : ConfirmInfoBarDelegate(),
48 bool DataReductionProxyInfoBarDelegate::ShouldExpire(
49 const NavigationDetails
& details
) const {
53 base::string16
DataReductionProxyInfoBarDelegate::GetMessageText() const {
54 return base::string16();
57 int DataReductionProxyInfoBarDelegate::GetButtons() const {
61 bool DataReductionProxyInfoBarDelegate::LinkClicked(
62 WindowOpenDisposition disposition
) {
63 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
64 content::OpenURLParams(
67 (disposition
== CURRENT_TAB
) ? NEW_FOREGROUND_TAB
: disposition
,
68 ui::PAGE_TRANSITION_LINK
, false));