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

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

Issue 10963004: Fix registerProtocolHandler OS registration on Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed blank line Created 8 years, 2 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 | Annotate | Revision Log
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 <windows.h> 7 #include <windows.h>
8 #include <shobjidl.h> 8 #include <shobjidl.h>
9 #include <propkey.h> 9 #include <propkey.h>
10 #include <propvarutil.h> 10 #include <propvarutil.h>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) { 424 bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
425 if (protocol.empty()) 425 if (protocol.empty())
426 return false; 426 return false;
427 427
428 FilePath chrome_exe; 428 FilePath chrome_exe;
429 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { 429 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
430 LOG(ERROR) << "Error getting app exe path"; 430 LOG(ERROR) << "Error getting app exe path";
431 return false; 431 return false;
432 } 432 }
433 433
434 string16 wprotocol = UTF8ToUTF16(protocol); 434 string16 wprotocol(UTF8ToUTF16(protocol));
435 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 435 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
436 if (!ShellUtil::MakeChromeDefaultProtocolClient(dist, chrome_exe.value(), 436 if (!ShellUtil::MakeChromeDefaultProtocolClient(dist, chrome_exe.value(),
437 wprotocol)) { 437 wprotocol)) {
438 LOG(ERROR) << "Chrome could not be set as default handler for " 438 LOG(ERROR) << "Chrome could not be set as default handler for "
439 << protocol << "."; 439 << protocol << ".";
440 return false; 440 return false;
441 } 441 }
442 442
443 VLOG(1) << "Chrome registered as default handler for " << protocol << "."; 443 VLOG(1) << "Chrome registered as default handler for " << protocol << ".";
444 return true; 444 return true;
445 } 445 }
446 446
447 bool ShellIntegration::SetAsDefaultBrowserInteractive() { 447 bool ShellIntegration::SetAsDefaultBrowserInteractive() {
448 FilePath chrome_exe; 448 FilePath chrome_exe;
449 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { 449 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
450 NOTREACHED() << "Error getting app exe path"; 450 NOTREACHED() << "Error getting app exe path";
451 return false; 451 return false;
452 } 452 }
453 453
454 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 454 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
455 if (!ShellUtil::ShowMakeChromeDefaultSystemUI(dist, chrome_exe.value())) { 455 if (!ShellUtil::ShowMakeChromeDefaultSystemUI(dist, chrome_exe.value())) {
456 LOG(ERROR) << "Failed to launch the set-default-browser Windows UI."; 456 LOG(ERROR) << "Failed to launch the set-default-browser Windows UI.";
457 return false; 457 return false;
458 } 458 }
459 459
460 VLOG(1) << "Set-as-default Windows UI triggered."; 460 VLOG(1) << "Set-default-browser Windows UI completed.";
461 return true; 461 return true;
462 } 462 }
463 463
464 bool ShellIntegration::SetAsDefaultProtocolClientInteractive(
465 const std::string& protocol) {
466 FilePath chrome_exe;
467 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
468 NOTREACHED() << "Error getting app exe path";
469 return false;
470 }
471
472 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
473 string16 wprotocol(UTF8ToUTF16(protocol));
474 if (!ShellUtil::ShowMakeChromeDefaultProtocolClientSystemUI(
475 dist, chrome_exe.value(), wprotocol)) {
476 LOG(ERROR) << "Failed to launch the set-default-client Windows UI.";
477 return false;
478 }
479
480 VLOG(1) << "Set-default-client Windows UI completed.";
481 return true;
482 }
483
464 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() { 484 ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() {
465 // When we check for default browser we don't necessarily want to count file 485 // When we check for default browser we don't necessarily want to count file
466 // type handlers and icons as having changed the default browser status, 486 // type handlers and icons as having changed the default browser status,
467 // since the user may have changed their shell settings to cause HTML files 487 // since the user may have changed their shell settings to cause HTML files
468 // to open with a text editor for example. We also don't want to aggressively 488 // to open with a text editor for example. We also don't want to aggressively
469 // claim FTP, since the user may have a separate FTP client. It is an open 489 // claim FTP, since the user may have a separate FTP client. It is an open
470 // question as to how to "heal" these settings. Perhaps the user should just 490 // question as to how to "heal" these settings. Perhaps the user should just
471 // re-run the installer or run with the --set-default-browser command line 491 // re-run the installer or run with the --set-default-browser command line
472 // flag. There is doubtless some other key we can hook into to cause "Repair" 492 // flag. There is doubtless some other key we can hook into to cause "Repair"
473 // to show up in Add/Remove programs for us. 493 // to show up in Add/Remove programs for us.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 continue; 606 continue;
587 } 607 }
588 608
589 shortcut = shortcut.Append(shortcut_name).Append(shortcut_name + L".lnk"); 609 shortcut = shortcut.Append(shortcut_name).Append(shortcut_name + L".lnk");
590 if (file_util::PathExists(shortcut)) 610 if (file_util::PathExists(shortcut))
591 return shortcut; 611 return shortcut;
592 } 612 }
593 613
594 return FilePath(); 614 return FilePath();
595 } 615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698