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

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 21259: Fix bugs related to making Chrome default browser on Vista. (Closed)
Patch Set: after merge Created 11 years, 10 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
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/util_constants.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include <windows.h> 10 #include <windows.h>
11 #include <shellapi.h> 11 #include <shellapi.h>
12 #include <shlobj.h> 12 #include <shlobj.h>
13 13
14 #include "chrome/installer/util/shell_util.h" 14 #include "chrome/installer/util/shell_util.h"
15 15
16 #include "base/command_line.h"
16 #include "base/file_path.h" 17 #include "base/file_path.h"
17 #include "base/file_util.h" 18 #include "base/file_util.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/path_service.h" 20 #include "base/path_service.h"
20 #include "base/registry.h" 21 #include "base/registry.h"
21 #include "base/scoped_ptr.h" 22 #include "base/scoped_ptr.h"
22 #include "base/string_util.h" 23 #include "base/string_util.h"
23 #include "base/win_util.h" 24 #include "base/win_util.h"
24 #include "chrome/common/chrome_constants.h" 25 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 for (std::list<RegistryEntry*>::iterator itr = entries.begin(); 213 for (std::list<RegistryEntry*>::iterator itr = entries.begin();
213 itr != entries.end(); ++itr) { 214 itr != entries.end(); ++itr) {
214 if (registered && !(*itr)->ExistsInHKLM()) 215 if (registered && !(*itr)->ExistsInHKLM())
215 registered = false; 216 registered = false;
216 delete (*itr); 217 delete (*itr);
217 } 218 }
218 LOG(INFO) << "Check for Chrome registeration returned " << registered; 219 LOG(INFO) << "Check for Chrome registeration returned " << registered;
219 return registered; 220 return registered;
220 } 221 }
221 222
222 bool CreateChromeRegKeysForXP(HKEY root_key, const std::wstring& chrome_exe) { 223 bool BindChromeAssociations(HKEY root_key, const std::wstring& chrome_exe) {
223 // Create a list of registry entries to create so that we can rollback 224 // Create a list of registry entries to create so that we can rollback
224 // in case of problem. 225 // in case of problem.
225 scoped_ptr<WorkItemList> items(WorkItem::CreateWorkItemList()); 226 scoped_ptr<WorkItemList> items(WorkItem::CreateWorkItemList());
226 std::wstring classes_path(ShellUtil::kRegClasses);
227
228 std::wstring exe_name = file_util::GetFilenameFromPath(chrome_exe);
229 std::wstring chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
230 std::wstring chrome_icon(chrome_exe);
231 ShellUtil::GetChromeIcon(chrome_icon);
232
233 // Create Software\Classes\ChromeHTML
234 std::wstring html_prog_id = classes_path + L"\\" +
235 ShellUtil::kChromeHTMLProgId;
236 items->AddCreateRegKeyWorkItem(root_key, html_prog_id);
237 items->AddSetRegValueWorkItem(root_key, html_prog_id,
238 L"", ShellUtil::kChromeHTMLProgIdDesc, true);
239 items->AddSetRegValueWorkItem(root_key, html_prog_id,
240 ShellUtil::kRegUrlProtocol, L"", true);
241 std::wstring default_icon = html_prog_id + ShellUtil::kRegDefaultIcon;
242 items->AddCreateRegKeyWorkItem(root_key, default_icon);
243 items->AddSetRegValueWorkItem(root_key, default_icon, L"",
244 chrome_icon, true);
245 std::wstring open_cmd = html_prog_id + ShellUtil::kRegShellOpen;
246 items->AddCreateRegKeyWorkItem(root_key, open_cmd);
247 items->AddSetRegValueWorkItem(root_key, open_cmd, L"",
248 chrome_open, true);
249 227
250 // file extension associations 228 // file extension associations
229 std::wstring classes_path(ShellUtil::kRegClasses);
251 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 230 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) {
252 std::wstring key_path = classes_path + L"\\" + 231 std::wstring key_path = classes_path + L"\\" +
253 ShellUtil::kFileAssociations[i]; 232 ShellUtil::kFileAssociations[i];
254 items->AddCreateRegKeyWorkItem(root_key, key_path); 233 items->AddCreateRegKeyWorkItem(root_key, key_path);
255 items->AddSetRegValueWorkItem(root_key, key_path, L"", 234 items->AddSetRegValueWorkItem(root_key, key_path, L"",
256 ShellUtil::kChromeHTMLProgId, true); 235 ShellUtil::kChromeHTMLProgId, true);
257 } 236 }
258 237
259 // protocols associations 238 // protocols associations
239 std::wstring chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
240 std::wstring chrome_icon(chrome_exe);
241 ShellUtil::GetChromeIcon(chrome_icon);
260 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) { 242 for (int i = 0; ShellUtil::kProtocolAssociations[i] != NULL; i++) {
261 std::wstring key_path = classes_path + L"\\" + 243 std::wstring key_path = classes_path + L"\\" +
262 ShellUtil::kProtocolAssociations[i]; 244 ShellUtil::kProtocolAssociations[i];
263 // <root hkey>\Software\Classes\<protocol>\DefaultIcon 245 // <root hkey>\Software\Classes\<protocol>\DefaultIcon
264 std::wstring icon_path = key_path + ShellUtil::kRegDefaultIcon; 246 std::wstring icon_path = key_path + ShellUtil::kRegDefaultIcon;
265 items->AddCreateRegKeyWorkItem(root_key, icon_path); 247 items->AddCreateRegKeyWorkItem(root_key, icon_path);
266 items->AddSetRegValueWorkItem(root_key, icon_path, L"", 248 items->AddSetRegValueWorkItem(root_key, icon_path, L"",
267 chrome_icon, true); 249 chrome_icon, true);
268 // <root hkey>\Software\Classes\<protocol>\shell\open\command 250 // <root hkey>\Software\Classes\<protocol>\shell\open\command
269 std::wstring shell_path = key_path + ShellUtil::kRegShellOpen; 251 std::wstring shell_path = key_path + ShellUtil::kRegShellOpen;
270 items->AddCreateRegKeyWorkItem(root_key, shell_path); 252 items->AddCreateRegKeyWorkItem(root_key, shell_path);
271 items->AddSetRegValueWorkItem(root_key, shell_path, L"", 253 items->AddSetRegValueWorkItem(root_key, shell_path, L"",
272 chrome_open, true); 254 chrome_open, true);
273 // <root hkey>\Software\Classes\<protocol>\shell\open\ddeexec 255 // <root hkey>\Software\Classes\<protocol>\shell\open\ddeexec
274 std::wstring dde_path = key_path + L"\\shell\\open\\ddeexec"; 256 std::wstring dde_path = key_path + L"\\shell\\open\\ddeexec";
275 items->AddCreateRegKeyWorkItem(root_key, dde_path); 257 items->AddCreateRegKeyWorkItem(root_key, dde_path);
276 items->AddSetRegValueWorkItem(root_key, dde_path, L"", L"", true); 258 items->AddSetRegValueWorkItem(root_key, dde_path, L"", L"", true);
277 // <root hkey>\Software\Classes\<protocol>\shell\@ 259 // <root hkey>\Software\Classes\<protocol>\shell\@
278 std::wstring protocol_shell_path = key_path + ShellUtil::kRegShellPath; 260 std::wstring protocol_shell_path = key_path + ShellUtil::kRegShellPath;
279 items->AddSetRegValueWorkItem(root_key, protocol_shell_path, L"", 261 items->AddSetRegValueWorkItem(root_key, protocol_shell_path, L"",
280 L"open", true); 262 L"open", true);
281 } 263 }
282 264
283 // start->Internet shortcut. 265 // start->Internet shortcut.
266 std::wstring exe_name = file_util::GetFilenameFromPath(chrome_exe);
284 std::wstring start_internet(ShellUtil::kRegStartMenuInternet); 267 std::wstring start_internet(ShellUtil::kRegStartMenuInternet);
285 items->AddCreateRegKeyWorkItem(root_key, start_internet); 268 items->AddCreateRegKeyWorkItem(root_key, start_internet);
286 items->AddSetRegValueWorkItem(root_key, start_internet, L"", 269 items->AddSetRegValueWorkItem(root_key, start_internet, L"",
287 exe_name, true); 270 exe_name, true);
288 271
289 // Apply all the registry changes and if there is a problem, rollback 272 // Apply all the registry changes and if there is a problem, rollback
290 if (!items->Do()) { 273 if (!items->Do()) {
291 LOG(ERROR) << "Error while registering Chrome as default browser"; 274 LOG(ERROR) << "Error while registering Chrome as default browser";
292 items->Rollback(); 275 items->Rollback();
293 return false; 276 return false;
294 } 277 }
295 return true; 278 return true;
296 } 279 }
297 280
281 // Populate work_item_list with WorkItem entries that will add chrome.exe to
282 // the set of App Paths registry keys so that ShellExecute can find it. Note
283 // that this is done in HKLM, regardless of whether this is a single-user
284 // install or not. For non-admin users, this will fail.
285 // chrome_exe: full path to chrome.exe
286 // work_item_list: pointer to the WorkItemList that will be populated
287 void AddChromeAppPathWorkItems(const std::wstring& chrome_exe,
288 WorkItemList* item_list) {
289 FilePath chrome_path(chrome_exe);
290 std::wstring app_path_key(ShellUtil::kAppPathsRegistryKey);
291 file_util::AppendToPath(&app_path_key, chrome_path.BaseName().value());
292 item_list->AddCreateRegKeyWorkItem(HKEY_LOCAL_MACHINE, app_path_key);
293 item_list->AddSetRegValueWorkItem(HKEY_LOCAL_MACHINE, app_path_key, L"",
294 chrome_exe, true);
295 item_list->AddSetRegValueWorkItem(HKEY_LOCAL_MACHINE, app_path_key,
296 ShellUtil::kAppPathsRegistryPathName,
297 chrome_path.DirName().value(), true);
298 }
299
298 // This method creates the registry entries required for Add/Remove Programs-> 300 // This method creates the registry entries required for Add/Remove Programs->
299 // Set Program Access and Defaults, Start->Default Programs on Windows Vista 301 // Set Program Access and Defaults, Start->Default Programs on Windows Vista
300 // and Chrome ProgIds for file extension and protocol handler. root_key is 302 // and Chrome ProgIds for file extension and protocol handler. root_key is
301 // the root registry (HKLM or HKCU). 303 // the root registry (HKLM or HKCU).
302 bool SetAccessDefaultRegEntries(HKEY root_key, 304 bool SetAccessDefaultRegEntries(HKEY root_key,
303 const std::wstring& chrome_exe) { 305 const std::wstring& chrome_exe) {
304 LOG(INFO) << "Registering Chrome browser " << chrome_exe; 306 LOG(INFO) << "Registering Chrome browser " << chrome_exe;
305 // Create a list of registry entries work items so that we can rollback 307 // Create a list of registry entries work items so that we can rollback
306 // in case of problem. 308 // in case of problem.
307 scoped_ptr<WorkItemList> items(WorkItem::CreateWorkItemList()); 309 scoped_ptr<WorkItemList> items(WorkItem::CreateWorkItemList());
308 310
309 std::list<RegistryEntry*> entries = RegistryEntry::GetAllEntries(chrome_exe); 311 std::list<RegistryEntry*> entries = RegistryEntry::GetAllEntries(chrome_exe);
310 for (std::list<RegistryEntry*>::iterator itr = entries.begin(); 312 for (std::list<RegistryEntry*>::iterator itr = entries.begin();
311 itr != entries.end(); ++itr) { 313 itr != entries.end(); ++itr) {
312 (*itr)->AddToWorkItemList(root_key, items.get()); 314 (*itr)->AddToWorkItemList(root_key, items.get());
313 delete (*itr); 315 delete (*itr);
314 } 316 }
315 317
316 // Append the App Paths registry entries. Do this only if we are an admin, 318 // Append the App Paths registry entries. Do this only if we are an admin,
317 // since they are always written to HKLM. 319 // since they are always written to HKLM.
318 if (IsUserAnAdmin()) 320 if (IsUserAnAdmin())
319 ShellUtil::AddChromeAppPathWorkItems(chrome_exe, items.get()); 321 AddChromeAppPathWorkItems(chrome_exe, items.get());
320 322
321 // Apply all the registry changes and if there is a problem, rollback. 323 // Apply all the registry changes and if there is a problem, rollback.
322 if (!items->Do()) { 324 if (!items->Do()) {
323 LOG(ERROR) << "Failed to add Chrome to Set Program Access and Defaults"; 325 LOG(ERROR) << "Failed to add Chrome to Set Program Access and Defaults";
324 items->Rollback(); 326 items->Rollback();
325 return false; 327 return false;
326 } 328 }
327 329
328 return true; 330 return true;
329 } 331 }
(...skipping 10 matching lines...) Expand all
340 SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe)) 342 SetAccessDefaultRegEntries(HKEY_LOCAL_MACHINE, chrome_exe))
341 return ShellUtil::SUCCESS; 343 return ShellUtil::SUCCESS;
342 344
343 if (!skip_if_not_admin) { 345 if (!skip_if_not_admin) {
344 std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe)); 346 std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe));
345 file_util::AppendToPath(&exe_path, installer_util::kSetupExe); 347 file_util::AppendToPath(&exe_path, installer_util::kSetupExe);
346 if (!file_util::PathExists(exe_path)) { 348 if (!file_util::PathExists(exe_path)) {
347 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 349 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
348 RegKey key(HKEY_CURRENT_USER, dist->GetUninstallRegPath().c_str()); 350 RegKey key(HKEY_CURRENT_USER, dist->GetUninstallRegPath().c_str());
349 key.ReadValue(installer_util::kUninstallStringField, &exe_path); 351 key.ReadValue(installer_util::kUninstallStringField, &exe_path);
350 exe_path = exe_path.substr(0, exe_path.find_first_of(L" --")); 352 CommandLine command_line(L"");
351 TrimString(exe_path, L" \"", &exe_path); 353 command_line.ParseFromString(exe_path);
354 exe_path = command_line.program();
352 } 355 }
353 if (file_util::PathExists(exe_path)) { 356 if (file_util::PathExists(exe_path)) {
354 std::wstring params(L"--"); 357 std::wstring params(L"--");
355 params.append(installer_util::switches::kRegisterChromeBrowser); 358 params.append(installer_util::switches::kRegisterChromeBrowser);
356 params.append(L"=\"" + chrome_exe + L"\""); 359 params.append(L"=\"" + chrome_exe + L"\"");
357 DWORD ret_val = ShellUtil::SUCCESS; 360 DWORD ret_val = ShellUtil::SUCCESS;
358 InstallUtil::ExecuteExeAsAdmin(exe_path, params, &ret_val); 361 InstallUtil::ExecuteExeAsAdmin(exe_path, params, &ret_val);
359 if (ret_val == ShellUtil::SUCCESS) 362 if (ret_val == ShellUtil::SUCCESS)
360 return ShellUtil::SUCCESS; 363 return ShellUtil::SUCCESS;
361 } 364 }
362 } 365 }
363 return ShellUtil::FAILURE; 366 return ShellUtil::FAILURE;
364 } 367 }
365 368
366 } // namespace 369 } // namespace
367 370
368 371
369 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; 372 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon";
370 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; 373 const wchar_t* ShellUtil::kRegShellPath = L"\\shell";
371 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; 374 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command";
372 const wchar_t* ShellUtil::kRegStartMenuInternet = 375 const wchar_t* ShellUtil::kRegStartMenuInternet =
373 L"Software\\Clients\\StartMenuInternet"; 376 L"Software\\Clients\\StartMenuInternet";
374 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes"; 377 const wchar_t* ShellUtil::kRegClasses = L"Software\\Classes";
375 const wchar_t* ShellUtil::kRegRegisteredApplications = 378 const wchar_t* ShellUtil::kRegRegisteredApplications =
376 L"Software\\RegisteredApplications"; 379 L"Software\\RegisteredApplications";
377 const wchar_t* ShellUtil::kRegVistaUrlPrefs = 380 const wchar_t* ShellUtil::kRegVistaUrlPrefs =
378 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\ UserChoice"; 381 L"Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\ UserChoice";
382 const wchar_t* ShellUtil::kAppPathsRegistryKey =
383 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths";
384 const wchar_t* ShellUtil::kAppPathsRegistryPathName = L"Path";
379 385
380 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML"; 386 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromeHTML";
381 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML"; 387 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chrome HTML";
382 const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml", 388 const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml",
383 L".xht", L".xhtml", NULL}; 389 L".xht", L".xhtml", NULL};
384 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https", 390 const wchar_t* ShellUtil::kProtocolAssociations[] = {L"ftp", L"http", L"https",
385 NULL}; 391 NULL};
386 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; 392 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol";
387 393
388 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt"; 394 const wchar_t* ShellUtil::kChromeExtProgId = L"ChromeExt";
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } else { 470 } else {
465 if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 471 if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL,
466 SHGFP_TYPE_CURRENT, qlaunch))) 472 SHGFP_TYPE_CURRENT, qlaunch)))
467 return false; 473 return false;
468 *path = qlaunch; 474 *path = qlaunch;
469 } 475 }
470 file_util::AppendToPath(path, kQuickLaunchPath); 476 file_util::AppendToPath(path, kQuickLaunchPath);
471 return true; 477 return true;
472 } 478 }
473 479
474 void ShellUtil::AddChromeAppPathWorkItems(
475 const std::wstring& chrome_exe, WorkItemList* item_list) {
476 WorkItem* create_work_item = WorkItem::CreateCreateRegKeyWorkItem(
477 HKEY_LOCAL_MACHINE, installer_util::kAppPathsRegistryKey);
478
479 item_list->AddWorkItem(create_work_item);
480
481 WorkItem* set_default_value_work_item =
482 WorkItem::CreateSetRegValueWorkItem(HKEY_LOCAL_MACHINE,
483 installer_util::kAppPathsRegistryKey,
484 installer_util::kAppPathsRegistryDefaultName,
485 chrome_exe, true);
486 item_list->AddWorkItem(set_default_value_work_item);
487
488 FilePath chrome_path(chrome_exe);
489 WorkItem* set_path_value_work_item =
490 WorkItem::CreateSetRegValueWorkItem(HKEY_LOCAL_MACHINE,
491 installer_util::kAppPathsRegistryKey,
492 installer_util::kAppPathsRegistryPathName,
493 chrome_path.DirName().value(), true);
494 item_list->AddWorkItem(set_path_value_work_item);
495 }
496
497 bool ShellUtil::CreateChromeDesktopShortcut(const std::wstring& chrome_exe, 480 bool ShellUtil::CreateChromeDesktopShortcut(const std::wstring& chrome_exe,
498 int shell_change, 481 int shell_change,
499 bool create_new) { 482 bool create_new) {
500 std::wstring shortcut_name; 483 std::wstring shortcut_name;
501 if (!ShellUtil::GetChromeShortcutName(&shortcut_name)) 484 if (!ShellUtil::GetChromeShortcutName(&shortcut_name))
502 return false; 485 return false;
503 486
504 bool ret = true; 487 bool ret = true;
505 if (shell_change & ShellUtil::CURRENT_USER) { 488 if (shell_change & ShellUtil::CURRENT_USER) {
506 std::wstring shortcut_path; 489 std::wstring shortcut_path;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ret = false; 542 ret = false;
560 } 543 }
561 } 544 }
562 545
563 return ret; 546 return ret;
564 } 547 }
565 548
566 bool ShellUtil::MakeChromeDefault(int shell_change, 549 bool ShellUtil::MakeChromeDefault(int shell_change,
567 const std::wstring chrome_exe) { 550 const std::wstring chrome_exe) {
568 bool ret = true; 551 bool ret = true;
552 // First use the new "recommended" way on Vista to make Chrome default
553 // browser.
569 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) { 554 if (win_util::GetWinVersion() == win_util::WINVERSION_VISTA) {
570 LOG(INFO) << "Registering Chrome as default browser on Vista."; 555 LOG(INFO) << "Registering Chrome as default browser on Vista.";
571 IApplicationAssociationRegistration* pAAR; 556 IApplicationAssociationRegistration* pAAR;
572 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration, 557 HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
573 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), 558 NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration),
574 (void**)&pAAR); 559 (void**)&pAAR);
575 if (SUCCEEDED(hr)) { 560 if (SUCCEEDED(hr)) {
576 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 561 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
577 hr = pAAR->SetAppAsDefaultAll(dist->GetApplicationName().c_str()); 562 hr = pAAR->SetAppAsDefaultAll(dist->GetApplicationName().c_str());
578 pAAR->Release(); 563 pAAR->Release();
579 } 564 }
580 if (!SUCCEEDED(hr)) { 565 if (!SUCCEEDED(hr)) {
581 ret = false; 566 ret = false;
582 LOG(ERROR) << "Could not make Chrome default browser."; 567 LOG(ERROR) << "Could not make Chrome default browser.";
583 } 568 }
584 } else { 569 }
585 // Change the default browser for current user.
586 if ((shell_change & ShellUtil::CURRENT_USER) &&
587 !CreateChromeRegKeysForXP(HKEY_CURRENT_USER, chrome_exe))
588 ret = false;
589 570
590 // Chrome as default browser at system level. 571 // Now use the old way to associate Chrome with supported protocols and file
591 if ((shell_change & ShellUtil::SYSTEM_LEVEL) && 572 // associations. This should not be required on Vista but since some
592 !CreateChromeRegKeysForXP(HKEY_LOCAL_MACHINE, chrome_exe)) 573 // applications still read Software\Classes\http key directly, we have to do
593 ret = false; 574 // this on Vista also.
594 } 575 // Change the default browser for current user.
576 if ((shell_change & ShellUtil::CURRENT_USER) &&
577 !BindChromeAssociations(HKEY_CURRENT_USER, chrome_exe))
578 ret = false;
579
580 // Chrome as default browser at system level.
581 if ((shell_change & ShellUtil::SYSTEM_LEVEL) &&
582 !BindChromeAssociations(HKEY_LOCAL_MACHINE, chrome_exe))
583 ret = false;
595 584
596 // Send Windows notification event so that it can update icons for 585 // Send Windows notification event so that it can update icons for
597 // file associations. 586 // file associations.
598 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); 587 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
599 return ret; 588 return ret;
600 } 589 }
601 590
602 bool ShellUtil::RemoveChromeDesktopShortcut(int shell_change) { 591 bool ShellUtil::RemoveChromeDesktopShortcut(int shell_change) {
603 std::wstring shortcut_name; 592 std::wstring shortcut_name;
604 if (!ShellUtil::GetChromeShortcutName(&shortcut_name)) 593 if (!ShellUtil::GetChromeShortcutName(&shortcut_name))
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target 663 return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target
675 shortcut.c_str(), // shortcut 664 shortcut.c_str(), // shortcut
676 chrome_path.c_str(), // working dir 665 chrome_path.c_str(), // working dir
677 NULL, // arguments 666 NULL, // arguments
678 NULL, // description 667 NULL, // description
679 chrome_exe.c_str(), // icon file 668 chrome_exe.c_str(), // icon file
680 0); // icon index 669 0); // icon index
681 } 670 }
682 } 671 }
683 672
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/util_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698