| Index: chrome/browser/shell_integration.cc
|
| diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
|
| index e8753deaac09e21367c3a9d02aa72ad2138af824..39799e88319404192511d578f691a3f7988849f3 100644
|
| --- a/chrome/browser/shell_integration.cc
|
| +++ b/chrome/browser/shell_integration.cc
|
| @@ -148,7 +148,7 @@ DefaultWebClientWorker::DefaultWebClientWorker(
|
| void DefaultWebClientWorker::StartCheckIsDefault() {
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(&DefaultWebClientWorker::CheckIsDefault, this));
|
| + base::Bind(&DefaultWebClientWorker::CheckIsDefault, this, false));
|
| }
|
|
|
| void DefaultWebClientWorker::StartSetAsDefault() {
|
| @@ -163,41 +163,23 @@ void DefaultWebClientWorker::StartSetAsDefault() {
|
| DefaultWebClientWorker::~DefaultWebClientWorker() {}
|
|
|
| void DefaultWebClientWorker::OnCheckIsDefaultComplete(
|
| - DefaultWebClientState state) {
|
| + DefaultWebClientState state,
|
| + bool is_following_set_as_default) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| UpdateUI(state);
|
|
|
| - if (check_default_should_report_success_) {
|
| - check_default_should_report_success_ = false;
|
| -
|
| - ReportAttemptResult(state == DefaultWebClientState::IS_DEFAULT
|
| - ? AttemptResult::SUCCESS
|
| - : AttemptResult::NO_ERRORS_NOT_DEFAULT);
|
| - }
|
| + if (is_following_set_as_default)
|
| + ReportSetDefaultResult(state);
|
| }
|
|
|
| -void DefaultWebClientWorker::OnSetAsDefaultAttemptComplete(
|
| - AttemptResult result) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| -
|
| - // Report failures here. Successes are reported in
|
| - // OnCheckIsDefaultComplete() after checking that the change is verified.
|
| - check_default_should_report_success_ = result == AttemptResult::SUCCESS;
|
| - if (!check_default_should_report_success_)
|
| - ReportAttemptResult(result);
|
| -
|
| - // Start the default browser check. The default state will be reported to
|
| - // the caller via the |callback_|.
|
| - StartCheckIsDefault();
|
| -}
|
| -
|
| -void DefaultWebClientWorker::ReportAttemptResult(AttemptResult result) {
|
| +void DefaultWebClientWorker::ReportSetDefaultResult(
|
| + DefaultWebClientState state) {
|
| base::LinearHistogram::FactoryGet(
|
| - base::StringPrintf("%s.SetDefaultResult", GetHistogramPrefix()), 1,
|
| - AttemptResult::NUM_ATTEMPT_RESULT_TYPES,
|
| - AttemptResult::NUM_ATTEMPT_RESULT_TYPES + 1,
|
| + base::StringPrintf("%s.SetDefaultResult2", GetHistogramPrefix()), 1,
|
| + DefaultWebClientState::NUM_DEFAULT_STATES,
|
| + DefaultWebClientState::NUM_DEFAULT_STATES + 1,
|
| base::HistogramBase::kUmaTargetedHistogramFlag)
|
| - ->Add(result);
|
| + ->Add(state);
|
| }
|
|
|
| void DefaultWebClientWorker::UpdateUI(DefaultWebClientState state) {
|
| @@ -232,32 +214,28 @@ DefaultBrowserWorker::~DefaultBrowserWorker() {}
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // DefaultBrowserWorker, private:
|
|
|
| -void DefaultBrowserWorker::CheckIsDefault() {
|
| +void DefaultBrowserWorker::CheckIsDefault(bool is_following_set_as_default) {
|
| DefaultWebClientState state = GetDefaultBrowser();
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state));
|
| + base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state,
|
| + is_following_set_as_default));
|
| }
|
|
|
| void DefaultBrowserWorker::SetAsDefault() {
|
| - AttemptResult result = AttemptResult::FAILURE;
|
| switch (CanSetAsDefaultBrowser()) {
|
| case SET_DEFAULT_NOT_ALLOWED:
|
| NOTREACHED();
|
| break;
|
| case SET_DEFAULT_UNATTENDED:
|
| - if (SetAsDefaultBrowser())
|
| - result = AttemptResult::SUCCESS;
|
| + SetAsDefaultBrowser();
|
| break;
|
| case SET_DEFAULT_INTERACTIVE:
|
| - if (interactive_permitted_ && SetAsDefaultBrowserInteractive())
|
| - result = AttemptResult::SUCCESS;
|
| + if (interactive_permitted_)
|
| + SetAsDefaultBrowserInteractive();
|
| break;
|
| }
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&DefaultBrowserWorker::OnSetAsDefaultAttemptComplete, this,
|
| - result));
|
| + CheckIsDefault(true);
|
| }
|
|
|
| const char* DefaultBrowserWorker::GetHistogramPrefix() {
|
| @@ -278,35 +256,30 @@ DefaultProtocolClientWorker::DefaultProtocolClientWorker(
|
|
|
| DefaultProtocolClientWorker::~DefaultProtocolClientWorker() {}
|
|
|
| -void DefaultProtocolClientWorker::CheckIsDefault() {
|
| +void DefaultProtocolClientWorker::CheckIsDefault(
|
| + bool is_following_set_as_default) {
|
| DefaultWebClientState state = IsDefaultProtocolClient(protocol_);
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| base::Bind(&DefaultProtocolClientWorker::OnCheckIsDefaultComplete, this,
|
| - state));
|
| + state, is_following_set_as_default));
|
| }
|
|
|
| void DefaultProtocolClientWorker::SetAsDefault() {
|
| - AttemptResult result = AttemptResult::FAILURE;
|
| switch (CanSetAsDefaultProtocolClient()) {
|
| case SET_DEFAULT_NOT_ALLOWED:
|
| // Not allowed, do nothing.
|
| break;
|
| case SET_DEFAULT_UNATTENDED:
|
| - if (SetAsDefaultProtocolClient(protocol_))
|
| - result = AttemptResult::SUCCESS;
|
| + SetAsDefaultProtocolClient(protocol_);
|
| break;
|
| case SET_DEFAULT_INTERACTIVE:
|
| - if (interactive_permitted_ &&
|
| - SetAsDefaultProtocolClientInteractive(protocol_)) {
|
| - result = AttemptResult::SUCCESS;
|
| + if (interactive_permitted_) {
|
| + SetAsDefaultProtocolClientInteractive(protocol_);
|
| }
|
| break;
|
| }
|
| - BrowserThread::PostTask(
|
| - BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&DefaultProtocolClientWorker::OnSetAsDefaultAttemptComplete,
|
| - this, result));
|
| + CheckIsDefault(true);
|
| }
|
|
|
| const char* DefaultProtocolClientWorker::GetHistogramPrefix() {
|
|
|