OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_BROWSER_INIT_H__ | 5 #ifndef CHROME_BROWSER_BROWSER_INIT_H__ |
6 #define CHROME_BROWSER_BROWSER_INIT_H__ | 6 #define CHROME_BROWSER_BROWSER_INIT_H__ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlwin.h> | 9 #include <atlwin.h> |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 28 matching lines...) Expand all Loading... |
39 public: | 39 public: |
40 explicit MessageWindow(const std::wstring& user_data_dir); | 40 explicit MessageWindow(const std::wstring& user_data_dir); |
41 ~MessageWindow(); | 41 ~MessageWindow(); |
42 | 42 |
43 // Returns true if another process was found and notified, false if we | 43 // Returns true if another process was found and notified, false if we |
44 // should continue with this process. Roughly based on Mozilla | 44 // should continue with this process. Roughly based on Mozilla |
45 // | 45 // |
46 // TODO(brettw): this will not handle all cases. If two process start up too | 46 // TODO(brettw): this will not handle all cases. If two process start up too |
47 // close to each other, the window might not have been created yet for the | 47 // close to each other, the window might not have been created yet for the |
48 // first one, so this function won't find it. | 48 // first one, so this function won't find it. |
49 bool NotifyOtherProcess(int show_cmd); | 49 bool NotifyOtherProcess(); |
50 | 50 |
51 // Create the toplevel message window for IPC. | 51 // Create the toplevel message window for IPC. |
52 void Create(); | 52 void Create(); |
53 | 53 |
54 // Blocks the dispatch of CopyData messages. | 54 // Blocks the dispatch of CopyData messages. |
55 void Lock() { | 55 void Lock() { |
56 locked_ = true; | 56 locked_ = true; |
57 } | 57 } |
58 | 58 |
59 // Allows the dispatch of CopyData messages. | 59 // Allows the dispatch of CopyData messages. |
(...skipping 30 matching lines...) Expand all Loading... |
90 }; | 90 }; |
91 | 91 |
92 // LaunchWithProfile --------------------------------------------------------- | 92 // LaunchWithProfile --------------------------------------------------------- |
93 // | 93 // |
94 // Assists launching the application and appending the initial tabs for a | 94 // Assists launching the application and appending the initial tabs for a |
95 // browser window. | 95 // browser window. |
96 | 96 |
97 class LaunchWithProfile { | 97 class LaunchWithProfile { |
98 public: | 98 public: |
99 LaunchWithProfile(const std::wstring& cur_dir, | 99 LaunchWithProfile(const std::wstring& cur_dir, |
100 const std::wstring& cmd_line, | 100 const std::wstring& cmd_line); |
101 int show_command); | |
102 ~LaunchWithProfile() { } | 101 ~LaunchWithProfile() { } |
103 | 102 |
104 // Creates the necessary windows for startup. Returns true on success, | 103 // Creates the necessary windows for startup. Returns true on success, |
105 // false on failure. process_startup is true if Chrome is just | 104 // false on failure. process_startup is true if Chrome is just |
106 // starting up. If process_startup is false, it indicates Chrome was | 105 // starting up. If process_startup is false, it indicates Chrome was |
107 // already running and the user wants to launch another instance. | 106 // already running and the user wants to launch another instance. |
108 bool Launch(Profile* profile, bool process_startup); | 107 bool Launch(Profile* profile, bool process_startup); |
109 | 108 |
110 private: | 109 private: |
111 // Creates a new tabbed browser. | |
112 // | |
113 // Note that the window returned by this function may not be visible yet. | |
114 Browser* CreateTabbedBrowser(); | |
115 | |
116 // Does the following: | 110 // Does the following: |
117 // . If the user's startup pref is to restore the last session (or the | 111 // . If the user's startup pref is to restore the last session (or the |
118 // command line flag is present to force using last session), it is | 112 // command line flag is present to force using last session), it is |
119 // restored, and true is returned. | 113 // restored, and true is returned. |
120 // . If the user's startup pref is to launch a specific set of URLs, and | 114 // . If the user's startup pref is to launch a specific set of URLs, and |
121 // urls_to_open is empty, the user specified set of URLs is openned. | 115 // urls_to_open is empty, the user specified set of URLs is openned. |
122 // | 116 // |
123 // Otherwise false is returned. | 117 // Otherwise false is returned. |
124 bool OpenStartupURLs(bool is_process_startup, | 118 bool OpenStartupURLs(bool is_process_startup, |
125 const CommandLine& command_line, | 119 const CommandLine& command_line, |
(...skipping 11 matching lines...) Expand all Loading... |
137 // an infobar is added allowing the user to restore the last session. | 131 // an infobar is added allowing the user to restore the last session. |
138 void AddCrashedInfoBarIfNecessary(TabContents* tab); | 132 void AddCrashedInfoBarIfNecessary(TabContents* tab); |
139 | 133 |
140 // Returns the list of URLs to open from the command line. The returned | 134 // Returns the list of URLs to open from the command line. The returned |
141 // vector is empty if the user didn't specify any URLs on the command line. | 135 // vector is empty if the user didn't specify any URLs on the command line. |
142 std::vector<GURL> GetURLsFromCommandLine(const CommandLine& command_line, | 136 std::vector<GURL> GetURLsFromCommandLine(const CommandLine& command_line, |
143 Profile* profile); | 137 Profile* profile); |
144 | 138 |
145 std::wstring cur_dir_; | 139 std::wstring cur_dir_; |
146 std::wstring command_line_; | 140 std::wstring command_line_; |
147 int show_command_; | |
148 Profile* profile_; | 141 Profile* profile_; |
149 | 142 |
150 // Bounds for the browser. | 143 // Bounds for the browser. |
151 gfx::Rect start_position_; | 144 gfx::Rect start_position_; |
152 | 145 |
153 DISALLOW_EVIL_CONSTRUCTORS(LaunchWithProfile); | 146 DISALLOW_EVIL_CONSTRUCTORS(LaunchWithProfile); |
154 }; | 147 }; |
155 | 148 |
156 // This function performs command-line handling and is invoked when | 149 // This function performs command-line handling and is invoked when |
157 // process starts as well as when we get a start request from another | 150 // process starts as well as when we get a start request from another |
158 // process (via the WM_COPYDATA message). The process_startup flag | 151 // process (via the WM_COPYDATA message). The process_startup flag |
159 // indicates if this is being called from the process startup code or | 152 // indicates if this is being called from the process startup code or |
160 // the WM_COPYDATA handler. | 153 // the WM_COPYDATA handler. |
161 static bool ProcessCommandLine(const CommandLine& parsed_command_line, | 154 static bool ProcessCommandLine(const CommandLine& parsed_command_line, |
162 const std::wstring& cur_dir, | 155 const std::wstring& cur_dir, |
163 PrefService* prefs, int show_command, | 156 PrefService* prefs, bool process_startup, |
164 bool process_startup, Profile* profile, | 157 Profile* profile, int* return_code); |
165 int* return_code); | |
166 | 158 |
167 // Helper function to launch a new browser based on command-line arguments | 159 // Helper function to launch a new browser based on command-line arguments |
168 // This function takes in a specific profile to use. | 160 // This function takes in a specific profile to use. |
169 static bool LaunchBrowser(const CommandLine& parsed_command_line, | 161 static bool LaunchBrowser(const CommandLine& parsed_command_line, |
170 Profile* profile, int show_command, | 162 Profile* profile, const std::wstring& cur_dir, |
171 const std::wstring& cur_dir, bool process_startup, | 163 bool process_startup, int* return_code); |
172 int* return_code); | |
173 | 164 |
174 template <class AutomationProviderClass> | 165 template <class AutomationProviderClass> |
175 static void CreateAutomationProvider(const std::wstring& channel_id, | 166 static void CreateAutomationProvider(const std::wstring& channel_id, |
176 Profile* profile, | 167 Profile* profile, |
177 size_t expected_tabs); | 168 size_t expected_tabs); |
178 | 169 |
179 private: | 170 private: |
180 // Does the work of LaunchBrowser returning the result. | 171 // Does the work of LaunchBrowser returning the result. |
181 static bool LaunchBrowserImpl(const CommandLine& parsed_command_line, | 172 static bool LaunchBrowserImpl(const CommandLine& parsed_command_line, |
182 Profile* profile, int show_command, | 173 Profile* profile, const std::wstring& cur_dir, |
183 const std::wstring& cur_dir, | |
184 bool process_startup, int* return_code); | 174 bool process_startup, int* return_code); |
185 | 175 |
186 // This class is for scoping purposes. | 176 // This class is for scoping purposes. |
187 BrowserInit(); | 177 BrowserInit(); |
188 DISALLOW_EVIL_CONSTRUCTORS(BrowserInit); | 178 DISALLOW_EVIL_CONSTRUCTORS(BrowserInit); |
189 }; | 179 }; |
190 | 180 |
191 #endif // CHROME_BROWSER_BROWSER_INIT_H__ | 181 #endif // CHROME_BROWSER_BROWSER_INIT_H__ |
192 | 182 |
OLD | NEW |