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

Side by Side Diff: mojo/shell/desktop/mojo_main.cc

Issue 731923002: Emit error if unknown switch is passed to mojo_shell (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove static Created 6 years, 1 month 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
« no previous file with comments | « no previous file | mojo/shell/switches.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 #include <iostream> 6 #include <iostream>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 } // namespace 100 } // namespace
101 101
102 int main(int argc, char** argv) { 102 int main(int argc, char** argv) {
103 base::AtExitManager at_exit; 103 base::AtExitManager at_exit;
104 base::CommandLine::Init(argc, argv); 104 base::CommandLine::Init(argc, argv);
105 105
106 const base::CommandLine& command_line = 106 const base::CommandLine& command_line =
107 *base::CommandLine::ForCurrentProcess(); 107 *base::CommandLine::ForCurrentProcess();
108 if (!command_line.HasSwitch(switches::kEnableExternalApplications) && 108
109 (command_line.HasSwitch(switches::kHelp) || 109 const std::set<std::string> all_switches = switches::GetAllSwitches();
110 command_line.GetArgs().empty())) { 110 const base::CommandLine::SwitchMap switches = command_line.GetSwitches();
111 bool found_unknown_switch = false;
112 for (const auto& s : switches) {
113 if (all_switches.find(s.first) == all_switches.end()) {
114 std::cerr << "unknown switch: " << s.first << std::endl;
115 found_unknown_switch = true;
116 }
117 }
118
119 if (found_unknown_switch ||
120 (!command_line.HasSwitch(switches::kEnableExternalApplications) &&
121 (command_line.HasSwitch(switches::kHelp) ||
122 command_line.GetArgs().empty()))) {
111 Usage(); 123 Usage();
112 return 0; 124 return 0;
113 } 125 }
114 126
115 #if defined(OS_LINUX) 127 #if defined(OS_LINUX)
116 // We use gfx::RenderText from multiple threads concurrently and the pango 128 // We use gfx::RenderText from multiple threads concurrently and the pango
117 // backend (currently the default on linux) is not close to threadsafe. Force 129 // backend (currently the default on linux) is not close to threadsafe. Force
118 // use of the harfbuzz backend for now. 130 // use of the harfbuzz backend for now.
119 base::CommandLine::ForCurrentProcess()->AppendSwitch( 131 base::CommandLine::ForCurrentProcess()->AppendSwitch(
120 kEnableHarfBuzzRenderText); 132 kEnableHarfBuzzRenderText);
(...skipping 24 matching lines...) Expand all
145 if (IsArgsFor(argv[i], &args_for_value)) 157 if (IsArgsFor(argv[i], &args_for_value))
146 GetAppURLAndSetArgs(args_for_value, &shell_context); 158 GetAppURLAndSetArgs(args_for_value, &shell_context);
147 } 159 }
148 160
149 message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context)); 161 message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context));
150 message_loop.Run(); 162 message_loop.Run();
151 } 163 }
152 } 164 }
153 return 0; 165 return 0;
154 } 166 }
OLDNEW
« no previous file with comments | « no previous file | mojo/shell/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698