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

Unified Diff: content/app/content_main_runner.cc

Issue 9623027: Move --user-agent overriding logic from chrome into content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: cleanup Created 8 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: content/app/content_main_runner.cc
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 8d360c37ed1a76610e6a72a1f03cae845b914760..3d363dccc4c8ceb3dc2fbff2003957f3fe86c09a 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -223,9 +223,10 @@ int RunZygote(const content::MainFunctionParams& main_function_params,
// If a custom user agent was passed on the command line, we need
// to (re)set it now, rather than using the default one the zygote
// initialized.
- bool custom = false;
- std::string ua = content::GetContentClient()->GetUserAgent(&custom);
- if (custom) webkit_glue::SetUserAgent(ua, custom);
+ if (command_line.HasSwitch(switches::kUserAgent)) {
+ webkit_glue::SetUserAgent(
+ command_line.GetSwitchValueASCII(switches::kUserAgent), true);
+ }
// The StatsTable must be initialized in each process; we already
// initialized for the browser process, now we need to initialize
@@ -467,6 +468,16 @@ class ContentMainRunnerImpl : public content::ContentMainRunner {
if (delegate)
delegate->PreSandboxStartup();
+ // Set any custom user agent passed on the command line now so the string
+ // doesn't change between calls to webkit_glue::GetUserAgent(), otherwise it
+ // defaults to the user agent set during SetContentClient().
+ DCHECK(content::GetContentClient())
+ << "SetContentClient() must be called by this point in time";
jam 2012/04/06 23:13:52 nit: are you sure this dcheck is necessary? ie. ha
scherkus (not reviewing) 2012/04/06 23:59:41 if the call to SetContentClient() happens after se
jam 2012/04/07 00:03:07 just to be clear, i meant if there's code in conte
+ if (command_line.HasSwitch(switches::kUserAgent)) {
+ webkit_glue::SetUserAgent(
+ command_line.GetSwitchValueASCII(switches::kUserAgent), true);
+ }
+
if (!process_type.empty())
CommonSubprocessInit(process_type);

Powered by Google App Engine
This is Rietveld 408576698