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

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

Issue 1926403002: Remove BrowserDistribution::SHORTCUT_APP_LAUNCHER (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160406-Mac-EnableAppLauncher0
Patch Set: lint headers Created 4 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
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/shell_util_unittest.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 // 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 } 344 }
345 345
346 // This method returns a list of all the registry entries that are needed to 346 // This method returns a list of all the registry entries that are needed to
347 // register this installation's ProgId and AppId. These entries need to be 347 // register this installation's ProgId and AppId. These entries need to be
348 // registered in HKLM prior to Win8. 348 // registered in HKLM prior to Win8.
349 void GetChromeProgIdEntries(BrowserDistribution* dist, 349 void GetChromeProgIdEntries(BrowserDistribution* dist,
350 const base::FilePath& chrome_exe, 350 const base::FilePath& chrome_exe,
351 const base::string16& suffix, 351 const base::string16& suffix,
352 ScopedVector<RegistryEntry>* entries) { 352 ScopedVector<RegistryEntry>* entries) {
353 int chrome_icon_index = 353 int chrome_icon_index = dist->GetIconIndex();
354 dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME);
355 354
356 ApplicationInfo app_info; 355 ApplicationInfo app_info;
357 app_info.prog_id = GetBrowserProgId(suffix); 356 app_info.prog_id = GetBrowserProgId(suffix);
358 app_info.file_type_name = dist->GetBrowserProgIdDesc(); 357 app_info.file_type_name = dist->GetBrowserProgIdDesc();
359 // File types associated with Chrome are just given the Chrome icon. 358 // File types associated with Chrome are just given the Chrome icon.
360 app_info.file_type_icon_path = chrome_exe; 359 app_info.file_type_icon_path = chrome_exe;
361 app_info.file_type_icon_index = chrome_icon_index; 360 app_info.file_type_icon_index = chrome_icon_index;
362 app_info.command_line = ShellUtil::GetChromeShellOpenCmd(chrome_exe); 361 app_info.command_line = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
363 // For user-level installs: entries for the app id will be in HKCU; thus we 362 // For user-level installs: entries for the app id will be in HKCU; thus we
364 // do not need a suffix on those entries. 363 // do not need a suffix on those entries.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 404
406 // This method returns a list of the registry entries required to register this 405 // This method returns a list of the registry entries required to register this
407 // installation in "RegisteredApplications" on Windows (to appear in Default 406 // installation in "RegisteredApplications" on Windows (to appear in Default
408 // Programs, StartMenuInternet, etc.). These entries need to be registered in 407 // Programs, StartMenuInternet, etc.). These entries need to be registered in
409 // HKLM prior to Win8. If |suffix| is not empty, these entries are guaranteed to 408 // HKLM prior to Win8. If |suffix| is not empty, these entries are guaranteed to
410 // be unique on this machine. 409 // be unique on this machine.
411 void GetShellIntegrationEntries(BrowserDistribution* dist, 410 void GetShellIntegrationEntries(BrowserDistribution* dist,
412 const base::FilePath& chrome_exe, 411 const base::FilePath& chrome_exe,
413 const base::string16& suffix, 412 const base::string16& suffix,
414 ScopedVector<RegistryEntry>* entries) { 413 ScopedVector<RegistryEntry>* entries) {
415 const base::string16 icon_path(ShellUtil::FormatIconLocation( 414 const base::string16 icon_path(
416 chrome_exe, dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME))); 415 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex()));
417 const base::string16 quoted_exe_path(L"\"" + chrome_exe.value() + L"\""); 416 const base::string16 quoted_exe_path(L"\"" + chrome_exe.value() + L"\"");
418 417
419 // Register for the Start Menu "Internet" link (pre-Win7). 418 // Register for the Start Menu "Internet" link (pre-Win7).
420 const base::string16 start_menu_entry(GetBrowserClientKey(dist, suffix)); 419 const base::string16 start_menu_entry(GetBrowserClientKey(dist, suffix));
421 // Register Chrome's display name. 420 // Register Chrome's display name.
422 // TODO(grt): http://crbug.com/75152 Also set LocalizedString; see 421 // TODO(grt): http://crbug.com/75152 Also set LocalizedString; see
423 // http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109(v=VS.85).a spx#registering_the_display_name 422 // http://msdn.microsoft.com/en-us/library/windows/desktop/cc144109(v=VS.85).a spx#registering_the_display_name
424 entries->push_back( 423 entries->push_back(
425 new RegistryEntry(start_menu_entry, dist->GetDisplayName())); 424 new RegistryEntry(start_menu_entry, dist->GetDisplayName()));
426 // Register the "open" verb for launching Chrome via the "Internet" link. 425 // Register the "open" verb for launching Chrome via the "Internet" link.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 ScopedVector<RegistryEntry>* entries) { 592 ScopedVector<RegistryEntry>* entries) {
594 // File extension associations. 593 // File extension associations.
595 base::string16 html_prog_id(GetBrowserProgId(suffix)); 594 base::string16 html_prog_id(GetBrowserProgId(suffix));
596 for (int i = 0; ShellUtil::kDefaultFileAssociations[i] != NULL; i++) { 595 for (int i = 0; ShellUtil::kDefaultFileAssociations[i] != NULL; i++) {
597 GetAppDefaultRegistrationEntries( 596 GetAppDefaultRegistrationEntries(
598 html_prog_id, ShellUtil::kDefaultFileAssociations[i], true, entries); 597 html_prog_id, ShellUtil::kDefaultFileAssociations[i], true, entries);
599 } 598 }
600 599
601 // Protocols associations. 600 // Protocols associations.
602 base::string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe); 601 base::string16 chrome_open = ShellUtil::GetChromeShellOpenCmd(chrome_exe);
603 base::string16 chrome_icon = ShellUtil::FormatIconLocation( 602 base::string16 chrome_icon =
604 chrome_exe, dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME)); 603 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex());
605 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) { 604 for (int i = 0; ShellUtil::kBrowserProtocolAssociations[i] != NULL; i++) {
606 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i], 605 GetXPStyleUserProtocolEntries(ShellUtil::kBrowserProtocolAssociations[i],
607 chrome_icon, chrome_open, entries); 606 chrome_icon, chrome_open, entries);
608 } 607 }
609 608
610 // start->Internet shortcut. 609 // start->Internet shortcut.
611 base::string16 start_menu(ShellUtil::kRegStartMenuInternet); 610 base::string16 start_menu(ShellUtil::kRegStartMenuInternet);
612 base::string16 app_name = dist->GetBaseAppName() + suffix; 611 base::string16 app_name = dist->GetBaseAppName() + suffix;
613 entries->push_back(new RegistryEntry(start_menu, app_name)); 612 entries->push_back(new RegistryEntry(start_menu, app_name));
614 } 613 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 // keys directly, we have to do this on Vista+ as well. 911 // keys directly, we have to do this on Vista+ as well.
913 // See http://msdn.microsoft.com/library/aa767914.aspx for more details. 912 // See http://msdn.microsoft.com/library/aa767914.aspx for more details.
914 bool RegisterChromeAsDefaultProtocolClientXPStyle( 913 bool RegisterChromeAsDefaultProtocolClientXPStyle(
915 BrowserDistribution* dist, 914 BrowserDistribution* dist,
916 const base::FilePath& chrome_exe, 915 const base::FilePath& chrome_exe,
917 const base::string16& protocol) { 916 const base::string16& protocol) {
918 ScopedVector<RegistryEntry> entries; 917 ScopedVector<RegistryEntry> entries;
919 const base::string16 chrome_open( 918 const base::string16 chrome_open(
920 ShellUtil::GetChromeShellOpenCmd(chrome_exe)); 919 ShellUtil::GetChromeShellOpenCmd(chrome_exe));
921 const base::string16 chrome_icon( 920 const base::string16 chrome_icon(
922 ShellUtil::FormatIconLocation( 921 ShellUtil::FormatIconLocation(chrome_exe, dist->GetIconIndex()));
923 chrome_exe,
924 dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME)));
925 GetXPStyleUserProtocolEntries(protocol, chrome_icon, chrome_open, &entries); 922 GetXPStyleUserProtocolEntries(protocol, chrome_icon, chrome_open, &entries);
926 // Change the default protocol handler for current user. 923 // Change the default protocol handler for current user.
927 if (!ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries)) { 924 if (!ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries)) {
928 LOG(ERROR) << "Could not make Chrome default protocol client (XP)."; 925 LOG(ERROR) << "Could not make Chrome default protocol client (XP).";
929 return false; 926 return false;
930 } 927 }
931 928
932 return true; 929 return true;
933 } 930 }
934 931
935 // Returns |properties.shortcut_name| if the property is set, otherwise it 932 // Returns |properties.shortcut_name| if the property is set, otherwise it
936 // returns dist->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME). In any 933 // returns dist->GetShortcutName(). In any case, it makes sure the return value
937 // case, it makes sure the return value is suffixed with ".lnk". 934 // is suffixed with ".lnk".
938 base::string16 ExtractShortcutNameFromProperties( 935 base::string16 ExtractShortcutNameFromProperties(
939 BrowserDistribution* dist, 936 BrowserDistribution* dist,
940 const ShellUtil::ShortcutProperties& properties) { 937 const ShellUtil::ShortcutProperties& properties) {
941 DCHECK(dist); 938 DCHECK(dist);
942 base::string16 shortcut_name; 939 base::string16 shortcut_name = properties.has_shortcut_name()
943 if (properties.has_shortcut_name()) { 940 ? properties.shortcut_name
944 shortcut_name = properties.shortcut_name; 941 : dist->GetShortcutName();
945 } else {
946 shortcut_name =
947 dist->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME);
948 }
949 942
950 if (!base::EndsWith(shortcut_name, installer::kLnkExt, 943 if (!base::EndsWith(shortcut_name, installer::kLnkExt,
951 base::CompareCase::INSENSITIVE_ASCII)) 944 base::CompareCase::INSENSITIVE_ASCII))
952 shortcut_name.append(installer::kLnkExt); 945 shortcut_name.append(installer::kLnkExt);
953 946
954 return shortcut_name; 947 return shortcut_name;
955 } 948 }
956 949
957 // Converts ShellUtil::ShortcutOperation to the best-matching value in 950 // Converts ShellUtil::ShortcutOperation to the best-matching value in
958 // base::win::ShortcutOperation. 951 // base::win::ShortcutOperation.
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 itr != entries.end(); ++itr) 2380 itr != entries.end(); ++itr)
2388 (*itr)->AddToWorkItemList(root, items.get()); 2381 (*itr)->AddToWorkItemList(root, items.get());
2389 2382
2390 // Apply all the registry changes and if there is a problem, rollback 2383 // Apply all the registry changes and if there is a problem, rollback
2391 if (!items->Do()) { 2384 if (!items->Do()) {
2392 items->Rollback(); 2385 items->Rollback();
2393 return false; 2386 return false;
2394 } 2387 }
2395 return true; 2388 return true;
2396 } 2389 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.h ('k') | chrome/installer/util/shell_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698