Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24dfcbc

Browse files
committed
Modify webkit preferences in content browser client.
1 parent 6e0302b commit 24dfcbc

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

src/shell_content_browser_client.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "content/nw/src/shell_browser_main_parts.h"
3535
#include "geolocation/shell_access_token_store.h"
3636
#include "googleurl/src/gurl.h"
37+
#include "webkit/glue/webpreferences.h"
3738

3839
namespace content {
3940

@@ -88,4 +89,20 @@ AccessTokenStore* ShellContentBrowserClient::CreateAccessTokenStore() {
8889
return new ShellAccessTokenStore(browser_context()->GetRequestContext());
8990
}
9091

92+
void ShellContentBrowserClient::OverrideWebkitPrefs(
93+
RenderViewHost* render_view_host,
94+
const GURL& url,
95+
webkit_glue::WebPreferences* prefs) {
96+
// Disable web security
97+
prefs->web_security_enabled = false;
98+
prefs->allow_file_access_from_file_urls = true;
99+
100+
// Disable plugins to speed up (TODO provide flag to enable them)
101+
prefs->plugins_enabled = false;
102+
prefs->java_enabled = false;
103+
104+
// No caches
105+
prefs->uses_page_cache = false;
106+
}
107+
91108
} // namespace content

src/shell_content_browser_client.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class ShellContentBrowserClient : public ContentBrowserClient {
2929
virtual void RenderProcessHostCreated(RenderProcessHost* host) OVERRIDE;
3030
virtual void ResourceDispatcherHostCreated() OVERRIDE;
3131
virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
32+
virtual void OverrideWebkitPrefs(
33+
RenderViewHost* render_view_host,
34+
const GURL& url,
35+
webkit_glue::WebPreferences* prefs) OVERRIDE;
3236
virtual std::string GetDefaultDownloadName() OVERRIDE;
3337
virtual MediaObserver* GetMediaObserver() OVERRIDE;
3438
virtual void BrowserURLHandlerCreated(BrowserURLHandler* handler) OVERRIDE;

src/shell_main_delegate.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,12 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
9999
logging::LogEventProvider::Initialize(kContentShellProviderName);
100100
#endif
101101

102-
// Disable web security
103-
CommandLine* command_line = CommandLine::ForCurrentProcess();
104-
command_line->AppendSwitch(switches::kAllowFileAccessFromFiles);
105-
command_line->AppendSwitch(switches::kDisableWebSecurity);
106-
107102
// Enforce single process
108-
command_line->AppendSwitch(switches::kSingleProcess);
103+
// command_line->AppendSwitch(switches::kSingleProcess);
109104

110105
// Fix navigator.language in single process mode
111106
std::string locale = l10n_util::GetApplicationLocale("en-US");
112-
command_line->AppendSwitchASCII(switches::kLang, locale);
107+
CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kLang, locale);
113108

114109
InitLogging();
115110

0 commit comments

Comments
 (0)