Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2226)

Unified Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc

Issue 2848293002: Adding the Previews infobar to pages that show a client LoFi image (Closed)
Patch Set: sclittle comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc
index 92616506531838fe026eae5e09c6f7d00893ff5c..1f33a2f1c4c7f0ea0752f32db50624d8c18706f6 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc
@@ -12,6 +12,9 @@
#include "chrome/browser/net/spdyproxy/chrome_data_use_group_provider.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/browser/previews/previews_infobar_delegate.h"
+#include "chrome/browser/previews/previews_service.h"
+#include "chrome/browser/previews/previews_service_factory.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/pref_names.h"
@@ -21,9 +24,15 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "components/prefs/pref_service.h"
+#include "components/previews/core/previews_experiments.h"
+#include "components/previews/core/previews_ui_service.h"
#include "components/version_info/version_info.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
+#include "url/gurl.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
@@ -37,14 +46,41 @@ using data_reduction_proxy::DataReductionProxyParams;
namespace {
+// Adds the preview navigation to the black list.
+void AddPreviewNavigationToBlackListCallback(
+ content::BrowserContext* browser_context,
+ const GURL& url,
+ previews::PreviewsType type,
+ bool opt_out) {
+ PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile(
+ Profile::FromBrowserContext(browser_context));
+ if (previews_service && previews_service->previews_ui_service()) {
+ previews_service->previews_ui_service()->AddPreviewNavigation(url, type,
+ opt_out);
+ }
+}
+
// If this is the first Lo-Fi response for a page load, a
// PreviewsInfoBarDelegate is created, which handles showing Lo-Fi UI.
-void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents) {
+void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents,
+ bool is_server_lofi) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- PreviewsInfoBarDelegate::Create(
- web_contents, PreviewsInfoBarDelegate::LOFI,
- true /* is_data_saver_user */,
- PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
+ if (is_server_lofi) {
sclittle 2017/05/03 22:51:29 If both Server and Client LoFi are used on a page,
RyanSturm 2017/05/03 23:20:29 Good Point. I was trying to land these CLs side-by
+ PreviewsInfoBarDelegate::Create(
+ web_contents, PreviewsInfoBarDelegate::LOFI,
+ true /* is_data_saver_user */,
+ PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
+ } else {
+ PreviewsInfoBarDelegate::Create(
+ web_contents, PreviewsInfoBarDelegate::LOFI,
+ true /* is_data_saver_user */,
+ base::Bind(&AddPreviewNavigationToBlackListCallback,
+ web_contents->GetBrowserContext(),
+ web_contents->GetController()
+ .GetLastCommittedEntry()
+ ->GetRedirectChain()[0],
+ previews::PreviewsType::CLIENT_LOFI));
+ }
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698