Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 STATE_NOT_DEFAULT, | 160 STATE_NOT_DEFAULT, |
| 161 STATE_IS_DEFAULT, | 161 STATE_IS_DEFAULT, |
| 162 STATE_UNKNOWN | 162 STATE_UNKNOWN |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 class DefaultWebClientObserver { | 165 class DefaultWebClientObserver { |
| 166 public: | 166 public: |
| 167 virtual ~DefaultWebClientObserver() {} | 167 virtual ~DefaultWebClientObserver() {} |
| 168 // Updates the UI state to reflect the current default browser state. | 168 // Updates the UI state to reflect the current default browser state. |
| 169 virtual void SetDefaultWebClientUIState(DefaultWebClientUIState state) = 0; | 169 virtual void SetDefaultWebClientUIState(DefaultWebClientUIState state) = 0; |
| 170 // Called to notify the UI of the immediate result of invoking | |
| 171 // SetAsDefault. | |
| 172 virtual void OnSetAsDefaultConcluded(bool succeeded) { } | |
| 170 // Observer classes that return true to OwnedByWorker are automatically | 173 // Observer classes that return true to OwnedByWorker are automatically |
| 171 // freed by the worker when they are no longer needed. | 174 // freed by the worker when they are no longer needed. |
| 172 virtual bool IsOwnedByWorker() { return false; } | 175 virtual bool IsOwnedByWorker() { return false; } |
| 173 // An observer can permit or decline set-as-default operation if it | 176 // An observer can permit or decline set-as-default operation if it |
| 174 // requires triggering user interaction. | 177 // requires triggering user interaction. |
| 175 virtual bool IsInteractiveSetDefaultPermitted() { return false; } | 178 virtual bool IsInteractiveSetDefaultPermitted() { return false; } |
| 176 }; | 179 }; |
| 177 | 180 |
| 178 // Helper objects that handle checking if Chrome is the default browser | 181 // Helper objects that handle checking if Chrome is the default browser |
| 179 // or application for a url protocol on Windows and Linux, and also setting | 182 // or application for a url protocol on Windows and Linux, and also setting |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 201 protected: | 204 protected: |
| 202 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>; | 205 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>; |
| 203 | 206 |
| 204 virtual ~DefaultWebClientWorker() {} | 207 virtual ~DefaultWebClientWorker() {} |
| 205 | 208 |
| 206 private: | 209 private: |
| 207 // Function that performs the check. | 210 // Function that performs the check. |
| 208 virtual DefaultWebClientState CheckIsDefault() = 0; | 211 virtual DefaultWebClientState CheckIsDefault() = 0; |
| 209 | 212 |
| 210 // Function that sets Chrome as the default web client. | 213 // Function that sets Chrome as the default web client. |
| 211 virtual void SetAsDefault(bool interactive_permitted) = 0; | 214 virtual bool SetAsDefault(bool interactive_permitted) = 0; |
|
grt (UTC plus 2)
2012/06/20 19:42:12
document meaning of return value
motek.
2012/06/20 22:02:29
Done.
| |
| 212 | 215 |
| 213 // Function that handles performing the check on the file thread. This | 216 // Function that handles performing the check on the file thread. This |
| 214 // function is posted as a task onto the file thread, where it performs | 217 // function is posted as a task onto the file thread, where it performs |
| 215 // the check. When the check has finished the CompleteCheckIsDefault | 218 // the check. When the check has finished the CompleteCheckIsDefault |
| 216 // function is posted to the UI thread, where the result is sent back to | 219 // function is posted to the UI thread, where the result is sent back to |
| 217 // the observer. | 220 // the observer. |
| 218 void ExecuteCheckIsDefault(); | 221 void ExecuteCheckIsDefault(); |
| 219 | 222 |
| 220 // Function that handles setting Chrome as the default web client on the | 223 // Function that handles setting Chrome as the default web client on the |
| 221 // file thread. This function is posted as a task onto the file thread. | 224 // file thread. This function is posted as a task onto the file thread. |
| 222 // Once it is finished the CompleteSetAsDefault function is posted to the | 225 // Once it is finished the CompleteSetAsDefault function is posted to the |
| 223 // UI thread which will check the status of Chrome as the default, and | 226 // UI thread which will check the status of Chrome as the default, and |
| 224 // send this to the observer. | 227 // send this to the observer. |
| 225 void ExecuteSetAsDefault(); | 228 void ExecuteSetAsDefault(bool interactive_permitted); |
|
grt (UTC plus 2)
2012/06/20 19:42:12
document interactive_permitted
motek.
2012/06/20 22:02:29
Done.
| |
| 226 | 229 |
| 227 // Communicate results to the observer. This function is posted as a task | 230 // Communicate results to the observer. This function is posted as a task |
| 228 // onto the UI thread by the ExecuteCheckIsDefault function running in the | 231 // onto the UI thread by the ExecuteCheckIsDefault function running in the |
| 229 // file thread. | 232 // file thread. |
| 230 void CompleteCheckIsDefault(DefaultWebClientState state); | 233 void CompleteCheckIsDefault(DefaultWebClientState state); |
| 231 | 234 |
| 232 // When the action to set Chrome as the default has completed this function | 235 // When the action to set Chrome as the default has completed this function |
| 233 // is run. It is posted as a task back onto the UI thread by the | 236 // is run. It is posted as a task back onto the UI thread by the |
| 234 // ExecuteSetAsDefault function running in the file thread. This function | 237 // ExecuteSetAsDefault function running in the file thread. This function |
| 235 // will the start the check process, which, if an observer is present, | 238 // will the start the check process, which, if an observer is present, |
| 236 // reports to it the new status. | 239 // reports to it the new status. |
| 237 void CompleteSetAsDefault(); | 240 void CompleteSetAsDefault(bool call_result); |
|
grt (UTC plus 2)
2012/06/20 19:42:12
call_result -> succeeded?
also, document
motek.
2012/06/20 22:02:29
Done.
| |
| 238 | 241 |
| 239 // Updates the UI in our associated view with the current default web | 242 // Updates the UI in our associated view with the current default web |
| 240 // client state. | 243 // client state. |
| 241 void UpdateUI(DefaultWebClientState state); | 244 void UpdateUI(DefaultWebClientState state); |
| 242 | 245 |
| 243 DefaultWebClientObserver* observer_; | 246 DefaultWebClientObserver* observer_; |
| 244 | 247 |
| 245 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker); | 248 DISALLOW_COPY_AND_ASSIGN(DefaultWebClientWorker); |
| 246 }; | 249 }; |
| 247 | 250 |
| 248 // Worker for checking and setting the default browser. | 251 // Worker for checking and setting the default browser. |
| 249 class DefaultBrowserWorker : public DefaultWebClientWorker { | 252 class DefaultBrowserWorker : public DefaultWebClientWorker { |
| 250 public: | 253 public: |
| 251 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer); | 254 explicit DefaultBrowserWorker(DefaultWebClientObserver* observer); |
| 252 | 255 |
| 253 private: | 256 private: |
| 254 virtual ~DefaultBrowserWorker() {} | 257 virtual ~DefaultBrowserWorker() {} |
| 255 | 258 |
| 256 // Check if Chrome is the default browser. | 259 // Check if Chrome is the default browser. |
| 257 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; | 260 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; |
| 258 | 261 |
| 259 // Set Chrome as the default browser. | 262 // Set Chrome as the default browser. |
| 260 virtual void SetAsDefault(bool interactive_permitted) OVERRIDE; | 263 virtual bool SetAsDefault(bool interactive_permitted) OVERRIDE; |
| 261 | 264 |
| 262 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); | 265 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); |
| 263 }; | 266 }; |
| 264 | 267 |
| 265 // Worker for checking and setting the default client application | 268 // Worker for checking and setting the default client application |
| 266 // for a given protocol. A different worker instance is needed for each | 269 // for a given protocol. A different worker instance is needed for each |
| 267 // protocol you are interested in, so to check or set the default for | 270 // protocol you are interested in, so to check or set the default for |
| 268 // multiple protocols you should use multiple worker objects. | 271 // multiple protocols you should use multiple worker objects. |
| 269 class DefaultProtocolClientWorker : public DefaultWebClientWorker { | 272 class DefaultProtocolClientWorker : public DefaultWebClientWorker { |
| 270 public: | 273 public: |
| 271 DefaultProtocolClientWorker(DefaultWebClientObserver* observer, | 274 DefaultProtocolClientWorker(DefaultWebClientObserver* observer, |
| 272 const std::string& protocol); | 275 const std::string& protocol); |
| 273 | 276 |
| 274 const std::string& protocol() const { return protocol_; } | 277 const std::string& protocol() const { return protocol_; } |
| 275 | 278 |
| 276 protected: | 279 protected: |
| 277 virtual ~DefaultProtocolClientWorker() {} | 280 virtual ~DefaultProtocolClientWorker() {} |
| 278 | 281 |
| 279 private: | 282 private: |
| 280 // Check is Chrome is the default handler for this protocol. | 283 // Check is Chrome is the default handler for this protocol. |
| 281 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; | 284 virtual DefaultWebClientState CheckIsDefault() OVERRIDE; |
| 282 | 285 |
| 283 // Set Chrome as the default handler for this protocol. | 286 // Set Chrome as the default handler for this protocol. |
| 284 virtual void SetAsDefault(bool interactive_permitted) OVERRIDE; | 287 virtual bool SetAsDefault(bool interactive_permitted) OVERRIDE; |
| 285 | 288 |
| 286 std::string protocol_; | 289 std::string protocol_; |
| 287 | 290 |
| 288 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); | 291 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); |
| 289 }; | 292 }; |
| 290 }; | 293 }; |
| 291 | 294 |
| 292 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ | 295 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ |
| OLD | NEW |