OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 ShellIntegration::DefaultWebClientState ProbeCurrentDefaultHandlers( | 67 ShellIntegration::DefaultWebClientState ProbeCurrentDefaultHandlers( |
68 const wchar_t* const* protocols, | 68 const wchar_t* const* protocols, |
69 size_t num_protocols) { | 69 size_t num_protocols) { |
70 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration; | 70 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration; |
71 HRESULT hr = registration.CreateInstance( | 71 HRESULT hr = registration.CreateInstance( |
72 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); | 72 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); |
73 if (FAILED(hr)) | 73 if (FAILED(hr)) |
74 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; | 74 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; |
75 | 75 |
76 string16 prog_id(ShellUtil::kChromeHTMLProgId); | 76 string16 prog_id(ShellUtil::kChromeHTMLProgId); |
77 | 77 prog_id += ShellUtil::GetCurrentInstallationSuffix(); |
78 // If a user specific default browser entry exists, we check for that ProgID | |
79 // being default. If not, then the ProgID is ChromeHTML or ChromiumHTML so we | |
80 // do not append a suffix to the ProgID. | |
81 string16 suffix; | |
82 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
83 if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(dist, &suffix)) | |
84 prog_id += suffix; | |
85 | 78 |
86 for (size_t i = 0; i < num_protocols; ++i) { | 79 for (size_t i = 0; i < num_protocols; ++i) { |
87 base::win::ScopedCoMem<wchar_t> current_app; | 80 base::win::ScopedCoMem<wchar_t> current_app; |
88 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL, | 81 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL, |
89 AL_EFFECTIVE, ¤t_app); | 82 AL_EFFECTIVE, ¤t_app); |
90 if (FAILED(hr) || prog_id.compare(current_app) != 0) | 83 if (FAILED(hr) || prog_id.compare(current_app) != 0) |
91 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; | 84 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; |
92 } | 85 } |
93 | 86 |
94 return ShellIntegration::IS_DEFAULT_WEB_CLIENT; | 87 return ShellIntegration::IS_DEFAULT_WEB_CLIENT; |
95 } | 88 } |
96 | 89 |
97 // Probe using IApplicationAssociationRegistration::QueryAppIsDefault (Vista and | 90 // Probe using IApplicationAssociationRegistration::QueryAppIsDefault (Vista and |
98 // Windows 7); see ProbeProtocolHandlers. | 91 // Windows 7); see ProbeProtocolHandlers. |
99 ShellIntegration::DefaultWebClientState ProbeAppIsDefaultHandlers( | 92 ShellIntegration::DefaultWebClientState ProbeAppIsDefaultHandlers( |
100 const wchar_t* const* protocols, | 93 const wchar_t* const* protocols, |
101 size_t num_protocols) { | 94 size_t num_protocols) { |
102 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration; | 95 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration; |
103 HRESULT hr = registration.CreateInstance( | 96 HRESULT hr = registration.CreateInstance( |
104 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); | 97 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); |
105 if (FAILED(hr)) | 98 if (FAILED(hr)) |
106 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; | 99 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; |
107 | 100 |
108 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 101 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
109 string16 app_name(dist->GetApplicationName()); | 102 string16 app_name(dist->GetApplicationName()); |
110 | 103 app_name += ShellUtil::GetCurrentInstallationSuffix(); |
111 // If a user specific default browser entry exists, we check for that | |
112 // app name being default. If not, then default browser is just called | |
113 // Google Chrome or Chromium so we do not append a suffix to the app name. | |
114 string16 suffix; | |
115 if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(dist, &suffix)) | |
116 app_name += suffix; | |
117 | 104 |
118 BOOL result; | 105 BOOL result; |
119 for (size_t i = 0; i < num_protocols; ++i) { | 106 for (size_t i = 0; i < num_protocols; ++i) { |
120 result = TRUE; | 107 result = TRUE; |
121 hr = registration->QueryAppIsDefault(protocols[i], AT_URLPROTOCOL, | 108 hr = registration->QueryAppIsDefault(protocols[i], AT_URLPROTOCOL, |
122 AL_EFFECTIVE, app_name.c_str(), &result); | 109 AL_EFFECTIVE, app_name.c_str(), &result); |
123 if (FAILED(hr) || result == FALSE) | 110 if (FAILED(hr) || result == FALSE) |
124 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; | 111 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; |
125 } | 112 } |
126 | 113 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 } | 517 } |
531 | 518 |
532 void ShellIntegration::MigrateChromiumShortcuts() { | 519 void ShellIntegration::MigrateChromiumShortcuts() { |
533 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 520 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
534 return; | 521 return; |
535 | 522 |
536 BrowserThread::PostTask( | 523 BrowserThread::PostTask( |
537 BrowserThread::FILE, FROM_HERE, | 524 BrowserThread::FILE, FROM_HERE, |
538 base::Bind(&MigrateChromiumShortcutsCallback)); | 525 base::Bind(&MigrateChromiumShortcutsCallback)); |
539 } | 526 } |
OLD | NEW |