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

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

Powered by Google App Engine
This is Rietveld 408576698