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

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

Issue 1770943005: Removed AttemptResult enum in favor of using DefaultWebClientState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dont_record_async_duration
Patch Set: Rebase Created 4 years, 9 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
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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void StartCheckIsDefault(); 200 void StartCheckIsDefault();
201 201
202 // Sets Chrome as the default web client application. Once done, it will 202 // Sets Chrome as the default web client application. Once done, it will
203 // trigger a check for the default state using StartCheckIsDefault() to return 203 // trigger a check for the default state using StartCheckIsDefault() to return
204 // the default state to the caller. 204 // the default state to the caller.
205 void StartSetAsDefault(); 205 void StartSetAsDefault();
206 206
207 protected: 207 protected:
208 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>; 208 friend class base::RefCountedThreadSafe<DefaultWebClientWorker>;
209 209
210 // Possible result codes for a set-as-default operation.
211 // Do not modify the ordering as it is important for UMA.
212 enum AttemptResult {
213 // Chrome was set as the default web client.
214 SUCCESS = 0,
215 // Chrome was already the default web client. This counts as a successful
216 // attempt.
217 // Note: This result is no longer used since the removal of the Win10
218 // default browser experiment.
219 // ALREADY_DEFAULT = 1,
220 // Chrome was not set as the default web client.
221 FAILURE = 2,
222 // The attempt was abandoned because the observer was destroyed.
223 // Note: This result is no longer used since the removal of
224 // DefaultWebClientObserver.
225 // ABANDONED = 3,
226 // Failed to launch the process to set Chrome as the default web client
227 // asynchronously.
228 // Note: This result is no longer used since the removal of the Win10
229 // default browser experiment.
230 // LAUNCH_FAILURE = 4,
231 // Another worker is already in progress to make Chrome the default web
232 // client.
233 // Note: This result is no longer used since the removal of the Win10
234 // default browser experiment.
235 // OTHER_WORKER = 5,
236 // The user initiated another attempt while the asynchronous operation was
237 // already in progress.
238 RETRY = 6,
239 // No errors were encountered yet Chrome is still not the default web
240 // client.
241 NO_ERRORS_NOT_DEFAULT = 7,
242 NUM_ATTEMPT_RESULT_TYPES
243 };
244
245 DefaultWebClientWorker(const DefaultWebClientWorkerCallback& callback, 210 DefaultWebClientWorker(const DefaultWebClientWorkerCallback& callback,
246 const char* worker_name); 211 const char* worker_name);
247 virtual ~DefaultWebClientWorker(); 212 virtual ~DefaultWebClientWorker();
248 213
249 // Communicates the result via the |callback_|. In contrast to 214 // Communicates the result via the |callback_|. When
250 // OnSetAsDefaultAttemptComplete(), this should not be called multiple 215 // |is_following_set_as_default| is true, |state| will be reported to UMA as
251 // times. 216 // the result of the set-as-default operation.
252 void OnCheckIsDefaultComplete(DefaultWebClientState state); 217 void OnCheckIsDefaultComplete(DefaultWebClientState state,
253 218 bool is_following_set_as_default);
254 // Called when the set as default operation is completed. This then invokes
255 // FinalizeSetAsDefault() and starts the check is default process.
256 // It is safe to call this multiple times. Only the first call is processed
257 // after StartSetAsDefault() is invoked.
258 void OnSetAsDefaultAttemptComplete(AttemptResult result);
259 219
260 // When false, the operation to set as default will fail for interactive 220 // When false, the operation to set as default will fail for interactive
261 // flows. 221 // flows.
262 bool interactive_permitted_ = true; 222 bool interactive_permitted_ = true;
263 223
264 private: 224 private:
265 // Checks whether Chrome is the default web client. Always called on the 225 // Checks whether Chrome is the default web client. Always called on the
266 // FILE thread. 226 // FILE thread. When |is_following_set_as_default| is true, The default state
267 void CheckIsDefault(); 227 // will be reported to UMA as the result of the set-as-default operation.
228 void CheckIsDefault(bool is_following_set_as_default);
268 229
269 // Sets Chrome as the default web client. Always called on the FILE thread. 230 // Sets Chrome as the default web client. Always called on the FILE thread.
270 void SetAsDefault(); 231 void SetAsDefault();
271 232
272 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses. 233 // Implementation of CheckIsDefault() and SetAsDefault() for subclasses.
273 virtual DefaultWebClientState CheckIsDefaultImpl() = 0; 234 virtual DefaultWebClientState CheckIsDefaultImpl() = 0;
274 virtual AttemptResult SetAsDefaultImpl() = 0; 235 virtual void SetAsDefaultImpl() = 0;
275 236
276 // Reports the result and duration for one set-as-default attempt. 237 // Reports the result for the set-as-default operation.
277 void ReportAttemptResult(AttemptResult result); 238 void ReportSetDefaultResult(DefaultWebClientState state);
278 239
279 // Updates the UI in our associated view with the current default web 240 // Updates the UI in our associated view with the current default web
280 // client state. 241 // client state.
281 void UpdateUI(DefaultWebClientState state); 242 void UpdateUI(DefaultWebClientState state);
282 243
283 // Called with the default state after the worker is done. 244 // Called with the default state after the worker is done.
284 DefaultWebClientWorkerCallback callback_; 245 DefaultWebClientWorkerCallback callback_;
285 246
286 // Used to differentiate UMA metrics for setting the default browser and 247 // Used to differentiate UMA metrics for setting the default browser and
287 // setting the default protocol client. The pointer must be valid for the 248 // setting the default protocol client. The pointer must be valid for the
(...skipping 12 matching lines...) Expand all
300 public: 261 public:
301 explicit DefaultBrowserWorker(const DefaultWebClientWorkerCallback& callback); 262 explicit DefaultBrowserWorker(const DefaultWebClientWorkerCallback& callback);
302 263
303 private: 264 private:
304 ~DefaultBrowserWorker() override; 265 ~DefaultBrowserWorker() override;
305 266
306 // Check if Chrome is the default browser. 267 // Check if Chrome is the default browser.
307 DefaultWebClientState CheckIsDefaultImpl() override; 268 DefaultWebClientState CheckIsDefaultImpl() override;
308 269
309 // Set Chrome as the default browser. 270 // Set Chrome as the default browser.
310 AttemptResult SetAsDefaultImpl() override; 271 void SetAsDefaultImpl() override;
311 272
312 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker); 273 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserWorker);
313 }; 274 };
314 275
315 // Worker for checking and setting the default client application 276 // Worker for checking and setting the default client application
316 // for a given protocol. A different worker instance is needed for each 277 // for a given protocol. A different worker instance is needed for each
317 // protocol you are interested in, so to check or set the default for 278 // protocol you are interested in, so to check or set the default for
318 // multiple protocols you should use multiple worker objects. 279 // multiple protocols you should use multiple worker objects.
319 class DefaultProtocolClientWorker : public DefaultWebClientWorker { 280 class DefaultProtocolClientWorker : public DefaultWebClientWorker {
320 public: 281 public:
321 DefaultProtocolClientWorker(const DefaultWebClientWorkerCallback& callback, 282 DefaultProtocolClientWorker(const DefaultWebClientWorkerCallback& callback,
322 const std::string& protocol); 283 const std::string& protocol);
323 284
324 const std::string& protocol() const { return protocol_; } 285 const std::string& protocol() const { return protocol_; }
325 286
326 protected: 287 protected:
327 ~DefaultProtocolClientWorker() override; 288 ~DefaultProtocolClientWorker() override;
328 289
329 private: 290 private:
330 // Check if Chrome is the default handler for this protocol. 291 // Check if Chrome is the default handler for this protocol.
331 DefaultWebClientState CheckIsDefaultImpl() override; 292 DefaultWebClientState CheckIsDefaultImpl() override;
332 293
333 // Set Chrome as the default handler for this protocol. 294 // Set Chrome as the default handler for this protocol.
334 AttemptResult SetAsDefaultImpl() override; 295 void SetAsDefaultImpl() override;
335 296
336 std::string protocol_; 297 std::string protocol_;
337 298
338 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker); 299 DISALLOW_COPY_AND_ASSIGN(DefaultProtocolClientWorker);
339 }; 300 };
340 301
341 } // namespace shell_integration 302 } // namespace shell_integration
342 303
343 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_ 304 #endif // CHROME_BROWSER_SHELL_INTEGRATION_H_
OLDNEW
« no previous file with comments | « chrome/browser/external_protocol/external_protocol_handler_unittest.cc ('k') | chrome/browser/shell_integration.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698