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.h

Issue 94013004: Add base:: to string16s in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 7 years 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/product_operations.h ('k') | chrome/installer/util/shell_util.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 declares methods that are useful for integrating Chrome in 5 // This file declares methods that are useful for integrating Chrome in
6 // Windows shell. These methods are all static and currently part of 6 // Windows shell. These methods are all static and currently part of
7 // ShellUtil class. 7 // ShellUtil class.
8 8
9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 9 #ifndef CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 10 #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Sets the target executable to launch from this shortcut. 91 // Sets the target executable to launch from this shortcut.
92 // This is mandatory when creating a shortcut. 92 // This is mandatory when creating a shortcut.
93 void set_target(const base::FilePath& target_in) { 93 void set_target(const base::FilePath& target_in) {
94 target = target_in; 94 target = target_in;
95 options |= PROPERTIES_TARGET; 95 options |= PROPERTIES_TARGET;
96 } 96 }
97 97
98 // Sets the arguments to be passed to |target| when launching from this 98 // Sets the arguments to be passed to |target| when launching from this
99 // shortcut. 99 // shortcut.
100 // The length of this string must be less than MAX_PATH. 100 // The length of this string must be less than MAX_PATH.
101 void set_arguments(const string16& arguments_in) { 101 void set_arguments(const base::string16& arguments_in) {
102 // Size restriction as per MSDN at 102 // Size restriction as per MSDN at
103 // http://msdn.microsoft.com/library/windows/desktop/bb774954.aspx. 103 // http://msdn.microsoft.com/library/windows/desktop/bb774954.aspx.
104 DCHECK(arguments_in.length() < MAX_PATH); 104 DCHECK(arguments_in.length() < MAX_PATH);
105 arguments = arguments_in; 105 arguments = arguments_in;
106 options |= PROPERTIES_ARGUMENTS; 106 options |= PROPERTIES_ARGUMENTS;
107 } 107 }
108 108
109 // Sets the localized description of the shortcut. 109 // Sets the localized description of the shortcut.
110 // The length of this string must be less than MAX_PATH. 110 // The length of this string must be less than MAX_PATH.
111 void set_description(const string16& description_in) { 111 void set_description(const base::string16& description_in) {
112 // Size restriction as per MSDN at 112 // Size restriction as per MSDN at
113 // http://msdn.microsoft.com/library/windows/desktop/bb774955.aspx. 113 // http://msdn.microsoft.com/library/windows/desktop/bb774955.aspx.
114 DCHECK(description_in.length() < MAX_PATH); 114 DCHECK(description_in.length() < MAX_PATH);
115 description = description_in; 115 description = description_in;
116 options |= PROPERTIES_DESCRIPTION; 116 options |= PROPERTIES_DESCRIPTION;
117 } 117 }
118 118
119 // Sets the path to the icon (icon_index set to 0). 119 // Sets the path to the icon (icon_index set to 0).
120 // icon index unless otherwise specified in master_preferences). 120 // icon index unless otherwise specified in master_preferences).
121 void set_icon(const base::FilePath& icon_in, int icon_index_in) { 121 void set_icon(const base::FilePath& icon_in, int icon_index_in) {
122 icon = icon_in; 122 icon = icon_in;
123 icon_index = icon_index_in; 123 icon_index = icon_index_in;
124 options |= PROPERTIES_ICON; 124 options |= PROPERTIES_ICON;
125 } 125 }
126 126
127 // Sets the app model id for the shortcut (Win7+). 127 // Sets the app model id for the shortcut (Win7+).
128 void set_app_id(const string16& app_id_in) { 128 void set_app_id(const base::string16& app_id_in) {
129 app_id = app_id_in; 129 app_id = app_id_in;
130 options |= PROPERTIES_APP_ID; 130 options |= PROPERTIES_APP_ID;
131 } 131 }
132 132
133 // Forces the shortcut's name to |shortcut_name_in|. 133 // Forces the shortcut's name to |shortcut_name_in|.
134 // Default: the current distribution's GetShortcutName(SHORTCUT_CHROME). 134 // Default: the current distribution's GetShortcutName(SHORTCUT_CHROME).
135 // The ".lnk" extension will automatically be added to this name. 135 // The ".lnk" extension will automatically be added to this name.
136 void set_shortcut_name(const string16& shortcut_name_in) { 136 void set_shortcut_name(const base::string16& shortcut_name_in) {
137 shortcut_name = shortcut_name_in; 137 shortcut_name = shortcut_name_in;
138 options |= PROPERTIES_SHORTCUT_NAME; 138 options |= PROPERTIES_SHORTCUT_NAME;
139 } 139 }
140 140
141 // Sets whether this is a dual mode shortcut (Win8+). 141 // Sets whether this is a dual mode shortcut (Win8+).
142 // NOTE: Only the default (no arguments and default browser appid) browser 142 // NOTE: Only the default (no arguments and default browser appid) browser
143 // shortcut in the Start menu (Start screen on Win8+) should be made dual 143 // shortcut in the Start menu (Start screen on Win8+) should be made dual
144 // mode. 144 // mode.
145 void set_dual_mode(bool dual_mode_in) { 145 void set_dual_mode(bool dual_mode_in) {
146 dual_mode = dual_mode_in; 146 dual_mode = dual_mode_in;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 bool has_dual_mode() const { 181 bool has_dual_mode() const {
182 return (options & PROPERTIES_DUAL_MODE) != 0; 182 return (options & PROPERTIES_DUAL_MODE) != 0;
183 } 183 }
184 184
185 // The level to install this shortcut at (CURRENT_USER for a per-user 185 // The level to install this shortcut at (CURRENT_USER for a per-user
186 // shortcut and SYSTEM_LEVEL for an all-users shortcut). 186 // shortcut and SYSTEM_LEVEL for an all-users shortcut).
187 ShellChange level; 187 ShellChange level;
188 188
189 base::FilePath target; 189 base::FilePath target;
190 string16 arguments; 190 base::string16 arguments;
191 string16 description; 191 base::string16 description;
192 base::FilePath icon; 192 base::FilePath icon;
193 int icon_index; 193 int icon_index;
194 string16 app_id; 194 base::string16 app_id;
195 string16 shortcut_name; 195 base::string16 shortcut_name;
196 bool dual_mode; 196 bool dual_mode;
197 bool pin_to_taskbar; 197 bool pin_to_taskbar;
198 // Bitfield made of IndividualProperties. Properties set in |options| will 198 // Bitfield made of IndividualProperties. Properties set in |options| will
199 // be used to create/update the shortcut, others will be ignored on update 199 // be used to create/update the shortcut, others will be ignored on update
200 // and possibly replaced by default values on create (see individual 200 // and possibly replaced by default values on create (see individual
201 // property setters above for details on default values). 201 // property setters above for details on default values).
202 uint32 options; 202 uint32 options;
203 }; 203 };
204 204
205 // Relative path of the URL Protocol registry entry (prefixed with '\'). 205 // Relative path of the URL Protocol registry entry (prefixed with '\').
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // Registry value name for the DelegateExecute verb handler. 290 // Registry value name for the DelegateExecute verb handler.
291 static const wchar_t* kRegDelegateExecute; 291 static const wchar_t* kRegDelegateExecute;
292 292
293 // Registry value name for the OpenWithProgids entry for file associations. 293 // Registry value name for the OpenWithProgids entry for file associations.
294 static const wchar_t* kRegOpenWithProgids; 294 static const wchar_t* kRegOpenWithProgids;
295 295
296 // Returns true if |chrome_exe| is registered in HKLM with |suffix|. 296 // Returns true if |chrome_exe| is registered in HKLM with |suffix|.
297 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and 297 // Note: This only checks one deterministic key in HKLM for |chrome_exe| and
298 // doesn't otherwise validate a full Chrome install in HKLM. 298 // doesn't otherwise validate a full Chrome install in HKLM.
299 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, 299 static bool QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist,
300 const string16& chrome_exe, 300 const base::string16& chrome_exe,
301 const string16& suffix); 301 const base::string16& suffix);
302 302
303 // Returns true if the current Windows version supports the presence of 303 // Returns true if the current Windows version supports the presence of
304 // shortcuts at |location|. 304 // shortcuts at |location|.
305 static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location); 305 static bool ShortcutLocationIsSupported(ShellUtil::ShortcutLocation location);
306 306
307 // Sets |path| to the path for a shortcut at the |location| desired for the 307 // Sets |path| to the path for a shortcut at the |location| desired for the
308 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for 308 // given |level| (CURRENT_USER for per-user path and SYSTEM_LEVEL for
309 // all-users path). 309 // all-users path).
310 // Returns false on failure. 310 // Returns false on failure.
311 static bool GetShortcutPath(ShellUtil::ShortcutLocation location, 311 static bool GetShortcutPath(ShellUtil::ShortcutLocation location,
(...skipping 11 matching lines...) Expand all
323 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or 323 // SHORTCUT_LOCATION_START_MENU_CHROME_DIR, or
324 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR. 324 // SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR.
325 static bool CreateOrUpdateShortcut( 325 static bool CreateOrUpdateShortcut(
326 ShellUtil::ShortcutLocation location, 326 ShellUtil::ShortcutLocation location,
327 BrowserDistribution* dist, 327 BrowserDistribution* dist,
328 const ShellUtil::ShortcutProperties& properties, 328 const ShellUtil::ShortcutProperties& properties,
329 ShellUtil::ShortcutOperation operation); 329 ShellUtil::ShortcutOperation operation);
330 330
331 // Returns the string "|icon_path|,|icon_index|" (see, for example, 331 // Returns the string "|icon_path|,|icon_index|" (see, for example,
332 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx). 332 // http://msdn.microsoft.com/library/windows/desktop/dd391573.aspx).
333 static string16 FormatIconLocation(const string16& icon_path, int icon_index); 333 static base::string16 FormatIconLocation(const base::string16& icon_path,
334 int icon_index);
334 335
335 // This method returns the command to open URLs/files using chrome. Typically 336 // This method returns the command to open URLs/files using chrome. Typically
336 // this command is written to the registry under shell\open\command key. 337 // this command is written to the registry under shell\open\command key.
337 // |chrome_exe|: the full path to chrome.exe 338 // |chrome_exe|: the full path to chrome.exe
338 static string16 GetChromeShellOpenCmd(const string16& chrome_exe); 339 static base::string16 GetChromeShellOpenCmd(const base::string16& chrome_exe);
339 340
340 // This method returns the command to be called by the DelegateExecute verb 341 // This method returns the command to be called by the DelegateExecute verb
341 // handler to launch chrome on Windows 8. Typically this command is written to 342 // handler to launch chrome on Windows 8. Typically this command is written to
342 // the registry under the HKCR\Chrome\.exe\shell\(open|run)\command key. 343 // the registry under the HKCR\Chrome\.exe\shell\(open|run)\command key.
343 // |chrome_exe|: the full path to chrome.exe 344 // |chrome_exe|: the full path to chrome.exe
344 static string16 GetChromeDelegateCommand(const string16& chrome_exe); 345 static base::string16 GetChromeDelegateCommand(
346 const base::string16& chrome_exe);
345 347
346 // Gets a mapping of all registered browser names (excluding browsers in the 348 // Gets a mapping of all registered browser names (excluding browsers in the
347 // |dist| distribution) and their reinstall command (which usually sets 349 // |dist| distribution) and their reinstall command (which usually sets
348 // browser as default). 350 // browser as default).
349 // Given browsers can be registered in HKCU (as of Win7) and/or in HKLM, this 351 // Given browsers can be registered in HKCU (as of Win7) and/or in HKLM, this
350 // method looks in both and gives precedence to values in HKCU as per the msdn 352 // method looks in both and gives precedence to values in HKCU as per the msdn
351 // standard: http://goo.gl/xjczJ. 353 // standard: http://goo.gl/xjczJ.
352 static void GetRegisteredBrowsers(BrowserDistribution* dist, 354 static void GetRegisteredBrowsers(
353 std::map<string16, string16>* browsers); 355 BrowserDistribution* dist,
356 std::map<base::string16, base::string16>* browsers);
354 357
355 // Returns the suffix this user's Chrome install is registered with. 358 // Returns the suffix this user's Chrome install is registered with.
356 // Always returns the empty string on system-level installs. 359 // Always returns the empty string on system-level installs.
357 // 360 //
358 // This method is meant for external methods which need to know the suffix of 361 // This method is meant for external methods which need to know the suffix of
359 // the current install at run-time, not for install-time decisions. 362 // the current install at run-time, not for install-time decisions.
360 // There are no guarantees that this suffix will not change later: 363 // There are no guarantees that this suffix will not change later:
361 // (e.g. if two user-level installs were previously installed in parallel on 364 // (e.g. if two user-level installs were previously installed in parallel on
362 // the same machine, both without admin rights and with no user-level install 365 // the same machine, both without admin rights and with no user-level install
363 // having claimed the non-suffixed HKLM registrations, they both have no 366 // having claimed the non-suffixed HKLM registrations, they both have no
364 // suffix in their progId entries (as per the old suffix rules). If they were 367 // suffix in their progId entries (as per the old suffix rules). If they were
365 // to both fully register (i.e. click "Make Chrome Default" and go through 368 // to both fully register (i.e. click "Make Chrome Default" and go through
366 // UAC; or upgrade to Win8 and get the automatic no UAC full registration) 369 // UAC; or upgrade to Win8 and get the automatic no UAC full registration)
367 // they would then both get a suffixed registration as per the new suffix 370 // they would then both get a suffixed registration as per the new suffix
368 // rules). 371 // rules).
369 // 372 //
370 // |chrome_exe| The path to the currently installed (or running) chrome.exe. 373 // |chrome_exe| The path to the currently installed (or running) chrome.exe.
371 static string16 GetCurrentInstallationSuffix(BrowserDistribution* dist, 374 static base::string16 GetCurrentInstallationSuffix(
372 const string16& chrome_exe); 375 BrowserDistribution* dist,
376 const base::string16& chrome_exe);
373 377
374 // Returns the application name of the program under |dist|. 378 // Returns the application name of the program under |dist|.
375 // This application name will be suffixed as is appropriate for the current 379 // This application name will be suffixed as is appropriate for the current
376 // install. 380 // install.
377 // This is the name that is registered with Default Programs on Windows and 381 // This is the name that is registered with Default Programs on Windows and
378 // that should thus be used to "make chrome default" and such. 382 // that should thus be used to "make chrome default" and such.
379 static string16 GetApplicationName(BrowserDistribution* dist, 383 static base::string16 GetApplicationName(BrowserDistribution* dist,
380 const string16& chrome_exe); 384 const base::string16& chrome_exe);
381 385
382 // Returns the AppUserModelId for |dist|. This identifier is unconditionally 386 // Returns the AppUserModelId for |dist|. This identifier is unconditionally
383 // suffixed with a unique id for this user on user-level installs (in contrast 387 // suffixed with a unique id for this user on user-level installs (in contrast
384 // to other registration entries which are suffixed as described in 388 // to other registration entries which are suffixed as described in
385 // GetCurrentInstallationSuffix() above). 389 // GetCurrentInstallationSuffix() above).
386 static string16 GetBrowserModelId(BrowserDistribution* dist, 390 static base::string16 GetBrowserModelId(BrowserDistribution* dist,
387 bool is_per_user_install); 391 bool is_per_user_install);
388 392
389 // Returns an AppUserModelId composed of each member of |components| separated 393 // Returns an AppUserModelId composed of each member of |components| separated
390 // by dots. 394 // by dots.
391 // The returned appid is guaranteed to be no longer than 395 // The returned appid is guaranteed to be no longer than
392 // chrome::kMaxAppModelIdLength (some of the components might have been 396 // chrome::kMaxAppModelIdLength (some of the components might have been
393 // shortened to enforce this). 397 // shortened to enforce this).
394 static string16 BuildAppModelId(const std::vector<string16>& components); 398 static base::string16 BuildAppModelId(
399 const std::vector<base::string16>& components);
395 400
396 // Returns true if Chrome can make itself the default browser without relying 401 // Returns true if Chrome can make itself the default browser without relying
397 // on the Windows shell to prompt the user. This is the case for versions of 402 // on the Windows shell to prompt the user. This is the case for versions of
398 // Windows prior to Windows 8. 403 // Windows prior to Windows 8.
399 static bool CanMakeChromeDefaultUnattended(); 404 static bool CanMakeChromeDefaultUnattended();
400 405
401 // Returns the DefaultState of Chrome for HTTP and HTTPS. 406 // Returns the DefaultState of Chrome for HTTP and HTTPS.
402 static DefaultState GetChromeDefaultState(); 407 static DefaultState GetChromeDefaultState();
403 408
404 // Returns the DefaultState of Chrome for |protocol|. 409 // Returns the DefaultState of Chrome for |protocol|.
405 static DefaultState GetChromeDefaultProtocolClientState( 410 static DefaultState GetChromeDefaultProtocolClientState(
406 const string16& protocol); 411 const base::string16& protocol);
407 412
408 // Make Chrome the default browser. This function works by going through 413 // Make Chrome the default browser. This function works by going through
409 // the url protocols and file associations that are related to general 414 // the url protocols and file associations that are related to general
410 // browsing, e.g. http, https, .html etc., and requesting to become the 415 // browsing, e.g. http, https, .html etc., and requesting to become the
411 // default handler for each. If any of these fails the operation will return 416 // default handler for each. If any of these fails the operation will return
412 // false to indicate failure, which is consistent with the return value of 417 // false to indicate failure, which is consistent with the return value of
413 // ShellIntegration::GetDefaultBrowser. 418 // ShellIntegration::GetDefaultBrowser.
414 // 419 //
415 // In the case of failure any successful changes will be left, however no 420 // In the case of failure any successful changes will be left, however no
416 // more changes will be attempted. 421 // more changes will be attempted.
417 // TODO(benwells): Attempt to undo any changes that were successfully made. 422 // TODO(benwells): Attempt to undo any changes that were successfully made.
418 // http://crbug.com/83970 423 // http://crbug.com/83970
419 // 424 //
420 // shell_change: Defined whether to register as default browser at system 425 // shell_change: Defined whether to register as default browser at system
421 // level or user level. If value has ShellChange::SYSTEM_LEVEL 426 // level or user level. If value has ShellChange::SYSTEM_LEVEL
422 // we should be running as admin user. 427 // we should be running as admin user.
423 // chrome_exe: The chrome.exe path to register as default browser. 428 // chrome_exe: The chrome.exe path to register as default browser.
424 // elevate_if_not_admin: On Vista if user is not admin, try to elevate for 429 // elevate_if_not_admin: On Vista if user is not admin, try to elevate for
425 // Chrome registration. 430 // Chrome registration.
426 static bool MakeChromeDefault(BrowserDistribution* dist, 431 static bool MakeChromeDefault(BrowserDistribution* dist,
427 int shell_change, 432 int shell_change,
428 const string16& chrome_exe, 433 const base::string16& chrome_exe,
429 bool elevate_if_not_admin); 434 bool elevate_if_not_admin);
430 435
431 // Shows and waits for the Windows 8 "How do you want to open webpages?" 436 // Shows and waits for the Windows 8 "How do you want to open webpages?"
432 // dialog if Chrome is not already the default HTTP/HTTPS handler. Also does 437 // dialog if Chrome is not already the default HTTP/HTTPS handler. Also does
433 // XP-era registrations if Chrome is chosen or was already the default. Do 438 // XP-era registrations if Chrome is chosen or was already the default. Do
434 // not use on pre-Win8 OSes. 439 // not use on pre-Win8 OSes.
435 // 440 //
436 // |dist| gives the type of browser distribution currently in use. 441 // |dist| gives the type of browser distribution currently in use.
437 // |chrome_exe| The chrome.exe path to register as default browser. 442 // |chrome_exe| The chrome.exe path to register as default browser.
438 static bool ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist, 443 static bool ShowMakeChromeDefaultSystemUI(BrowserDistribution* dist,
439 const string16& chrome_exe); 444 const base::string16& chrome_exe);
440 445
441 // Make Chrome the default application for a protocol. 446 // Make Chrome the default application for a protocol.
442 // chrome_exe: The chrome.exe path to register as default browser. 447 // chrome_exe: The chrome.exe path to register as default browser.
443 // protocol: The protocol to register as the default handler for. 448 // protocol: The protocol to register as the default handler for.
444 static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist, 449 static bool MakeChromeDefaultProtocolClient(BrowserDistribution* dist,
445 const string16& chrome_exe, 450 const base::string16& chrome_exe,
446 const string16& protocol); 451 const base::string16& protocol);
447 452
448 // Shows and waits for the Windows 8 "How do you want to open links of this 453 // Shows and waits for the Windows 8 "How do you want to open links of this
449 // type?" dialog if Chrome is not already the default |protocol| 454 // type?" dialog if Chrome is not already the default |protocol|
450 // handler. Also does XP-era registrations if Chrome is chosen or was already 455 // handler. Also does XP-era registrations if Chrome is chosen or was already
451 // the default for |protocol|. Do not use on pre-Win8 OSes. 456 // the default for |protocol|. Do not use on pre-Win8 OSes.
452 // 457 //
453 // |dist| gives the type of browser distribution currently in use. 458 // |dist| gives the type of browser distribution currently in use.
454 // |chrome_exe| The chrome.exe path to register as default browser. 459 // |chrome_exe| The chrome.exe path to register as default browser.
455 // |protocol| is the protocol being registered. 460 // |protocol| is the protocol being registered.
456 static bool ShowMakeChromeDefaultProtocolClientSystemUI( 461 static bool ShowMakeChromeDefaultProtocolClientSystemUI(
457 BrowserDistribution* dist, 462 BrowserDistribution* dist,
458 const string16& chrome_exe, 463 const base::string16& chrome_exe,
459 const string16& protocol); 464 const base::string16& protocol);
460 465
461 // Registers Chrome as a potential default browser and handler for filetypes 466 // Registers Chrome as a potential default browser and handler for filetypes
462 // and protocols. 467 // and protocols.
463 // If Chrome is already registered, this method is a no-op. 468 // If Chrome is already registered, this method is a no-op.
464 // This method requires write access to HKLM (prior to Win8) so is just a 469 // This method requires write access to HKLM (prior to Win8) so is just a
465 // best effort deal. 470 // best effort deal.
466 // If write to HKLM is required, but fails, and: 471 // If write to HKLM is required, but fails, and:
467 // - |elevate_if_not_admin| is true (and OS is Vista or above): 472 // - |elevate_if_not_admin| is true (and OS is Vista or above):
468 // tries to launch setup.exe with admin priviledges (by prompting the user 473 // tries to launch setup.exe with admin priviledges (by prompting the user
469 // with a UAC) to do these tasks. 474 // with a UAC) to do these tasks.
470 // - |elevate_if_not_admin| is false (or OS is XP): 475 // - |elevate_if_not_admin| is false (or OS is XP):
471 // adds the ProgId entries to HKCU. These entries will not make Chrome show 476 // adds the ProgId entries to HKCU. These entries will not make Chrome show
472 // in Default Programs but they are still useful because Chrome can be 477 // in Default Programs but they are still useful because Chrome can be
473 // registered to run when the user clicks on an http link or an html file. 478 // registered to run when the user clicks on an http link or an html file.
474 // 479 //
475 // |chrome_exe| full path to chrome.exe. 480 // |chrome_exe| full path to chrome.exe.
476 // |unique_suffix| Optional input. If given, this function appends the value 481 // |unique_suffix| Optional input. If given, this function appends the value
477 // to default browser entries names that it creates in the registry. 482 // to default browser entries names that it creates in the registry.
478 // Currently, this is only used to continue an install with the same suffix 483 // Currently, this is only used to continue an install with the same suffix
479 // when elevating and calling setup.exe with admin privileges as described 484 // when elevating and calling setup.exe with admin privileges as described
480 // above. 485 // above.
481 // |elevate_if_not_admin| if true will make this method try alternate methods 486 // |elevate_if_not_admin| if true will make this method try alternate methods
482 // as described above. This should only be true when following a user action 487 // as described above. This should only be true when following a user action
483 // (e.g. "Make Chrome Default") as it allows this method to UAC. 488 // (e.g. "Make Chrome Default") as it allows this method to UAC.
484 // 489 //
485 // Returns true if Chrome is successfully registered (or already registered). 490 // Returns true if Chrome is successfully registered (or already registered).
486 static bool RegisterChromeBrowser(BrowserDistribution* dist, 491 static bool RegisterChromeBrowser(BrowserDistribution* dist,
487 const string16& chrome_exe, 492 const base::string16& chrome_exe,
488 const string16& unique_suffix, 493 const base::string16& unique_suffix,
489 bool elevate_if_not_admin); 494 bool elevate_if_not_admin);
490 495
491 // This method declares to Windows that Chrome is capable of handling the 496 // This method declares to Windows that Chrome is capable of handling the
492 // given protocol. This function will call the RegisterChromeBrowser function 497 // given protocol. This function will call the RegisterChromeBrowser function
493 // to register with Windows as capable of handling the protocol, if it isn't 498 // to register with Windows as capable of handling the protocol, if it isn't
494 // currently registered as capable. 499 // currently registered as capable.
495 // Declaring the capability of handling a protocol is necessary to register 500 // Declaring the capability of handling a protocol is necessary to register
496 // as the default handler for the protocol in Vista and later versions of 501 // as the default handler for the protocol in Vista and later versions of
497 // Windows. 502 // Windows.
498 // 503 //
499 // If called by the browser and elevation is required, it will elevate by 504 // If called by the browser and elevation is required, it will elevate by
500 // calling setup.exe which will again call this function with elevate false. 505 // calling setup.exe which will again call this function with elevate false.
501 // 506 //
502 // |chrome_exe| full path to chrome.exe. 507 // |chrome_exe| full path to chrome.exe.
503 // |unique_suffix| Optional input. If given, this function appends the value 508 // |unique_suffix| Optional input. If given, this function appends the value
504 // to default browser entries names that it creates in the registry. 509 // to default browser entries names that it creates in the registry.
505 // |protocol| The protocol to register as being capable of handling.s 510 // |protocol| The protocol to register as being capable of handling.s
506 // |elevate_if_not_admin| if true will make this method try alternate methods 511 // |elevate_if_not_admin| if true will make this method try alternate methods
507 // as described above. 512 // as described above.
508 static bool RegisterChromeForProtocol(BrowserDistribution* dist, 513 static bool RegisterChromeForProtocol(BrowserDistribution* dist,
509 const string16& chrome_exe, 514 const base::string16& chrome_exe,
510 const string16& unique_suffix, 515 const base::string16& unique_suffix,
511 const string16& protocol, 516 const base::string16& protocol,
512 bool elevate_if_not_admin); 517 bool elevate_if_not_admin);
513 518
514 // Removes installed shortcut(s) at |location|. 519 // Removes installed shortcut(s) at |location|.
515 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to 520 // |level|: CURRENT_USER to remove per-user shortcuts, or SYSTEM_LEVEL to
516 // remove all-users shortcuts. 521 // remove all-users shortcuts.
517 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when 522 // |target_exe|: Shortcut target exe; shortcuts will only be deleted when
518 // their target is |target_exe|. 523 // their target is |target_exe|.
519 // If |location| is a Chrome-specific folder, it will be deleted as well. 524 // If |location| is a Chrome-specific folder, it will be deleted as well.
520 // Returns true if all shortcuts pointing to |target_exe| are successfully 525 // Returns true if all shortcuts pointing to |target_exe| are successfully
521 // deleted, including the case where no such shortcuts are found. 526 // deleted, including the case where no such shortcuts are found.
(...skipping 21 matching lines...) Expand all
543 // (including the '.'). 548 // (including the '.').
544 // This suffix is then meant to be added to all registration that may conflict 549 // This suffix is then meant to be added to all registration that may conflict
545 // with another user-level Chrome install. 550 // with another user-level Chrome install.
546 // Note that prior to Chrome 21, the suffix registered used to be the user's 551 // Note that prior to Chrome 21, the suffix registered used to be the user's
547 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old 552 // username (see GetOldUserSpecificRegistrySuffix() below). We still honor old
548 // installs registered that way, but it was wrong because some of the 553 // installs registered that way, but it was wrong because some of the
549 // characters allowed in a username are not allowed in a ProgId. 554 // characters allowed in a username are not allowed in a ProgId.
550 // Returns true unless the OS call to retrieve the username fails. 555 // Returns true unless the OS call to retrieve the username fails.
551 // NOTE: Only the installer should use this suffix directly. Other callers 556 // NOTE: Only the installer should use this suffix directly. Other callers
552 // should call GetCurrentInstallationSuffix(). 557 // should call GetCurrentInstallationSuffix().
553 static bool GetUserSpecificRegistrySuffix(string16* suffix); 558 static bool GetUserSpecificRegistrySuffix(base::string16* suffix);
554 559
555 // Sets |suffix| to this user's username preceded by a dot. This suffix should 560 // Sets |suffix| to this user's username preceded by a dot. This suffix should
556 // only be used to support legacy installs that used this suffixing 561 // only be used to support legacy installs that used this suffixing
557 // style. 562 // style.
558 // Returns true unless the OS call to retrieve the username fails. 563 // Returns true unless the OS call to retrieve the username fails.
559 // NOTE: Only the installer should use this suffix directly. Other callers 564 // NOTE: Only the installer should use this suffix directly. Other callers
560 // should call GetCurrentInstallationSuffix(). 565 // should call GetCurrentInstallationSuffix().
561 static bool GetOldUserSpecificRegistrySuffix(string16* suffix); 566 static bool GetOldUserSpecificRegistrySuffix(base::string16* suffix);
562 567
563 // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|. 568 // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|.
564 // |size| is the length of |bytes|. 569 // |size| is the length of |bytes|.
565 // Note: This method does not suffix the output with '=' signs as technically 570 // Note: This method does not suffix the output with '=' signs as technically
566 // required by the base32 standard for inputs that aren't a multiple of 5 571 // required by the base32 standard for inputs that aren't a multiple of 5
567 // bytes. 572 // bytes.
568 static string16 ByteArrayToBase32(const uint8* bytes, size_t size); 573 static base::string16 ByteArrayToBase32(const uint8* bytes, size_t size);
569 574
570 private: 575 private:
571 DISALLOW_COPY_AND_ASSIGN(ShellUtil); 576 DISALLOW_COPY_AND_ASSIGN(ShellUtil);
572 }; 577 };
573 578
574 579
575 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ 580 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/installer/util/product_operations.h ('k') | chrome/installer/util/shell_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698