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

Unified Diff: chrome/browser/shell_integration.cc

Issue 1657933003: Fixes the interactive default browser UX for policy setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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.cc
diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
index 8c519c5de1d2785de7b366b0c06f34290569028e..583384b855702195e1ecafbd51f8b1f90ffe075f 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -157,25 +157,16 @@ base::string16 ShellIntegration::GetAppShortcutsSubdirName() {
#endif // !defined(OS_WIN)
///////////////////////////////////////////////////////////////////////////////
-// ShellIntegration::DefaultWebClientObserver
-//
-
-bool ShellIntegration::DefaultWebClientObserver::IsOwnedByWorker() {
- return false;
-}
-
-bool ShellIntegration::DefaultWebClientObserver::
- IsInteractiveSetDefaultPermitted() {
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
// ShellIntegration::DefaultWebClientWorker
//
ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker(
- DefaultWebClientObserver* observer)
- : observer_(observer) {}
+ DefaultWebClientObserver* observer,
+ bool delete_observer,
+ bool interactive_permitted)
+ : observer_(observer),
+ delete_observer_(delete_observer),
+ interactive_permitted_(interactive_permitted) {}
void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() {
if (observer_)
@@ -198,10 +189,8 @@ void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
}
set_as_default_in_progress_ = true;
- bool interactive_permitted = true;
if (observer_) {
grt (UTC plus 2) 2016/02/02 17:28:22 nit: omit braces
Patrick Monette 2016/02/02 22:24:15 Done.
observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
- interactive_permitted = observer_->IsInteractiveSetDefaultPermitted();
}
set_as_default_initialized_ = InitializeSetAsDefault();
@@ -209,9 +198,9 @@ void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
// Remember the start time.
start_time_ = base::TimeTicks::Now();
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&DefaultWebClientWorker::SetAsDefault,
- this, interactive_permitted));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DefaultWebClientWorker::SetAsDefault, this));
}
void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() {
@@ -249,7 +238,7 @@ void ShellIntegration::DefaultWebClientWorker::OnCheckIsDefaultComplete(
// The worker has finished everything it needs to do, so free the observer
// if we own it.
- if (observer_ && observer_->IsOwnedByWorker()) {
+ if (observer_ && delete_observer_) {
delete observer_;
observer_ = nullptr;
}
@@ -379,8 +368,10 @@ const char* ShellIntegration::DefaultWebClientWorker::AttemptResultToString(
//
ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker(
- DefaultWebClientObserver* observer)
- : DefaultWebClientWorker(observer) {
+ DefaultWebClientObserver* observer,
+ bool delete_observer,
+ bool interactive_permitted)
+ : DefaultWebClientWorker(observer, delete_observer, interactive_permitted) {
}
ShellIntegration::DefaultBrowserWorker::~DefaultBrowserWorker() {}
@@ -395,8 +386,7 @@ void ShellIntegration::DefaultBrowserWorker::CheckIsDefault() {
base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state));
}
-void ShellIntegration::DefaultBrowserWorker::SetAsDefault(
- bool interactive_permitted) {
+void ShellIntegration::DefaultBrowserWorker::SetAsDefault() {
AttemptResult result = AttemptResult::FAILURE;
switch (CanSetAsDefaultBrowser()) {
case SET_DEFAULT_NOT_ALLOWED:
@@ -407,12 +397,12 @@ void ShellIntegration::DefaultBrowserWorker::SetAsDefault(
result = AttemptResult::SUCCESS;
break;
case SET_DEFAULT_INTERACTIVE:
- if (interactive_permitted && SetAsDefaultBrowserInteractive())
+ if (interactive_permitted_ && SetAsDefaultBrowserInteractive())
result = AttemptResult::SUCCESS;
break;
case SET_DEFAULT_ASYNCHRONOUS:
#if defined(OS_WIN)
- if (!interactive_permitted)
+ if (!interactive_permitted_)
break;
if (GetDefaultBrowser() == IS_DEFAULT) {
// Don't start the asynchronous operation since it could result in
@@ -447,10 +437,12 @@ const char* ShellIntegration::DefaultBrowserWorker::GetHistogramPrefix() {
//
ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker(
- DefaultWebClientObserver* observer, const std::string& protocol)
- : DefaultWebClientWorker(observer),
- protocol_(protocol) {
-}
+ DefaultWebClientObserver* observer,
+ const std::string& protocol,
+ bool delete_observer,
+ bool interactive_permitted)
+ : DefaultWebClientWorker(observer, delete_observer, interactive_permitted),
+ protocol_(protocol) {}
///////////////////////////////////////////////////////////////////////////////
// DefaultProtocolClientWorker, private:
@@ -465,8 +457,7 @@ void ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() {
state));
}
-void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault(
- bool interactive_permitted) {
+void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault() {
AttemptResult result = AttemptResult::FAILURE;
switch (CanSetAsDefaultProtocolClient()) {
case SET_DEFAULT_NOT_ALLOWED:
@@ -477,7 +468,7 @@ void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault(
result = AttemptResult::SUCCESS;
break;
case SET_DEFAULT_INTERACTIVE:
- if (interactive_permitted &&
+ if (interactive_permitted_ &&
SetAsDefaultProtocolClientInteractive(protocol_)) {
result = AttemptResult::SUCCESS;
}

Powered by Google App Engine
This is Rietveld 408576698