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

Unified Diff: chrome/browser/shell_integration.h

Issue 1657933003: Fixes the interactive default browser UX for policy setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt comments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/shell_integration.h
diff --git a/chrome/browser/shell_integration.h b/chrome/browser/shell_integration.h
index f2c629a57ae819495dcdee1ce6e4c02b86bcb567..4d92a829a6f0039ed63f138422189efe722c74bc 100644
--- a/chrome/browser/shell_integration.h
+++ b/chrome/browser/shell_integration.h
@@ -201,12 +201,6 @@ class ShellIntegration {
// Called to notify the UI of the immediate result of invoking
// SetAsDefault.
virtual void OnSetAsDefaultConcluded(bool succeeded) {}
- // Observer classes that return true to OwnedByWorker are automatically
- // freed by the worker when they are no longer needed. False by default.
- virtual bool IsOwnedByWorker();
- // An observer can permit or decline set-as-default operation if it
- // requires triggering user interaction. By default not allowed.
- virtual bool IsInteractiveSetDefaultPermitted();
};
// Helper objects that handle checking if Chrome is the default browser
@@ -217,7 +211,16 @@ class ShellIntegration {
class DefaultWebClientWorker
: public base::RefCountedThreadSafe<DefaultWebClientWorker> {
public:
- explicit DefaultWebClientWorker(DefaultWebClientObserver* observer);
+ // Constructor. The worker will post updates to |observer|. If
+ // |delete_observer| is true, the worker owns the observer and it will be
+ // freed in the destructor.
+ DefaultWebClientWorker(DefaultWebClientObserver* observer,
+ bool delete_observer);
+
+ // Controls whether the worker can use user interaction to set the default
+ // web client. If false, the set-as-default operation will fail on OS where
+ // it is required.
+ void SetInteractivePermitted(bool interactive_permitted);
grt (UTC plus 2) 2016/02/03 15:39:56 nit: this can be inlined as set_interactive_permit
Patrick Monette 2016/02/03 23:01:39 Done.
// Checks to see if Chrome is the default web client application. The result
// will be passed back to the observer via the SetDefaultWebClientUIState
@@ -281,6 +284,10 @@ class ShellIntegration {
return set_as_default_initialized_;
}
+ // When false, the operation to set as default will fail for interactive
+ // flows.
+ bool interactive_permitted_ = true;
+
// Flag that indicates if the set-as-default operation is in progess to
// prevent multiple notifications to the observer.
bool set_as_default_in_progress_ = false;
@@ -292,10 +299,9 @@ class ShellIntegration {
virtual void CheckIsDefault() = 0;
// Sets Chrome as the default web client. Always called on the FILE thread.
- // |interactive_permitted| will make SetAsDefault() fail if it requires
- // interaction with the user. Subclasses are responsible for calling
- // OnSetAsDefaultAttemptComplete() on the UI thread.
- virtual void SetAsDefault(bool interactive_permitted) = 0;
+ // Subclasses are responsible for calling OnSetAsDefaultAttemptComplete() on
+ // the UI thread.
+ virtual void SetAsDefault() = 0;
// Returns the prefix used for metrics to differentiate UMA metrics for
// setting the default browser and setting the default protocol client.
@@ -325,6 +331,9 @@ class ShellIntegration {
DefaultWebClientObserver* observer_;
+ // Indicates if the the observer will be automatically freed by the worker.
+ bool delete_observer_;
+
// Flag that indicates the return value of InitializeSetAsDefault(). If
// true, FinalizeSetAsDefault() will be called to clear what was
// initialized.
@@ -343,7 +352,11 @@ class ShellIntegration {
// Worker for checking and setting the default browser.
class DefaultBrowserWorker : public DefaultWebClientWorker {
public:
- explicit DefaultBrowserWorker(DefaultWebClientObserver* observer);
+ // Constructor. The worker will post updates to |observer|. If
+ // |delete_observer| is true, the worker owns the observer and it will be
+ // freed in the destructor.
+ DefaultBrowserWorker(DefaultWebClientObserver* observer,
+ bool delete_observer);
private:
~DefaultBrowserWorker() override;
@@ -352,7 +365,7 @@ class ShellIntegration {
void CheckIsDefault() override;
// Set Chrome as the default browser.
- void SetAsDefault(bool interactive_permitted) override;
+ void SetAsDefault() override;
// Returns the histogram prefix for DefaultBrowserWorker.
const char* GetHistogramPrefix() override;
@@ -383,8 +396,12 @@ class ShellIntegration {
// multiple protocols you should use multiple worker objects.
class DefaultProtocolClientWorker : public DefaultWebClientWorker {
public:
+ // Constructor. The worker will post updates to |observer|. If
+ // |delete_observer| is true, the worker owns the observer and it will be
+ // freed in the destructor.
DefaultProtocolClientWorker(DefaultWebClientObserver* observer,
- const std::string& protocol);
+ const std::string& protocol,
+ bool delete_observer);
const std::string& protocol() const { return protocol_; }
@@ -396,7 +413,7 @@ class ShellIntegration {
void CheckIsDefault() override;
// Set Chrome as the default handler for this protocol.
- void SetAsDefault(bool interactive_permitted) override;
+ void SetAsDefault() override;
// Returns the histogram prefix for DefaultProtocolClientWorker.
const char* GetHistogramPrefix() override;

Powered by Google App Engine
This is Rietveld 408576698