| 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(DataReductionProxyInfoBarDelegate::CreateInfoBar( |
| 22 new DataReductionProxyInfoBarDelegate(link_url)))); | 22 infobar_service, scoped_ptr<DataReductionProxyInfoBarDelegate>( |
| 23 new DataReductionProxyInfoBarDelegate(link_url)))); |
| 23 } | 24 } |
| 24 | 25 |
| 25 #if !defined(OS_ANDROID) | 26 #if !defined(OS_ANDROID) |
| 26 // This infobar currently only supports Android. | 27 // This infobar currently only supports Android. |
| 27 | 28 |
| 28 // static | 29 // static |
| 29 scoped_ptr<infobars::InfoBar> DataReductionProxyInfoBarDelegate::CreateInfoBar( | 30 scoped_ptr<infobars::InfoBar> DataReductionProxyInfoBarDelegate::CreateInfoBar( |
| 31 infobars::InfoBarManager* infobar_manager, |
| 30 scoped_ptr<DataReductionProxyInfoBarDelegate> delegate) { | 32 scoped_ptr<DataReductionProxyInfoBarDelegate> delegate) { |
| 31 return ConfirmInfoBarDelegate::CreateInfoBar(delegate.Pass()); | 33 return ConfirmInfoBarDelegate::CreateInfoBar(infobar_manager, |
| 34 delegate.Pass()); |
| 32 } | 35 } |
| 33 #endif | 36 #endif |
| 34 | 37 |
| 35 DataReductionProxyInfoBarDelegate::~DataReductionProxyInfoBarDelegate() { | 38 DataReductionProxyInfoBarDelegate::~DataReductionProxyInfoBarDelegate() { |
| 36 } | 39 } |
| 37 | 40 |
| 38 DataReductionProxyInfoBarDelegate::DataReductionProxyInfoBarDelegate( | 41 DataReductionProxyInfoBarDelegate::DataReductionProxyInfoBarDelegate( |
| 39 const std::string& link_url) | 42 const std::string& link_url) |
| 40 : ConfirmInfoBarDelegate(), | 43 : ConfirmInfoBarDelegate(), |
| 41 link_url_(link_url) { | 44 link_url_(link_url) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 57 bool DataReductionProxyInfoBarDelegate::LinkClicked( | 60 bool DataReductionProxyInfoBarDelegate::LinkClicked( |
| 58 WindowOpenDisposition disposition) { | 61 WindowOpenDisposition disposition) { |
| 59 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | 62 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
| 60 content::OpenURLParams( | 63 content::OpenURLParams( |
| 61 GURL(link_url_), | 64 GURL(link_url_), |
| 62 content::Referrer(), | 65 content::Referrer(), |
| 63 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 66 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 64 ui::PAGE_TRANSITION_LINK, false)); | 67 ui::PAGE_TRANSITION_LINK, false)); |
| 65 return true; | 68 return true; |
| 66 } | 69 } |
| OLD | NEW |