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

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

Issue 14021010: Add file association for .webp to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed kFileAssociations to kDefaultFileAssociations Created 7 years, 7 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 | « chrome/installer/util/shell_util.h ('k') | no next file » | 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 // 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 "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 entries->push_back(new RegistryEntry( 392 entries->push_back(new RegistryEntry(
393 capabilities, ShellUtil::kRegApplicationIcon, icon_path)); 393 capabilities, ShellUtil::kRegApplicationIcon, icon_path));
394 entries->push_back(new RegistryEntry( 394 entries->push_back(new RegistryEntry(
395 capabilities, ShellUtil::kRegApplicationName, 395 capabilities, ShellUtil::kRegApplicationName,
396 dist->GetAppShortCutName())); 396 dist->GetAppShortCutName()));
397 397
398 entries->push_back(new RegistryEntry(capabilities + L"\\Startmenu", 398 entries->push_back(new RegistryEntry(capabilities + L"\\Startmenu",
399 L"StartMenuInternet", reg_app_name)); 399 L"StartMenuInternet", reg_app_name));
400 400
401 const string16 html_prog_id(GetBrowserProgId(suffix)); 401 const string16 html_prog_id(GetBrowserProgId(suffix));
402 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 402 for (int i = 0; ShellUtil::kPotentialFileAssociations[i] != NULL; i++) {
403 entries->push_back(new RegistryEntry( 403 entries->push_back(new RegistryEntry(
404 capabilities + L"\\FileAssociations", 404 capabilities + L"\\FileAssociations",
405 ShellUtil::kFileAssociations[i], html_prog_id)); 405 ShellUtil::kPotentialFileAssociations[i], html_prog_id));
406 } 406 }
407 for (int i = 0; ShellUtil::kPotentialProtocolAssociations[i] != NULL; 407 for (int i = 0; ShellUtil::kPotentialProtocolAssociations[i] != NULL;
408 i++) { 408 i++) {
409 entries->push_back(new RegistryEntry( 409 entries->push_back(new RegistryEntry(
410 capabilities + L"\\URLAssociations", 410 capabilities + L"\\URLAssociations",
411 ShellUtil::kPotentialProtocolAssociations[i], html_prog_id)); 411 ShellUtil::kPotentialProtocolAssociations[i], html_prog_id));
412 } 412 }
413 } 413 }
414 414
415 // This method returns a list of the registry entries required for this 415 // This method returns a list of the registry entries required for this
416 // installation to be registered in the Windows shell. 416 // installation to be registered in the Windows shell.
417 // In particular: 417 // In particular:
418 // - App Paths 418 // - App Paths
419 // http://msdn.microsoft.com/en-us/library/windows/desktop/ee872121 419 // http://msdn.microsoft.com/en-us/library/windows/desktop/ee872121
420 // - File Associations 420 // - File Associations
421 // http://msdn.microsoft.com/en-us/library/bb166549 421 // http://msdn.microsoft.com/en-us/library/bb166549
422 // These entries need to be registered in HKLM prior to Win8. 422 // These entries need to be registered in HKLM prior to Win8.
423 static void GetAppRegistrationEntries(const string16& chrome_exe, 423 static void GetAppRegistrationEntries(const string16& chrome_exe,
424 const string16& suffix, 424 const string16& suffix,
425 ScopedVector<RegistryEntry>* entries) { 425 ScopedVector<RegistryEntry>* entries) {
426 const base::FilePath chrome_path(chrome_exe); 426 const base::FilePath chrome_path(chrome_exe);
427 string16 app_path_key(ShellUtil::kAppPathsRegistryKey); 427 string16 app_path_key(ShellUtil::kAppPathsRegistryKey);
428 app_path_key.push_back(base::FilePath::kSeparators[0]); 428 app_path_key.push_back(base::FilePath::kSeparators[0]);
429 app_path_key.append(chrome_path.BaseName().value()); 429 app_path_key.append(chrome_path.BaseName().value());
430 entries->push_back(new RegistryEntry(app_path_key, chrome_exe)); 430 entries->push_back(new RegistryEntry(app_path_key, chrome_exe));
431 entries->push_back(new RegistryEntry(app_path_key, 431 entries->push_back(new RegistryEntry(app_path_key,
432 ShellUtil::kAppPathsRegistryPathName, chrome_path.DirName().value())); 432 ShellUtil::kAppPathsRegistryPathName, chrome_path.DirName().value()));
433 433
434 const string16 html_prog_id(GetBrowserProgId(suffix)); 434 const string16 html_prog_id(GetBrowserProgId(suffix));
435 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 435 for (int i = 0; ShellUtil::kPotentialFileAssociations[i] != NULL; i++) {
436 string16 key(ShellUtil::kRegClasses); 436 string16 key(ShellUtil::kRegClasses);
437 key.push_back(base::FilePath::kSeparators[0]); 437 key.push_back(base::FilePath::kSeparators[0]);
438 key.append(ShellUtil::kFileAssociations[i]); 438 key.append(ShellUtil::kPotentialFileAssociations[i]);
439 key.push_back(base::FilePath::kSeparators[0]); 439 key.push_back(base::FilePath::kSeparators[0]);
440 key.append(ShellUtil::kRegOpenWithProgids); 440 key.append(ShellUtil::kRegOpenWithProgids);
441 entries->push_back(new RegistryEntry(key, html_prog_id, string16())); 441 entries->push_back(new RegistryEntry(key, html_prog_id, string16()));
442 } 442 }
443 } 443 }
444 444
445 // This method returns a list of all the user level registry entries that 445 // This method returns a list of all the user level registry entries that
446 // are needed to make Chromium the default handler for a protocol on XP. 446 // are needed to make Chromium the default handler for a protocol on XP.
447 static void GetXPStyleUserProtocolEntries( 447 static void GetXPStyleUserProtocolEntries(
448 const string16& protocol, 448 const string16& protocol,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // Some of these entries are irrelevant in recent versions of Windows, but 482 // Some of these entries are irrelevant in recent versions of Windows, but
483 // we register them anyways as some legacy apps are hardcoded to lookup those 483 // we register them anyways as some legacy apps are hardcoded to lookup those
484 // values. 484 // values.
485 static void GetXPStyleDefaultBrowserUserEntries( 485 static void GetXPStyleDefaultBrowserUserEntries(
486 BrowserDistribution* dist, 486 BrowserDistribution* dist,
487 const string16& chrome_exe, 487 const string16& chrome_exe,
488 const string16& suffix, 488 const string16& suffix,
489 ScopedVector<RegistryEntry>* entries) { 489 ScopedVector<RegistryEntry>* entries) {
490 // File extension associations. 490 // File extension associations.
491 string16 html_prog_id(GetBrowserProgId(suffix)); 491 string16 html_prog_id(GetBrowserProgId(suffix));
492 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 492 for (int i = 0; ShellUtil::kDefaultFileAssociations[i] != NULL; i++) {
493 string16 ext_key(ShellUtil::kRegClasses); 493 string16 ext_key(ShellUtil::kRegClasses);
494 ext_key.push_back(base::FilePath::kSeparators[0]); 494 ext_key.push_back(base::FilePath::kSeparators[0]);
495 ext_key.append(ShellUtil::kFileAssociations[i]); 495 ext_key.append(ShellUtil::kDefaultFileAssociations[i]);
496 entries->push_back(new RegistryEntry(ext_key, html_prog_id)); 496 entries->push_back(new RegistryEntry(ext_key, html_prog_id));
497 } 497 }
498 498
499 // Protocols associations. 499 // Protocols associations.
500 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); 500 string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
501 string16 chrome_icon = 501 string16 chrome_icon =
502 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex()); 502 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex());
503 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { 503 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) {
504 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], 504 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i],
505 chrome_icon, chrome_open, entries); 505 chrome_icon, chrome_open, entries);
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // because of http://crbug.com/153349 as with the '.' and 26 characters suffix 1213 // because of http://crbug.com/153349 as with the '.' and 26 characters suffix
1214 // added on user-level installs, the generated progid for Chromium was 39 1214 // added on user-level installs, the generated progid for Chromium was 39
1215 // characters long which, according to MSDN ( 1215 // characters long which, according to MSDN (
1216 // http://msdn.microsoft.com/library/aa911706.aspx), is the maximum length 1216 // http://msdn.microsoft.com/library/aa911706.aspx), is the maximum length
1217 // for a progid. It was however determined through experimentation that the 39 1217 // for a progid. It was however determined through experimentation that the 39
1218 // character limit mentioned on MSDN includes the NULL character... 1218 // character limit mentioned on MSDN includes the NULL character...
1219 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromiumHTM"; 1219 const wchar_t* ShellUtil::kChromeHTMLProgId = L"ChromiumHTM";
1220 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chromium HTML Document"; 1220 const wchar_t* ShellUtil::kChromeHTMLProgIdDesc = L"Chromium HTML Document";
1221 #endif 1221 #endif
1222 1222
1223 const wchar_t* ShellUtil::kFileAssociations[] = {L".htm", L".html", L".shtml", 1223 const wchar_t* ShellUtil::kDefaultFileAssociations[] = {L".htm", L".html",
1224 L".xht", L".xhtml", NULL}; 1224 L".shtml", L".xht", L".xhtml", NULL};
1225 const wchar_t* ShellUtil::kPotentialFileAssociations[] = {L".htm", L".html",
1226 L".shtml", L".xht", L".xhtml", L".webp", NULL};
1225 const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"ftp", L"http", 1227 const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"ftp", L"http",
1226 L"https", NULL}; 1228 L"https", NULL};
1227 const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = {L"ftp", L"http", 1229 const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = {L"ftp", L"http",
1228 L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", L"sms", L"smsto", 1230 L"https", L"irc", L"mailto", L"mms", L"news", L"nntp", L"sms", L"smsto",
1229 L"tel", L"urn", L"webcal", NULL}; 1231 L"tel", L"urn", L"webcal", NULL};
1230 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol"; 1232 const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol";
1231 const wchar_t* ShellUtil::kRegApplication = L"\\Application"; 1233 const wchar_t* ShellUtil::kRegApplication = L"\\Application";
1232 const wchar_t* ShellUtil::kRegAppUserModelId = L"AppUserModelId"; 1234 const wchar_t* ShellUtil::kRegAppUserModelId = L"AppUserModelId";
1233 const wchar_t* ShellUtil::kRegApplicationDescription = 1235 const wchar_t* ShellUtil::kRegApplicationDescription =
1234 L"ApplicationDescription"; 1236 L"ApplicationDescription";
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 hr = pAAR->SetAppAsDefault(app_name.c_str(), 1592 hr = pAAR->SetAppAsDefault(app_name.c_str(),
1591 ShellUtil::kBrowserProtocolAssociations[i], AT_URLPROTOCOL); 1593 ShellUtil::kBrowserProtocolAssociations[i], AT_URLPROTOCOL);
1592 if (!SUCCEEDED(hr)) { 1594 if (!SUCCEEDED(hr)) {
1593 ret = false; 1595 ret = false;
1594 LOG(ERROR) << "Failed to register as default for protocol " 1596 LOG(ERROR) << "Failed to register as default for protocol "
1595 << ShellUtil::kBrowserProtocolAssociations[i] 1597 << ShellUtil::kBrowserProtocolAssociations[i]
1596 << " (" << hr << ")"; 1598 << " (" << hr << ")";
1597 } 1599 }
1598 } 1600 }
1599 1601
1600 for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { 1602 for (int i = 0; ShellUtil::kDefaultFileAssociations[i] != NULL; i++) {
1601 hr = pAAR->SetAppAsDefault(app_name.c_str(), 1603 hr = pAAR->SetAppAsDefault(app_name.c_str(),
1602 ShellUtil::kFileAssociations[i], AT_FILEEXTENSION); 1604 ShellUtil::kDefaultFileAssociations[i], AT_FILEEXTENSION);
1603 if (!SUCCEEDED(hr)) { 1605 if (!SUCCEEDED(hr)) {
1604 ret = false; 1606 ret = false;
1605 LOG(ERROR) << "Failed to register as default for file extension " 1607 LOG(ERROR) << "Failed to register as default for file extension "
1606 << ShellUtil::kFileAssociations[i] << " (" << hr << ")"; 1608 << ShellUtil::kDefaultFileAssociations[i]
1609 << " (" << hr << ")";
1607 } 1610 }
1608 } 1611 }
1609 } 1612 }
1610 } 1613 }
1611 1614
1612 if (!RegisterChromeAsDefaultXPStyle(dist, shell_change, chrome_exe)) 1615 if (!RegisterChromeAsDefaultXPStyle(dist, shell_change, chrome_exe))
1613 ret = false; 1616 ret = false;
1614 1617
1615 // Send Windows notification event so that it can update icons for 1618 // Send Windows notification event so that it can update icons for
1616 // file associations. 1619 // file associations.
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 // are any left...). 2021 // are any left...).
2019 if (free_bits >= 8 && next_byte_index < size) { 2022 if (free_bits >= 8 && next_byte_index < size) {
2020 free_bits -= 8; 2023 free_bits -= 8;
2021 bit_stream += bytes[next_byte_index++] << free_bits; 2024 bit_stream += bytes[next_byte_index++] << free_bits;
2022 } 2025 }
2023 } 2026 }
2024 2027
2025 DCHECK_EQ(ret.length(), encoded_length); 2028 DCHECK_EQ(ret.length(), encoded_length);
2026 return ret; 2029 return ret;
2027 } 2030 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698