OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_infobar_delegate.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_infobar_delegate.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
9 #include "components/infobars/core/infobar.h" | 9 #include "components/infobars/core/infobar.h" |
10 #include "components/infobars/core/infobar_delegate.h" | 10 #include "components/infobars/core/infobar_delegate.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "grit/components_strings.h" | 12 #include "grit/components_strings.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 // static | 16 // static |
17 void DataReductionProxyInfoBarDelegate::Create( | 17 void DataReductionProxyInfoBarDelegate::Create( |
18 content::WebContents* web_contents, const std::string& link_url) { | 18 content::WebContents* web_contents, const std::string& link_url) { |
19 InfoBarService::FromWebContents(web_contents)->AddInfoBar( | 19 InfoBarService* infobar_service = |
20 DataReductionProxyInfoBarDelegate::CreateInfoBar( | 20 InfoBarService::FromWebContents(web_contents); |
21 scoped_ptr<DataReductionProxyInfoBarDelegate>( | 21 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
22 new DataReductionProxyInfoBarDelegate(link_url)))); | 22 scoped_ptr<DataReductionProxyInfoBarDelegate>( |
| 23 new DataReductionProxyInfoBarDelegate(link_url)))); |
23 } | 24 } |
24 | 25 |
25 #if !defined(OS_ANDROID) | |
26 // This infobar currently only supports Android. | |
27 | |
28 // static | |
29 scoped_ptr<infobars::InfoBar> DataReductionProxyInfoBarDelegate::CreateInfoBar( | |
30 scoped_ptr<DataReductionProxyInfoBarDelegate> delegate) { | |
31 return ConfirmInfoBarDelegate::CreateInfoBar(delegate.Pass()); | |
32 } | |
33 #endif | |
34 | |
35 DataReductionProxyInfoBarDelegate::~DataReductionProxyInfoBarDelegate() { | 26 DataReductionProxyInfoBarDelegate::~DataReductionProxyInfoBarDelegate() { |
36 } | 27 } |
37 | 28 |
38 DataReductionProxyInfoBarDelegate::DataReductionProxyInfoBarDelegate( | 29 DataReductionProxyInfoBarDelegate::DataReductionProxyInfoBarDelegate( |
39 const std::string& link_url) | 30 const std::string& link_url) |
40 : ConfirmInfoBarDelegate(), | 31 : ConfirmInfoBarDelegate(), |
41 link_url_(link_url) { | 32 link_url_(link_url) { |
42 } | 33 } |
43 | 34 |
44 bool DataReductionProxyInfoBarDelegate::ShouldExpire( | 35 bool DataReductionProxyInfoBarDelegate::ShouldExpire( |
(...skipping 12 matching lines...) Expand all Loading... |
57 bool DataReductionProxyInfoBarDelegate::LinkClicked( | 48 bool DataReductionProxyInfoBarDelegate::LinkClicked( |
58 WindowOpenDisposition disposition) { | 49 WindowOpenDisposition disposition) { |
59 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | 50 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
60 content::OpenURLParams( | 51 content::OpenURLParams( |
61 GURL(link_url_), | 52 GURL(link_url_), |
62 content::Referrer(), | 53 content::Referrer(), |
63 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 54 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
64 ui::PAGE_TRANSITION_LINK, false)); | 55 ui::PAGE_TRANSITION_LINK, false)); |
65 return true; | 56 return true; |
66 } | 57 } |
OLD | NEW |