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

Unified Diff: headless/public/headless_browser_context.h

Issue 2374063002: Headless: expose WebPreferences to embedder, add --hide-scrollbars. (Closed)
Patch Set: Address comments, add test. Created 4 years, 3 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 | « headless/lib/headless_browser_context_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/headless_browser_context.h
diff --git a/headless/public/headless_browser_context.h b/headless/public/headless_browser_context.h
index d041c0a3e923056a99c5421e013ee2730a40ffda..b779f6a38da1f8ea3748f5d2dd634a19cd7e3e55 100644
--- a/headless/public/headless_browser_context.h
+++ b/headless/public/headless_browser_context.h
@@ -11,7 +11,9 @@
#include <unordered_map>
#include <vector>
+#include "base/callback.h"
#include "base/optional.h"
+#include "content/public/common/web_preferences.h"
#include "headless/public/headless_export.h"
#include "headless/public/headless_web_contents.h"
#include "net/base/host_port_pair.h"
@@ -25,6 +27,10 @@ namespace headless {
class HeadlessBrowserImpl;
class HeadlessBrowserContextOptions;
+// Imported into headless namespace for
+// Builder::SetOverrideWebPreferencesCallback().
+using content::WebPreferences;
+
using ProtocolHandlerMap = std::unordered_map<
std::string,
std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>>;
@@ -97,6 +103,15 @@ class HEADLESS_EXPORT HeadlessBrowserContext::Builder {
Builder& EnableUnsafeNetworkAccessWithMojoBindings(
bool enable_http_and_https_if_mojo_used);
+ // Set a callback that is invoked to override WebPreferences for RenderViews
+ // created within this HeadlessBrowserContext. Called whenever the
+ // WebPreferences of a RenderView change. Executed on the browser main thread.
+ //
+ // WARNING: We cannot provide any guarantees about the stability of the
+ // exposed WebPreferences API, so use with care.
+ Builder& SetOverrideWebPreferencesCallback(
+ base::Callback<void(WebPreferences*)> callback);
+
// By default |HeadlessBrowserContext| inherits the following options from
// the browser instance. The methods below can be used to override these
// settings. See HeadlessBrowser::Options for their meaning.
« no previous file with comments | « headless/lib/headless_browser_context_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698