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

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

Issue 10451074: Always suffix ChromeHTML entries on Windows for user-level installs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on r142211 Created 8 years, 6 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
« no previous file with comments | « no previous file | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // As a result, stale ProgIDs could be returned, leading to false positives. 68 // As a result, stale ProgIDs could be returned, leading to false positives.
69 ShellIntegration::DefaultWebClientState ProbeCurrentDefaultHandlers( 69 ShellIntegration::DefaultWebClientState ProbeCurrentDefaultHandlers(
70 const wchar_t* const* protocols, 70 const wchar_t* const* protocols,
71 size_t num_protocols) { 71 size_t num_protocols) {
72 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration; 72 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration;
73 HRESULT hr = registration.CreateInstance( 73 HRESULT hr = registration.CreateInstance(
74 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); 74 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC);
75 if (FAILED(hr)) 75 if (FAILED(hr))
76 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; 76 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT;
77 77
78 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
79 FilePath chrome_exe;
80 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
81 NOTREACHED();
82 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT;
83 }
78 string16 prog_id(ShellUtil::kChromeHTMLProgId); 84 string16 prog_id(ShellUtil::kChromeHTMLProgId);
79 85 prog_id += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value());
80 // If a user specific default browser entry exists, we check for that ProgID
81 // being default. If not, then the ProgID is ChromeHTML or ChromiumHTML so we
82 // do not append a suffix to the ProgID.
83 string16 suffix;
84 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
85 if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(dist, &suffix))
86 prog_id += suffix;
87 86
88 for (size_t i = 0; i < num_protocols; ++i) { 87 for (size_t i = 0; i < num_protocols; ++i) {
89 base::win::ScopedCoMem<wchar_t> current_app; 88 base::win::ScopedCoMem<wchar_t> current_app;
90 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL, 89 hr = registration->QueryCurrentDefault(protocols[i], AT_URLPROTOCOL,
91 AL_EFFECTIVE, &current_app); 90 AL_EFFECTIVE, &current_app);
92 if (FAILED(hr) || prog_id.compare(current_app) != 0) 91 if (FAILED(hr) || prog_id.compare(current_app) != 0)
93 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; 92 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT;
94 } 93 }
95 94
96 return ShellIntegration::IS_DEFAULT_WEB_CLIENT; 95 return ShellIntegration::IS_DEFAULT_WEB_CLIENT;
97 } 96 }
98 97
99 // Probe using IApplicationAssociationRegistration::QueryAppIsDefault (Vista and 98 // Probe using IApplicationAssociationRegistration::QueryAppIsDefault (Vista and
100 // Windows 7); see ProbeProtocolHandlers. 99 // Windows 7); see ProbeProtocolHandlers.
101 ShellIntegration::DefaultWebClientState ProbeAppIsDefaultHandlers( 100 ShellIntegration::DefaultWebClientState ProbeAppIsDefaultHandlers(
102 const wchar_t* const* protocols, 101 const wchar_t* const* protocols,
103 size_t num_protocols) { 102 size_t num_protocols) {
104 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration; 103 base::win::ScopedComPtr<IApplicationAssociationRegistration> registration;
105 HRESULT hr = registration.CreateInstance( 104 HRESULT hr = registration.CreateInstance(
106 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC); 105 CLSID_ApplicationAssociationRegistration, NULL, CLSCTX_INPROC);
107 if (FAILED(hr)) 106 if (FAILED(hr))
108 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT; 107 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT;
109 108
110 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 109 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
110 FilePath chrome_exe;
111 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
112 NOTREACHED();
113 return ShellIntegration::UNKNOWN_DEFAULT_WEB_CLIENT;
114 }
111 string16 app_name(dist->GetApplicationName()); 115 string16 app_name(dist->GetApplicationName());
112 116 app_name += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value());
113 // If a user specific default browser entry exists, we check for that
114 // app name being default. If not, then default browser is just called
115 // Google Chrome or Chromium so we do not append a suffix to the app name.
116 string16 suffix;
117 if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(dist, &suffix))
118 app_name += suffix;
119 117
120 BOOL result; 118 BOOL result;
121 for (size_t i = 0; i < num_protocols; ++i) { 119 for (size_t i = 0; i < num_protocols; ++i) {
122 result = TRUE; 120 result = TRUE;
123 hr = registration->QueryAppIsDefault(protocols[i], AT_URLPROTOCOL, 121 hr = registration->QueryAppIsDefault(protocols[i], AT_URLPROTOCOL,
124 AL_EFFECTIVE, app_name.c_str(), &result); 122 AL_EFFECTIVE, app_name.c_str(), &result);
125 if (FAILED(hr) || result == FALSE) 123 if (FAILED(hr) || result == FALSE)
126 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; 124 return ShellIntegration::NOT_DEFAULT_WEB_CLIENT;
127 } 125 }
128 126
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 BrowserThread::PostTask( 594 BrowserThread::PostTask(
597 BrowserThread::FILE, FROM_HERE, 595 BrowserThread::FILE, FROM_HERE,
598 base::Bind(&MigrateChromiumShortcutsCallback)); 596 base::Bind(&MigrateChromiumShortcutsCallback));
599 } 597 }
600 598
601 bool ShellIntegration::ActivateMetroChrome() { 599 bool ShellIntegration::ActivateMetroChrome() {
602 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 600 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
603 const string16 app_id(dist->GetBrowserAppId()); 601 const string16 app_id(dist->GetBrowserAppId());
604 return ActivateApplication(app_id); 602 return ActivateApplication(app_id);
605 } 603 }
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698