| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/ui/webui/welcome_win10_handler.h" | 5 #include "chrome/browser/ui/webui/welcome_win10_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram_functions.h" | 8 #include "base/metrics/histogram_functions.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool callback_id_found = args->GetString(0, &pinned_state_callback_id_); | 97 bool callback_id_found = args->GetString(0, &pinned_state_callback_id_); |
| 98 DCHECK(callback_id_found); | 98 DCHECK(callback_id_found); |
| 99 | 99 |
| 100 // Send back the result if it is already available. | 100 // Send back the result if it is already available. |
| 101 if (pinned_state_result_.has_value()) { | 101 if (pinned_state_result_.has_value()) { |
| 102 SendPinnedToTaskbarStateResult(); | 102 SendPinnedToTaskbarStateResult(); |
| 103 return; | 103 return; |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Only wait for a small amount of time for the result. If the timer fires, | 106 // Only wait for a small amount of time for the result. If the timer fires, |
| 107 // it will be assumed that Chrome is pinned to the taskbar. This is to make | 107 // it will be assumed that Chrome isn't pinned to the taskbar. This is to make |
| 108 // sure the instructions are never displayed in case it was impossible to | 108 // sure the instructions are displayed in case it was impossible to determine |
| 109 // determine the pinned state. | 109 // the pinned state. |
| 110 constexpr base::TimeDelta kPinnedToTaskbarTimeout = | 110 constexpr base::TimeDelta kPinnedToTaskbarTimeout = |
| 111 base::TimeDelta::FromMilliseconds(200); | 111 base::TimeDelta::FromMilliseconds(200); |
| 112 timer_.Start(FROM_HERE, kPinnedToTaskbarTimeout, | 112 timer_.Start(FROM_HERE, kPinnedToTaskbarTimeout, |
| 113 base::Bind(&WelcomeWin10Handler::OnIsPinnedToTaskbarDetermined, | 113 base::Bind(&WelcomeWin10Handler::OnIsPinnedToTaskbarDetermined, |
| 114 base::Unretained(this), true, true)); | 114 base::Unretained(this), true, false)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void WelcomeWin10Handler::HandleSetDefaultBrowser(const base::ListValue* args) { | 117 void WelcomeWin10Handler::HandleSetDefaultBrowser(const base::ListValue* args) { |
| 118 base::RecordAction( | 118 base::RecordAction( |
| 119 base::UserMetricsAction("Win10WelcomePage_SetAsDefaultBrowser")); | 119 base::UserMetricsAction("Win10WelcomePage_SetAsDefaultBrowser")); |
| 120 // The worker owns itself. | 120 // The worker owns itself. |
| 121 (new shell_integration::DefaultBrowserWorker( | 121 (new shell_integration::DefaultBrowserWorker( |
| 122 shell_integration::DefaultWebClientWorkerCallback())) | 122 shell_integration::DefaultWebClientWorkerCallback())) |
| 123 ->StartSetAsDefault(); | 123 ->StartSetAsDefault(); |
| 124 } | 124 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // sent back. | 168 // sent back. |
| 169 if (!pinned_state_callback_id_.empty()) | 169 if (!pinned_state_callback_id_.empty()) |
| 170 SendPinnedToTaskbarStateResult(); | 170 SendPinnedToTaskbarStateResult(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void WelcomeWin10Handler::SendPinnedToTaskbarStateResult() { | 173 void WelcomeWin10Handler::SendPinnedToTaskbarStateResult() { |
| 174 ResolveJavascriptCallback( | 174 ResolveJavascriptCallback( |
| 175 base::StringValue(pinned_state_callback_id_), | 175 base::StringValue(pinned_state_callback_id_), |
| 176 base::FundamentalValue(pinned_state_result_.value())); | 176 base::FundamentalValue(pinned_state_result_.value())); |
| 177 } | 177 } |
| OLD | NEW |