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

Side by Side Diff: chrome/browser/shell_integration.h

Issue 10539169: Prototype version of the first-run dialog for Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed non-windows compilation errors. Created 8 years, 6 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
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 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_H_ 5 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_H_
6 #define CHROME_BROWSER_SHELL_INTEGRATION_H_ 6 #define CHROME_BROWSER_SHELL_INTEGRATION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // querying if Chrome is the default browser or the default handler 151 // querying if Chrome is the default browser or the default handler
152 // application for a url protocol, and communicates the state and result of 152 // application for a url protocol, and communicates the state and result of
153 // a request. 153 // a request.
154 enum DefaultWebClientUIState { 154 enum DefaultWebClientUIState {
155 STATE_PROCESSING, 155 STATE_PROCESSING,
156 STATE_NOT_DEFAULT, 156 STATE_NOT_DEFAULT,
157 STATE_IS_DEFAULT, 157 STATE_IS_DEFAULT,
158 STATE_UNKNOWN 158 STATE_UNKNOWN
159 }; 159 };
160 160
161 enum SetDefaultWebClientResult {
grt (UTC plus 2) 2012/06/18 19:19:13 Please document this.
motek. 2012/06/19 18:06:44 Done.
162 RESULT_SET_DEFAULT_OK,
163 RESULT_SET_DEFAULT_FAILED_OR_CANCELLED,
164 RESULT_SET_DEFAULT_UNDEFINED,
165 };
166
161 class DefaultWebClientObserver { 167 class DefaultWebClientObserver {
162 public: 168 public:
163 virtual ~DefaultWebClientObserver() {} 169 virtual ~DefaultWebClientObserver() {}
164 // Updates the UI state to reflect the current default browser state. 170 // Updates the UI state to reflect the current default browser state.
165 virtual void SetDefaultWebClientUIState(DefaultWebClientUIState state) = 0; 171 virtual void SetDefaultWebClientUIState(
grt (UTC plus 2) 2012/06/18 19:19:13 i don't really like this as-is, since it confuses
motek. 2012/06/19 18:06:44 I did consider a similar idea. The trouble is that
grt (UTC plus 2) 2012/06/19 20:43:09 I was interpreting "state" in the sense of a FSM.
172 DefaultWebClientUIState state,
173 SetDefaultWebClientResult call_result) = 0;
166 // Observer classes that return true to OwnedByWorker are automatically 174 // Observer classes that return true to OwnedByWorker are automatically
167 // freed by the worker when they are no longer needed. 175 // freed by the worker when they are no longer needed.
168 virtual bool IsOwnedByWorker() { return false; } 176 virtual bool IsOwnedByWorker() { return false; }
169 // An observer can permit or decline set-as-default operation if it 177 // An observer can permit or decline set-as-default operation if it
170 // requires triggering user interaction. 178 // requires triggering user interaction.
171 virtual bool IsInteractiveSetDefaultPermitted() { return false; } 179 virtual bool IsInteractiveSetDefaultPermitted() { return false; }
172 }; 180 };
173 181
174 // Helper objects that handle checking if Chrome is the default browser 182 // Helper objects that handle checking if Chrome is the default browser
175 // or application for a url protocol on Windows and Linux, and also setting 183 // or application for a url protocol on Windows and Linux, and also setting
(...skipping 21 matching lines...) Expand all
197 protected: 205 protected:
198 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>; 206 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>;
199 207
200 virtual ~DefaultWebClientWorker() {} 208 virtual ~DefaultWebClientWorker() {}
201 209
202 private: 210 private:
203 // Function that performs the check. 211 // Function that performs the check.
204 virtual DefaultWebClientState CheckIsDefault() = 0; 212 virtual DefaultWebClientState CheckIsDefault() = 0;
205 213
206 // Function that sets Chrome as the default web client. 214 // Function that sets Chrome as the default web client.
207 virtual void SetAsDefault(bool interactive_permitted) = 0; 215 virtual SetDefaultWebClientResult SetAsDefault(
216 bool interactive_permitted) = 0;
217
218 // Private version takes a call result to be eventually forwarded to the
219 // observer.
220 void StartCheckIsDefault(SetDefaultWebClientResult call_result);
208 221
209 // Function that handles performing the check on the file thread. This 222 // Function that handles performing the check on the file thread. This
210 // function is posted as a task onto the file thread, where it performs 223 // function is posted as a task onto the file thread, where it performs
211 // the check. When the check has finished the CompleteCheckIsDefault 224 // the check. When the check has finished the CompleteCheckIsDefault
212 // function is posted to the UI thread, where the result is sent back to 225 // function is posted to the UI thread, where the result is sent back to
213 // the observer. 226 // the observer.
214 void ExecuteCheckIsDefault(); 227 void ExecuteCheckIsDefault(SetDefaultWebClientResult call_result);
215 228
216 // Function that handles setting Chrome as the default web client on the 229 // Function that handles setting Chrome as the default web client on the
217 // file thread. This function is posted as a task onto the file thread. 230 // file thread. This function is posted as a task onto the file thread.
218 // Once it is finished the CompleteSetAsDefault function is posted to the 231 // Once it is finished the CompleteSetAsDefault function is posted to the
219 // UI thread which will check the status of Chrome as the default, and 232 // UI thread which will check the status of Chrome as the default, and
220 // send this to the observer. 233 // send this to the observer.
221 void ExecuteSetAsDefault(); 234 void ExecuteSetAsDefault();
222 235
223 // Communicate results to the observer. This function is posted as a task 236 // Communicate results to the observer. This function is posted as a task
224 // onto the UI thread by the ExecuteCheckIsDefault function running in the 237 // onto the UI thread by the ExecuteCheckIsDefault function running in the
225 // file thread. 238 // file thread.
226 void CompleteCheckIsDefault(DefaultWebClientState state); 239 void CompleteCheckIsDefault(DefaultWebClientState state,
240 SetDefaultWebClientResult call_result);
227 241
228 // When the action to set Chrome as the default has completed this function 242 // When the action to set Chrome as the default has completed this function
229 // is run. It is posted as a task back onto the UI thread by the 243 // is run. It is posted as a task back onto the UI thread by the
230 // ExecuteSetAsDefault function running in the file thread. This function 244 // ExecuteSetAsDefault function running in the file thread. This function
231 // will the start the check process, which, if an observer is present, 245 // will the start the check process, which, if an observer is present,
232 // reports to it the new status. 246 // reports to it the new status.
233 void CompleteSetAsDefault(); 247 void CompleteSetAsDefault(SetDefaultWebClientResult call_result);
234 248
235 // Updates the UI in our associated view with the current default web 249 // Updates the UI in our associated view with the current default web
236 // client state. 250 // client state.
237 void UpdateUI(DefaultWebClientState state); 251 void UpdateUI(DefaultWebClientState state,
252 SetDefaultWebClientResult call_result);
238 253
239 DefaultWebClientObserver* observer_; 254 DefaultWebClientObserver* observer_;
240 255
241 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker); 256 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker);
242 }; 257 };
243 258
244 // Worker for checking and setting the default browser. 259 // Worker for checking and setting the default browser.
245 class DefaultBrowserWorker : public DefaultWebClientWorker { 260 class DefaultBrowserWorker : public DefaultWebClientWorker {
246 public: 261 public:
247 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer); 262 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer);
248 263
249 private: 264 private:
250 virtual ~DefaultBrowserWorker() {} 265 virtual ~DefaultBrowserWorker() {}
251 266
252 // Check if Chrome is the default browser. 267 // Check if Chrome is the default browser.
253 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; 268 virtual DefaultWebClientState CheckIsDefault() OVERRIDE;
254 269
255 // Set Chrome as the default browser. 270 // Set Chrome as the default browser.
256 virtual void SetAsDefault(bool interactive_permitted) OVERRIDE; 271 virtual SetDefaultWebClientResult SetAsDefault(
272 bool interactive_permitted) OVERRIDE;
257 273
258 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); 274 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
259 }; 275 };
260 276
261 // Worker for checking and setting the default client application 277 // Worker for checking and setting the default client application
262 // for a given protocol. A different worker instance is needed for each 278 // for a given protocol. A different worker instance is needed for each
263 // protocol you are interested in, so to check or set the default for 279 // protocol you are interested in, so to check or set the default for
264 // multiple protocols you should use multiple worker objects. 280 // multiple protocols you should use multiple worker objects.
265 class DefaultProtocolClientWorker : public DefaultWebClientWorker { 281 class DefaultProtocolClientWorker : public DefaultWebClientWorker {
266 public: 282 public:
267 DefaultProtocolClientWorker(DefaultWebClientObserver* observer, 283 DefaultProtocolClientWorker(DefaultWebClientObserver* observer,
268 const std::string& protocol); 284 const std::string& protocol);
269 285
270 const std::string& protocol() const { return protocol_; } 286 const std::string& protocol() const { return protocol_; }
271 287
272 protected: 288 protected:
273 virtual ~DefaultProtocolClientWorker() {} 289 virtual ~DefaultProtocolClientWorker() {}
274 290
275 private: 291 private:
276 // Check is Chrome is the default handler for this protocol. 292 // Check is Chrome is the default handler for this protocol.
277 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; 293 virtual DefaultWebClientState CheckIsDefault() OVERRIDE;
278 294
279 // Set Chrome as the default handler for this protocol. 295 // Set Chrome as the default handler for this protocol.
280 virtual void SetAsDefault(bool interactive_permitted) OVERRIDE; 296 virtual SetDefaultWebClientResult SetAsDefault(
297 bool interactive_permitted) OVERRIDE;
281 298
282 std::string protocol_; 299 std::string protocol_;
283 300
284 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); 301 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker);
285 }; 302 };
286 }; 303 };
287 304
288 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ 305 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698