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" | |
13 #include "ui/base/l10n/l10n_util.h" | |
14 #include "url/gurl.h" | |
12 | 15 |
13 // static | 16 // static |
14 void DataReductionProxyInfoBarDelegate::Create( | 17 void DataReductionProxyInfoBarDelegate::Create( |
15 content::WebContents* web_contents) { | 18 content::WebContents* web_contents, const std::string& link_url) { |
16 InfoBarService::FromWebContents(web_contents)->AddInfoBar( | 19 InfoBarService::FromWebContents(web_contents)->AddInfoBar( |
17 DataReductionProxyInfoBarDelegate::CreateInfoBar( | 20 DataReductionProxyInfoBarDelegate::CreateInfoBar( |
18 scoped_ptr<DataReductionProxyInfoBarDelegate>( | 21 scoped_ptr<DataReductionProxyInfoBarDelegate>( |
19 new DataReductionProxyInfoBarDelegate()))); | 22 new DataReductionProxyInfoBarDelegate(link_url)))); |
20 } | 23 } |
21 | 24 |
22 #if !defined(OS_ANDROID) | 25 #if !defined(OS_ANDROID) |
23 // This infobar currently only supports Android. | 26 // This infobar currently only supports Android. |
24 | 27 |
25 // static | 28 // static |
26 scoped_ptr<infobars::InfoBar> DataReductionProxyInfoBarDelegate::CreateInfoBar( | 29 scoped_ptr<infobars::InfoBar> DataReductionProxyInfoBarDelegate::CreateInfoBar( |
27 scoped_ptr<DataReductionProxyInfoBarDelegate> delegate) { | 30 scoped_ptr<DataReductionProxyInfoBarDelegate> delegate) { |
28 return ConfirmInfoBarDelegate::CreateInfoBar( | 31 return ConfirmInfoBarDelegate::CreateInfoBar( |
29 delegate.PassAs<ConfirmInfoBarDelegate>()); | 32 delegate.PassAs<ConfirmInfoBarDelegate>()); |
30 } | 33 } |
31 #endif | 34 #endif |
32 | 35 |
33 DataReductionProxyInfoBarDelegate::~DataReductionProxyInfoBarDelegate() { | 36 DataReductionProxyInfoBarDelegate::~DataReductionProxyInfoBarDelegate() { |
34 } | 37 } |
35 | 38 |
36 DataReductionProxyInfoBarDelegate::DataReductionProxyInfoBarDelegate() | 39 DataReductionProxyInfoBarDelegate::DataReductionProxyInfoBarDelegate( |
37 : ConfirmInfoBarDelegate() { | 40 const std::string& link_url) |
41 : ConfirmInfoBarDelegate(), | |
42 link_url_(link_url) { | |
38 } | 43 } |
39 | 44 |
40 bool DataReductionProxyInfoBarDelegate::ShouldExpire( | 45 bool DataReductionProxyInfoBarDelegate::ShouldExpire( |
41 const NavigationDetails& details) const { | 46 const NavigationDetails& details) const { |
42 return false; | 47 return false; |
43 } | 48 } |
44 | 49 |
45 base::string16 DataReductionProxyInfoBarDelegate::GetMessageText() const { | 50 base::string16 DataReductionProxyInfoBarDelegate::GetMessageText() const { |
46 return base::string16(); | 51 return base::string16(); |
47 } | 52 } |
48 | 53 |
49 int DataReductionProxyInfoBarDelegate::GetButtons() const { | 54 int DataReductionProxyInfoBarDelegate::GetButtons() const { |
50 return BUTTON_NONE; | 55 return BUTTON_NONE; |
51 } | 56 } |
57 | |
58 bool DataReductionProxyInfoBarDelegate::LinkClicked( | |
59 WindowOpenDisposition disposition) { | |
60 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | |
61 content::OpenURLParams( | |
62 GURL(link_url_), | |
63 content::Referrer(), | |
64 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | |
65 content::PAGE_TRANSITION_LINK, false)); | |
66 return false; | |
Ted C
2014/09/18 00:40:21
does something else handle closing this?
Just won
bengr
2014/09/18 18:01:15
Because I mistakenly assumed it was being closed.
| |
67 } | |
OLD | NEW |