OLD | NEW |
| (Empty) |
1 // Copyright 2008-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #ifndef OMAHA_COMMON_GOOPDATE_COMMAND_LINE_VALIDATOR_H__ | |
17 #define OMAHA_COMMON_GOOPDATE_COMMAND_LINE_VALIDATOR_H__ | |
18 | |
19 #include <windows.h> | |
20 #include <atlstr.h> | |
21 | |
22 #include <map> | |
23 | |
24 #include "base/basictypes.h" | |
25 #include "base/scoped_ptr.h" | |
26 | |
27 namespace omaha { | |
28 | |
29 struct CommandLineArgs; | |
30 class CommandLineParser; | |
31 class CommandLineValidator; | |
32 | |
33 // Validates all of the command line permutations for googleupdate.exe. | |
34 class GoopdateCommandLineValidator { | |
35 public: | |
36 typedef HRESULT (GoopdateCommandLineValidator::*ScenarioHandler)(); | |
37 typedef std::map<CString, ScenarioHandler> MapScenarioHandlers; | |
38 typedef MapScenarioHandlers::iterator MapScenarioHandlersIter; | |
39 | |
40 GoopdateCommandLineValidator(); | |
41 ~GoopdateCommandLineValidator(); | |
42 | |
43 // Sets up the scenarios. | |
44 HRESULT Setup(); | |
45 | |
46 // Validates a pre-parsed parser against the scenarios and returns a | |
47 // CommandLineArgs structure filled in with the proper values. | |
48 HRESULT Validate(const CommandLineParser* parser, CommandLineArgs* args); | |
49 | |
50 private: | |
51 // Specific command-line scenario handlers. | |
52 HRESULT OnNoArgs(); | |
53 HRESULT OnCore(); | |
54 HRESULT OnCrashHandler(); | |
55 HRESULT OnService(); | |
56 HRESULT OnMediumService(); | |
57 HRESULT OnServiceRegister(); | |
58 HRESULT OnServiceUnregister(); | |
59 HRESULT OnRegServer(); | |
60 HRESULT OnUnregServer(); | |
61 HRESULT OnNetDiags(); | |
62 HRESULT OnCrash(); | |
63 HRESULT OnComServer(); | |
64 HRESULT OnComBroker(); | |
65 HRESULT OnDemand(); | |
66 HRESULT OnInstall(); | |
67 HRESULT OnUpdate(); | |
68 HRESULT OnInstallHandoffWorker(); | |
69 HRESULT OnUpdateApps(); | |
70 HRESULT OnReportCrash(); | |
71 HRESULT OnReportCrashInteractive(); | |
72 HRESULT OnWebPlugin(); | |
73 HRESULT OnCodeRed(); | |
74 HRESULT OnRecover(); | |
75 HRESULT OnRecoverMachine(); | |
76 HRESULT OnUninstall(); | |
77 HRESULT OnRegisterProduct(); | |
78 HRESULT OnUnregisterProduct(); | |
79 HRESULT OnPing(); | |
80 | |
81 void CreateScenario(const TCHAR* cmd_line, ScenarioHandler handler); | |
82 | |
83 HRESULT GetExtraAndAppArgs(const CString& switch_name); | |
84 | |
85 const CommandLineParser* parser_; | |
86 CommandLineArgs* args_; | |
87 scoped_ptr<CommandLineValidator> validator_; | |
88 MapScenarioHandlers scenario_handlers_; | |
89 | |
90 DISALLOW_EVIL_CONSTRUCTORS(GoopdateCommandLineValidator); | |
91 }; | |
92 | |
93 } // namespace omaha | |
94 | |
95 #endif // OMAHA_COMMON_GOOPDATE_COMMAND_LINE_VALIDATOR_H__ | |
96 | |
OLD | NEW |