Skip to content

Commit

Permalink
Make callers of CommandLine use it via the base:: namespace.
Browse files Browse the repository at this point in the history
Covers courgette/, dbus/, device/, extensions/, gin/, google_apis/, and gpu/.

BUG=422426
TEST=none
TBR=ben@chromium.org

Review URL: https://codereview.chromium.org/819193002

Cr-Commit-Position: refs/heads/master@{#309490}
  • Loading branch information
avi authored and Commit bot committed Dec 22, 2014
1 parent fdb146c commit 9ab0372
Show file tree
Hide file tree
Showing 57 changed files with 129 additions and 119 deletions.
7 changes: 4 additions & 3 deletions courgette/courgette_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,9 @@ void ApplyBSDiffPatch(const base::FilePath& old_file,

int main(int argc, const char* argv[]) {
base::AtExitManager at_exit_manager;
CommandLine::Init(argc, argv);
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
base::CommandLine::Init(argc, argv);
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();

logging::LoggingSettings settings;
settings.logging_dest = logging::LOG_TO_ALL;
Expand All @@ -447,7 +448,7 @@ int main(int argc, const char* argv[]) {
bool cmd_spread_1_unadjusted = command_line.HasSwitch("gen1u");

std::vector<base::FilePath> values;
const CommandLine::StringVector& args = command_line.GetArgs();
const base::CommandLine::StringVector& args = command_line.GetArgs();
for (size_t i = 0; i < args.size(); ++i) {
values.push_back(base::FilePath(args[i]));
}
Expand Down
2 changes: 1 addition & 1 deletion dbus/test_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

int main(int argc, char** argv) {
base::AtExitManager exit_manager;
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
TestTimeouts::Initialize();

base::Thread* dbus_thread = new base::Thread("D-Bus Thread");
Expand Down
2 changes: 1 addition & 1 deletion device/test/usb_test_gadget_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class UsbTestGadgetImpl : public UsbTestGadget {
} // namespace

bool UsbTestGadget::IsTestEnabled() {
base::CommandLine* command_line = CommandLine::ForCurrentProcess();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
return command_line->HasSwitch(kCommandLineSwitch);
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/api/app_window/app_window_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ AppWindow::Frame AppWindowCreateFunction::GetFrameFromString(
if (frame_string == kHtmlFrameOption &&
(extension()->permissions_data()->HasAPIPermission(
APIPermission::kExperimental) ||
CommandLine::ForCurrentProcess()->HasSwitch(
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExperimentalExtensionApis))) {
inject_html_titlebar_ = true;
return AppWindow::FRAME_NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BluetoothPrivateApiTest : public ExtensionApiTest {
~BluetoothPrivateApiTest() override {}

void SetUpOnMainThread() override {
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kWhitelistedExtensionID, kTestExtensionId);
mock_adapter_ = new NiceMock<MockBluetoothAdapter>();
event_router()->SetAdapterForTest(mock_adapter_.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CastChannelAPITest : public ExtensionApiTest {
public:
CastChannelAPITest() : ip_endpoint_(CreateIPEndPointForTest()) {}

void SetUpCommandLine(CommandLine* command_line) override {
void SetUpCommandLine(base::CommandLine* command_line) override {
ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(
extensions::switches::kWhitelistedExtensionID,
Expand Down
2 changes: 1 addition & 1 deletion extensions/browser/api/test/test_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace WaitForRoundTrip = core_api::test::WaitForRoundTrip;
TestExtensionFunction::~TestExtensionFunction() {}

bool TestExtensionFunction::RunSync() {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) {
error_ = kNotTestProcessError;
return false;
}
Expand Down
9 changes: 5 additions & 4 deletions extensions/browser/app_window/app_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void AppWindow::Init(const GURL& url,
// Initialize the render interface and web contents
app_window_contents_.reset(app_window_contents);
app_window_contents_->Initialize(browser_context(), url);
if (CommandLine::ForCurrentProcess()->HasSwitch(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAppsShowOnFirstPaint)) {
content::WebContentsObserver::Observe(web_contents());
}
Expand Down Expand Up @@ -334,7 +334,7 @@ void AppWindow::Init(const GURL& url,

app_window_contents_->LoadContents(new_params.creator_process_id);

if (CommandLine::ForCurrentProcess()->HasSwitch(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
extensions::switches::kEnableAppsShowOnFirstPaint)) {
// We want to show the window only when the content has been painted. For
// that to happen, we need to define a size for the content, otherwise the
Expand Down Expand Up @@ -659,7 +659,7 @@ void AppWindow::Show(ShowType show_type) {
bool was_hidden = is_hidden_ || !has_been_shown_;
is_hidden_ = false;

if (CommandLine::ForCurrentProcess()->HasSwitch(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAppsShowOnFirstPaint)) {
show_on_first_paint_ = true;

Expand Down Expand Up @@ -882,7 +882,8 @@ void AppWindow::SendOnWindowShownIfShown() {
if (!can_send_events_ || !has_been_shown_)
return;

if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kTestType)) {
app_window_contents_->DispatchWindowShownForTests();
}
}
Expand Down
3 changes: 2 additions & 1 deletion extensions/browser/extension_prefs_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ KeyedService* ExtensionPrefsFactory::BuildServiceInstanceFor(
context->GetPath().AppendASCII(extensions::kInstallDirectoryName),
ExtensionPrefValueMapFactory::GetForBrowserContext(context),
client->CreateAppSorting().Pass(),
client->AreExtensionsDisabled(*CommandLine::ForCurrentProcess(), context),
client->AreExtensionsDisabled(*base::CommandLine::ForCurrentProcess(),
context),
prefs_observers);
}

Expand Down
4 changes: 2 additions & 2 deletions extensions/common/extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ bool Extension::ShouldNotBeVisible() const {
// Don't show component extensions because they are only extensions as an
// implementation detail of Chrome.
if (extensions::Manifest::IsComponentLocation(location()) &&
!CommandLine::ForCurrentProcess()->HasSwitch(
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kShowComponentExtensionOptions)) {
return true;
}
Expand Down Expand Up @@ -714,7 +714,7 @@ bool Extension::LoadManifestVersion(base::string16* error) {
manifest_version_ = manifest_->GetManifestVersion();
if (manifest_version_ < kModernManifestVersion &&
((creation_flags_ & REQUIRE_MODERN_MANIFEST_VERSION &&
!CommandLine::ForCurrentProcess()->HasSwitch(
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAllowLegacyExtensionManifests)) ||
GetType() == Manifest::TYPE_PLATFORM_APP)) {
*error = ErrorUtils::FormatErrorMessageUTF16(
Expand Down
6 changes: 3 additions & 3 deletions extensions/common/feature_switch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ FeatureSwitch::ScopedOverride::~ScopedOverride() {

FeatureSwitch::FeatureSwitch(const char* switch_name,
DefaultValue default_value) {
Init(CommandLine::ForCurrentProcess(), switch_name, default_value);
Init(base::CommandLine::ForCurrentProcess(), switch_name, default_value);
}

FeatureSwitch::FeatureSwitch(const CommandLine* command_line,
FeatureSwitch::FeatureSwitch(const base::CommandLine* command_line,
const char* switch_name,
DefaultValue default_value) {
Init(command_line, switch_name, default_value);
}

void FeatureSwitch::Init(const CommandLine* command_line,
void FeatureSwitch::Init(const base::CommandLine* command_line,
const char* switch_name,
DefaultValue default_value) {
command_line_ = command_line;
Expand Down
4 changes: 2 additions & 2 deletions extensions/common/features/simple_feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ Feature::Availability SimpleFeature::IsAvailableToManifest(
if (!IsIdInWhitelist(extension_id)) {
// TODO(aa): This is gross. There should be a better way to test the
// whitelist.
CommandLine* command_line = CommandLine::ForCurrentProcess();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kWhitelistedExtensionID))
return CreateAvailability(NOT_FOUND_IN_WHITELIST, type);

std::string whitelist_switch_value =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kWhitelistedExtensionID);
if (extension_id != whitelist_switch_value)
return CreateAvailability(NOT_FOUND_IN_WHITELIST, type);
Expand Down
4 changes: 2 additions & 2 deletions extensions/common/manifest_handlers/background_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ bool BackgroundInfo::LoadBackgroundPage(const Extension* extension,
}

if (!(background_url_.SchemeIs("https") ||
(CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAllowHTTPBackgroundPage) &&
(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAllowHTTPBackgroundPage) &&
background_url_.SchemeIs("http")))) {
*error = ASCIIToUTF16(errors::kInvalidBackgroundInHostedApp);
return false;
Expand Down
2 changes: 1 addition & 1 deletion extensions/common/manifest_handlers/permissions_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool CanSpecifyHostPermission(const Extension* extension,
if (PermissionsData::CanExecuteScriptEverywhere(extension))
return true;

if (CommandLine::ForCurrentProcess()->HasSwitch(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kExtensionsOnChromeURLs)) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/common/user_script.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ int UserScript::ValidUserScriptSchemes(bool canExecuteScriptEverywhere) {
if (canExecuteScriptEverywhere)
return URLPattern::SCHEME_ALL;
int valid_schemes = kValidUserScriptSchemes;
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kExtensionsOnChromeURLs)) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kExtensionsOnChromeURLs)) {
valid_schemes &= ~URLPattern::SCHEME_CHROMEUI;
}
return valid_schemes;
Expand Down
4 changes: 2 additions & 2 deletions extensions/renderer/app_window_custom_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ void AppWindowCustomBindings::GetWindowControlsHtmlTemplate(
CHECK_EQ(args.Length(), 0);

v8::Handle<v8::Value> result = v8::String::Empty(args.GetIsolate());
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAppWindowControls)) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAppWindowControls)) {
base::StringValue value(
ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_WINDOW_CONTROLS_TEMPLATE_HTML)
Expand Down
5 changes: 3 additions & 2 deletions extensions/renderer/dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate)
is_webkit_initialized_(false),
user_script_set_manager_observer_(this),
webrequest_used_(false) {
const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
const base::CommandLine& command_line =
*(base::CommandLine::ForCurrentProcess());
is_extension_process_ =
command_line.HasSwitch(switches::kExtensionProcess) ||
command_line.HasSwitch(::switches::kSingleProcess);
Expand Down Expand Up @@ -1148,7 +1149,7 @@ void Dispatcher::UpdateBindingsForContext(ScriptContext* context) {

// Skip chrome.test if this isn't a test.
if (api_name == "test" &&
!CommandLine::ForCurrentProcess()->HasSwitch(
!base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kTestType)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/renderer/process_info_native_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void ProcessInfoNativeHandler::IsSendRequestDisabled(
void ProcessInfoNativeHandler::HasSwitch(
const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(args.Length() == 1 && args[0]->IsString());
bool has_switch = CommandLine::ForCurrentProcess()->HasSwitch(
bool has_switch = base::CommandLine::ForCurrentProcess()->HasSwitch(
*v8::String::Utf8Value(args[0]));
args.GetReturnValue().Set(v8::Boolean::New(args.GetIsolate(), has_switch));
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/shell/app/shell_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {

void ShellMainDelegate::PreSandboxStartup() {
std::string process_type =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
if (ProcessNeedsResourceBundle(process_type))
InitializeResourceBundle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ void DefaultShellBrowserMainDelegate::Start(
ExtensionSystem::Get(browser_context));
extension_system->Init();

CommandLine::StringType path_list =
base::CommandLine::StringType path_list =
command_line->GetSwitchValueNative(switches::kLoadApps);

base::StringTokenizerT<CommandLine::StringType,
CommandLine::StringType::const_iterator>
base::StringTokenizerT<base::CommandLine::StringType,
base::CommandLine::StringType::const_iterator>
tokenizer(path_list, FILE_PATH_LITERAL(","));


std::string launch_id;
while (tokenizer.GetNext()) {
base::FilePath app_absolute_dir =
Expand Down
4 changes: 2 additions & 2 deletions extensions/shell/browser/shell_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void ShellBrowserMainParts::PostMainMessageLoopStart() {

chromeos::NetworkHandler::Initialize();
network_controller_.reset(new ShellNetworkController(
CommandLine::ForCurrentProcess()->GetSwitchValueNative(
base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kAppShellPreferredNetwork)));
#else
// Non-Chrome OS platforms are for developer convenience, so use a test IME.
Expand Down Expand Up @@ -185,7 +185,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
browser_context_.get());

// Initialize OAuth2 support from command line.
CommandLine* cmd = CommandLine::ForCurrentProcess();
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
oauth2_token_service_.reset(new ShellOAuth2TokenService(
browser_context_.get(),
cmd->GetSwitchValueASCII(switches::kAppShellUser),
Expand Down
9 changes: 4 additions & 5 deletions extensions/shell/browser/shell_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void ShellContentBrowserClient::SiteInstanceDeleting(
}

void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
CommandLine* command_line,
base::CommandLine* command_line,
int child_process_id) {
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
Expand Down Expand Up @@ -235,7 +235,7 @@ ShellBrowserMainParts* ShellContentBrowserClient::CreateShellBrowserMainParts(
}

void ShellContentBrowserClient::AppendRendererSwitches(
CommandLine* command_line) {
base::CommandLine* command_line) {
// TODO(jamescook): Should we check here if the process is in the extension
// service process map, or can we assume all renderers are extension
// renderers?
Expand All @@ -247,9 +247,8 @@ void ShellContentBrowserClient::AppendRendererSwitches(
static const char* const kSwitchNames[] = {
::switches::kEnableNaClDebug,
};
command_line->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
kSwitchNames,
arraysize(kSwitchNames));
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kSwitchNames, arraysize(kSwitchNames));
#endif // !defined(DISABLE_NACL)
}

Expand Down
7 changes: 4 additions & 3 deletions gin/shell/gin_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class GinShellRunnerDelegate : public ModuleRunnerDelegate {

int main(int argc, char** argv) {
base::AtExitManager at_exit;
CommandLine::Init(argc, argv);
base::CommandLine::Init(argc, argv);
base::i18n::InitializeICU();
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
gin::IsolateHolder::LoadV8Snapshot();
Expand All @@ -77,8 +77,9 @@ int main(int argc, char** argv) {
v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
}

CommandLine::StringVector args = CommandLine::ForCurrentProcess()->GetArgs();
for (CommandLine::StringVector::const_iterator it = args.begin();
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
for (base::CommandLine::StringVector::const_iterator it = args.begin();
it != args.end(); ++it) {
base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
gin::Run, runner.GetWeakPtr(), base::FilePath(*it)));
Expand Down
2 changes: 1 addition & 1 deletion gin/shell/gin_shell_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TEST(GinShellTest, HelloWorld) {
ASSERT_TRUE(base::PathExists(gin_shell_path));
ASSERT_TRUE(base::PathExists(hello_world_path));

CommandLine cmd(gin_shell_path);
base::CommandLine cmd(gin_shell_path);
cmd.AppendArgPath(hello_world_path);
std::string output;
ASSERT_TRUE(base::GetAppOutput(cmd, &output));
Expand Down
2 changes: 1 addition & 1 deletion google_apis/gaia/gaia_urls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const char kOAuthUserInfoUrlSuffix[] = "oauth2/v1/userinfo";
void GetSwitchValueWithDefault(const char* switch_value,
const char* default_value,
std::string* output_value) {
CommandLine* command_line = CommandLine::ForCurrentProcess();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switch_value)) {
*output_value = command_line->GetSwitchValueASCII(switch_value);
} else {
Expand Down
Loading

0 comments on commit 9ab0372

Please sign in to comment.