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

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: fix indent Created 8 years, 9 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
« no previous file with comments | « chrome/common/chrome_content_client.cc ('k') | content/public/common/content_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
scherkus (not reviewing) 2012/03/08 01:03:49 note: previously the only implementation of GetUse
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 // XXXXXX we rely on delegates calling SetContentClient() at this point in
472 // time -- is this a fair assumption?
scherkus (not reviewing) 2012/03/08 01:03:49 this part concerns me -- any ideas?
jam 2012/03/08 01:07:58 sure tha'ts fine
473
474 // If a custom user agent was passed on the command line we need
475 // to set it now before webkit_glue::GetUserAgent() is called so that the
476 // UA doesn't change.
477 if (command_line.HasSwitch(switches::kUserAgent)) {
478 std::string ua = command_line.GetSwitchValueASCII(switches::kUserAgent);
479 webkit_glue::SetUserAgent(
480 command_line.GetSwitchValueASCII(switches::kUserAgent), true);
481 } else {
482 webkit_glue::SetUserAgent(
483 content::GetContentClient()->GetUserAgent(), false);
484 }
485
470 if (!process_type.empty()) 486 if (!process_type.empty())
471 CommonSubprocessInit(process_type); 487 CommonSubprocessInit(process_type);
472 488
473 #if defined(OS_WIN) 489 #if defined(OS_WIN)
474 CHECK(content::InitializeSandbox(sandbox_info)); 490 CHECK(content::InitializeSandbox(sandbox_info));
475 #elif defined(OS_MACOSX) 491 #elif defined(OS_MACOSX)
476 if (process_type == switches::kRendererProcess || 492 if (process_type == switches::kRendererProcess ||
477 process_type == switches::kPpapiPluginProcess || 493 process_type == switches::kPpapiPluginProcess ||
478 (delegate && delegate->DelaySandboxInitialization(process_type))) { 494 (delegate && delegate->DelaySandboxInitialization(process_type))) {
479 // On OS X the renderer sandbox needs to be initialized later in the 495 // 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 583 } // namespace
568 584
569 namespace content { 585 namespace content {
570 586
571 // static 587 // static
572 ContentMainRunner* ContentMainRunner::Create() { 588 ContentMainRunner* ContentMainRunner::Create() {
573 return new ContentMainRunnerImpl(); 589 return new ContentMainRunnerImpl();
574 } 590 }
575 591
576 } // namespace content 592 } // namespace content
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client.cc ('k') | content/public/common/content_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698