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

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: 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.cc
diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
index 8c519c5de1d2785de7b366b0c06f34290569028e..81f1d40c29fb5fed249f0b51bc821127060d0254 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -157,25 +157,15 @@ 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)
+ : observer_(observer),
+ delete_observer_(delete_observer),
+ interactive_permitted_(true) {}
grt (UTC plus 2) 2016/02/03 15:39:56 nit: remove this from the initializer list since i
Patrick Monette 2016/02/03 23:01:38 Done.
void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() {
if (observer_)
@@ -198,20 +188,17 @@ void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
}
set_as_default_in_progress_ = true;
- bool interactive_permitted = true;
- if (observer_) {
+ if (observer_)
observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
- interactive_permitted = observer_->IsInteractiveSetDefaultPermitted();
- }
set_as_default_initialized_ = InitializeSetAsDefault();
// 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 +236,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,9 +366,9 @@ const char* ShellIntegration::DefaultWebClientWorker::AttemptResultToString(
//
ShellIntegration::DefaultBrowserWorker::DefaultBrowserWorker(
- DefaultWebClientObserver* observer)
- : DefaultWebClientWorker(observer) {
-}
+ DefaultWebClientObserver* observer,
+ bool delete_observer)
+ : DefaultWebClientWorker(observer, delete_observer) {}
ShellIntegration::DefaultBrowserWorker::~DefaultBrowserWorker() {}
@@ -395,8 +382,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 +393,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 +433,10 @@ 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)
+ : DefaultWebClientWorker(observer, delete_observer), protocol_(protocol) {}
///////////////////////////////////////////////////////////////////////////////
// DefaultProtocolClientWorker, private:
@@ -465,8 +451,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 +462,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