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

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 nit Created 3 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/previews/previews_infobar_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3736e8b428c8917595a627c0228cb7083657646b 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,6 +46,20 @@ 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) {
@@ -44,7 +67,12 @@ void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents) {
PreviewsInfoBarDelegate::Create(
web_contents, PreviewsInfoBarDelegate::LOFI,
true /* is_data_saver_user */,
- PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
+ base::Bind(&AddPreviewNavigationToBlackListCallback,
+ web_contents->GetBrowserContext(),
+ web_contents->GetController()
+ .GetLastCommittedEntry()
+ ->GetRedirectChain()[0],
+ previews::PreviewsType::LOFI));
}
} // namespace
« no previous file with comments | « no previous file | chrome/browser/previews/previews_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698