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

Side by Side Diff: chrome/browser/shell_integration.cc

Issue 1832853003: DefaultBrowserWorker now fully supports opening the settings for Win10 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shell_integration.h" 5 #include "chrome/browser/shell_integration.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 27 matching lines...) Expand all
38 38
39 const struct AppModeInfo* gAppModeInfo = nullptr; 39 const struct AppModeInfo* gAppModeInfo = nullptr;
40 40
41 } // namespace 41 } // namespace
42 42
43 #if !defined(OS_WIN) 43 #if !defined(OS_WIN)
44 bool SetAsDefaultBrowserInteractive() { 44 bool SetAsDefaultBrowserInteractive() {
45 return false; 45 return false;
46 } 46 }
47 47
48 void SetAsDefaultBrowserUsingSystemSettings(
49 const base::Closure& on_finished_callback) {
50 NOTREACHED();
51 on_finished_callback.Run();
52 }
53
48 bool SetAsDefaultProtocolClientInteractive(const std::string& protocol) { 54 bool SetAsDefaultProtocolClientInteractive(const std::string& protocol) {
49 return false; 55 return false;
50 } 56 }
51 #endif // !defined(OS_WIN) 57 #endif // !defined(OS_WIN)
52 58
53 DefaultWebClientSetPermission CanSetAsDefaultProtocolClient() { 59 DefaultWebClientSetPermission CanSetAsDefaultProtocolClient() {
54 // Allowed as long as the browser can become the operating system default 60 // Allowed as long as the browser can become the operating system default
55 // browser. 61 // browser.
56 return CanSetAsDefaultBrowser(); 62 return CanSetAsDefaultBrowser();
57 } 63 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 186 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
181 DefaultWebClientState state = CheckIsDefaultImpl(); 187 DefaultWebClientState state = CheckIsDefaultImpl();
182 BrowserThread::PostTask( 188 BrowserThread::PostTask(
183 BrowserThread::UI, FROM_HERE, 189 BrowserThread::UI, FROM_HERE,
184 base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state, 190 base::Bind(&DefaultBrowserWorker::OnCheckIsDefaultComplete, this, state,
185 is_following_set_as_default)); 191 is_following_set_as_default));
186 } 192 }
187 193
188 void DefaultWebClientWorker::SetAsDefault() { 194 void DefaultWebClientWorker::SetAsDefault() {
189 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 195 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
190 SetAsDefaultImpl(); 196
191 CheckIsDefault(true); 197 // SetAsDefaultImpl will make sure the callback is executed exactly once.
198 SetAsDefaultImpl(
199 base::Bind(&DefaultWebClientWorker::CheckIsDefault, this, true));
192 } 200 }
193 201
194 void DefaultWebClientWorker::ReportSetDefaultResult( 202 void DefaultWebClientWorker::ReportSetDefaultResult(
195 DefaultWebClientState state) { 203 DefaultWebClientState state) {
196 base::LinearHistogram::FactoryGet( 204 base::LinearHistogram::FactoryGet(
197 base::StringPrintf("%s.SetDefaultResult2", worker_name_), 1, 205 base::StringPrintf("%s.SetDefaultResult2", worker_name_), 1,
198 DefaultWebClientState::NUM_DEFAULT_STATES, 206 DefaultWebClientState::NUM_DEFAULT_STATES,
199 DefaultWebClientState::NUM_DEFAULT_STATES + 1, 207 DefaultWebClientState::NUM_DEFAULT_STATES + 1,
200 base::HistogramBase::kUmaTargetedHistogramFlag) 208 base::HistogramBase::kUmaTargetedHistogramFlag)
201 ->Add(state); 209 ->Add(state);
(...skipping 28 matching lines...) Expand all
230 238
231 /////////////////////////////////////////////////////////////////////////////// 239 ///////////////////////////////////////////////////////////////////////////////
232 // DefaultBrowserWorker, private: 240 // DefaultBrowserWorker, private:
233 241
234 DefaultBrowserWorker::~DefaultBrowserWorker() = default; 242 DefaultBrowserWorker::~DefaultBrowserWorker() = default;
235 243
236 DefaultWebClientState DefaultBrowserWorker::CheckIsDefaultImpl() { 244 DefaultWebClientState DefaultBrowserWorker::CheckIsDefaultImpl() {
237 return GetDefaultBrowser(); 245 return GetDefaultBrowser();
238 } 246 }
239 247
240 void DefaultBrowserWorker::SetAsDefaultImpl() { 248 void DefaultBrowserWorker::SetAsDefaultImpl(
249 const base::Closure& on_finished_callback) {
241 switch (CanSetAsDefaultBrowser()) { 250 switch (CanSetAsDefaultBrowser()) {
242 case SET_DEFAULT_NOT_ALLOWED: 251 case SET_DEFAULT_NOT_ALLOWED:
243 NOTREACHED(); 252 NOTREACHED();
244 break; 253 break;
245 case SET_DEFAULT_UNATTENDED: 254 case SET_DEFAULT_UNATTENDED:
246 SetAsDefaultBrowser(); 255 SetAsDefaultBrowser();
247 break; 256 break;
248 case SET_DEFAULT_INTERACTIVE: 257 case SET_DEFAULT_INTERACTIVE:
249 if (interactive_permitted_) 258 if (interactive_permitted_)
250 SetAsDefaultBrowserInteractive(); 259 SetAsDefaultBrowserInteractive();
251 break; 260 break;
261 case SET_DEFAULT_OPEN_SETTINGS:
262 if (interactive_permitted_) {
263 SetAsDefaultBrowserUsingSystemSettings(on_finished_callback);
264 return;
265 }
252 } 266 }
267 on_finished_callback.Run();
253 } 268 }
254 269
255 /////////////////////////////////////////////////////////////////////////////// 270 ///////////////////////////////////////////////////////////////////////////////
256 // DefaultProtocolClientWorker 271 // DefaultProtocolClientWorker
257 // 272 //
258 273
259 DefaultProtocolClientWorker::DefaultProtocolClientWorker( 274 DefaultProtocolClientWorker::DefaultProtocolClientWorker(
260 const DefaultWebClientWorkerCallback& callback, 275 const DefaultWebClientWorkerCallback& callback,
261 const std::string& protocol) 276 const std::string& protocol)
262 : DefaultWebClientWorker(callback, "DefaultProtocolClient"), 277 : DefaultWebClientWorker(callback, "DefaultProtocolClient"),
263 protocol_(protocol) {} 278 protocol_(protocol) {}
264 279
265 /////////////////////////////////////////////////////////////////////////////// 280 ///////////////////////////////////////////////////////////////////////////////
266 // DefaultProtocolClientWorker, protected: 281 // DefaultProtocolClientWorker, protected:
267 282
268 DefaultProtocolClientWorker::~DefaultProtocolClientWorker() = default; 283 DefaultProtocolClientWorker::~DefaultProtocolClientWorker() = default;
269 284
270 /////////////////////////////////////////////////////////////////////////////// 285 ///////////////////////////////////////////////////////////////////////////////
271 // DefaultProtocolClientWorker, private: 286 // DefaultProtocolClientWorker, private:
272 287
273 DefaultWebClientState DefaultProtocolClientWorker::CheckIsDefaultImpl() { 288 DefaultWebClientState DefaultProtocolClientWorker::CheckIsDefaultImpl() {
274 return IsDefaultProtocolClient(protocol_); 289 return IsDefaultProtocolClient(protocol_);
275 } 290 }
276 291
277 void DefaultProtocolClientWorker::SetAsDefaultImpl() { 292 void DefaultProtocolClientWorker::SetAsDefaultImpl(
293 const base::Closure& on_finished_callback) {
278 switch (CanSetAsDefaultProtocolClient()) { 294 switch (CanSetAsDefaultProtocolClient()) {
279 case SET_DEFAULT_NOT_ALLOWED: 295 case SET_DEFAULT_NOT_ALLOWED:
280 // Not allowed, do nothing. 296 // Not allowed, do nothing.
281 break; 297 break;
282 case SET_DEFAULT_UNATTENDED: 298 case SET_DEFAULT_UNATTENDED:
283 SetAsDefaultProtocolClient(protocol_); 299 SetAsDefaultProtocolClient(protocol_);
284 break; 300 break;
285 case SET_DEFAULT_INTERACTIVE: 301 case SET_DEFAULT_INTERACTIVE:
286 if (interactive_permitted_) { 302 // TODO(pmonette): Implement SET_DEFAULT_OPEN_SETTINGS for Windows 10.
303 case SET_DEFAULT_OPEN_SETTINGS:
304 if (interactive_permitted_)
287 SetAsDefaultProtocolClientInteractive(protocol_); 305 SetAsDefaultProtocolClientInteractive(protocol_);
288 }
289 break; 306 break;
290 } 307 }
308 on_finished_callback.Run();
291 } 309 }
292 310
293 } // namespace shell_integration 311 } // namespace shell_integration
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698