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

Side by Side 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: replace SetContentClient() with Initialize() 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 if (delegate) delegate->ZygoteForked(); 217 if (delegate) delegate->ZygoteForked();
218 218
219 // Zygote::HandleForkRequest may have reallocated the command 219 // Zygote::HandleForkRequest may have reallocated the command
220 // line so update it here with the new version. 220 // line so update it here with the new version.
221 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 221 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
222 222
223 // If a custom user agent was passed on the command line, we need 223 // If a custom user agent was passed on the command line, we need
224 // to (re)set it now, rather than using the default one the zygote 224 // to (re)set it now, rather than using the default one the zygote
225 // initialized. 225 // initialized.
226 bool custom = false; 226 if (command_line.HasSwitch(switches::kUserAgent)) {
227 std::string ua = content::GetContentClient()->GetUserAgent(&custom); 227 webkit_glue::SetUserAgent(
228 if (custom) webkit_glue::SetUserAgent(ua, custom); 228 command_line.GetSwitchValueASCII(switches::kUserAgent), true);
229 }
229 230
230 // The StatsTable must be initialized in each process; we already 231 // The StatsTable must be initialized in each process; we already
231 // initialized for the browser process, now we need to initialize 232 // initialized for the browser process, now we need to initialize
232 // within the new processes as well. 233 // within the new processes as well.
233 pid_t browser_pid = base::GetParentProcessId( 234 pid_t browser_pid = base::GetParentProcessId(
234 base::GetParentProcessId(base::GetCurrentProcId())); 235 base::GetParentProcessId(base::GetCurrentProcId()));
235 InitializeStatsTable(browser_pid, command_line); 236 InitializeStatsTable(browser_pid, command_line);
236 237
237 content::MainFunctionParams main_params(command_line); 238 content::MainFunctionParams main_params(command_line);
238 239
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // On linux, we're in the zygote here; so we need the parent process' id. 461 // On linux, we're in the zygote here; so we need the parent process' id.
461 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); 462 browser_pid = base::GetParentProcessId(base::GetCurrentProcId());
462 #endif 463 #endif
463 } 464 }
464 465
465 InitializeStatsTable(browser_pid, command_line); 466 InitializeStatsTable(browser_pid, command_line);
466 467
467 if (delegate) 468 if (delegate)
468 delegate->PreSandboxStartup(); 469 delegate->PreSandboxStartup();
469 470
471 // If a custom user agent was passed on the command line we need
472 // to set it now before webkit_glue::GetUserAgent() is called so that the
473 // UA doesn't change.
474 if (command_line.HasSwitch(switches::kUserAgent)) {
475 std::string ua = command_line.GetSwitchValueASCII(switches::kUserAgent);
476 webkit_glue::SetUserAgent(
477 command_line.GetSwitchValueASCII(switches::kUserAgent), true);
478 }
479
470 if (!process_type.empty()) 480 if (!process_type.empty())
471 CommonSubprocessInit(process_type); 481 CommonSubprocessInit(process_type);
472 482
473 #if defined(OS_WIN) 483 #if defined(OS_WIN)
474 CHECK(content::InitializeSandbox(sandbox_info)); 484 CHECK(content::InitializeSandbox(sandbox_info));
475 #elif defined(OS_MACOSX) 485 #elif defined(OS_MACOSX)
476 if (process_type == switches::kRendererProcess || 486 if (process_type == switches::kRendererProcess ||
477 process_type == switches::kPpapiPluginProcess || 487 process_type == switches::kPpapiPluginProcess ||
478 (delegate && delegate->DelaySandboxInitialization(process_type))) { 488 (delegate && delegate->DelaySandboxInitialization(process_type))) {
479 // On OS X the renderer sandbox needs to be initialized later in the 489 // On OS X the renderer sandbox needs to be initialized later in the
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } // namespace 577 } // namespace
568 578
569 namespace content { 579 namespace content {
570 580
571 // static 581 // static
572 ContentMainRunner* ContentMainRunner::Create() { 582 ContentMainRunner* ContentMainRunner::Create() {
573 return new ContentMainRunnerImpl(); 583 return new ContentMainRunnerImpl();
574 } 584 }
575 585
576 } // namespace content 586 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698