| OLD | NEW |
| 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_ |
| 11 | 11 |
| 12 #include <windows.h> | 12 #include <windows.h> |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
| 22 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 23 #include "chrome/installer/util/work_item_list.h" | 23 #include "chrome/installer/util/work_item_list.h" |
| 24 | 24 |
| 25 class BrowserDistribution; | 25 class BrowserDistribution; |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class CancellationFlag; | 28 class CancellationFlag; |
| 29 class CommandLine; |
| 29 } | 30 } |
| 30 | 31 |
| 31 // This is a utility class that provides common shell integration methods | 32 // This is a utility class that provides common shell integration methods |
| 32 // that can be used by installer as well as Chrome. | 33 // that can be used by installer as well as Chrome. |
| 33 class ShellUtil { | 34 class ShellUtil { |
| 34 public: | 35 public: |
| 35 // Input to any methods that make changes to OS shell. | 36 // Input to any methods that make changes to OS shell. |
| 36 enum ShellChange { | 37 enum ShellChange { |
| 37 CURRENT_USER = 0x1, // Make any shell changes only at the user level | 38 CURRENT_USER = 0x1, // Make any shell changes only at the user level |
| 38 SYSTEM_LEVEL = 0x2 // Make any shell changes only at the system level | 39 SYSTEM_LEVEL = 0x2 // Make any shell changes only at the system level |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // should call GetCurrentInstallationSuffix(). | 594 // should call GetCurrentInstallationSuffix(). |
| 594 static bool GetOldUserSpecificRegistrySuffix(base::string16* suffix); | 595 static bool GetOldUserSpecificRegistrySuffix(base::string16* suffix); |
| 595 | 596 |
| 596 // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|. | 597 // Returns the base32 encoding (using the [A-Z2-7] alphabet) of |bytes|. |
| 597 // |size| is the length of |bytes|. | 598 // |size| is the length of |bytes|. |
| 598 // Note: This method does not suffix the output with '=' signs as technically | 599 // Note: This method does not suffix the output with '=' signs as technically |
| 599 // required by the base32 standard for inputs that aren't a multiple of 5 | 600 // required by the base32 standard for inputs that aren't a multiple of 5 |
| 600 // bytes. | 601 // bytes. |
| 601 static base::string16 ByteArrayToBase32(const uint8* bytes, size_t size); | 602 static base::string16 ByteArrayToBase32(const uint8* bytes, size_t size); |
| 602 | 603 |
| 604 // Associates a set of file extensions with a particular application in the |
| 605 // Windows registry, for the current user only. If an extension has no |
| 606 // existing default association, the given application becomes the default. |
| 607 // Otherwise, the application is added to the Open With menu for this type, |
| 608 // but does not become the default. |
| 609 // |
| 610 // |progid| is the unique internal name Windows will use for file associations |
| 611 // with this application. |
| 612 // |command_line| is the command to execute when opening a file via this |
| 613 // association. It should contain "%1" to pass the filename as an argument. |
| 614 // |file_type_name| and |icon_path| are the friendly name, and the path of the |
| 615 // icon, respectively, that will be used for files of these types when |
| 616 // associated with this application by default. (They are NOT the name/icon |
| 617 // that will represent the application under the Open With menu.) |
| 618 // Returns true on success; otherwise logs to stderr and returns false. |
| 619 static bool AddFileAssociations( |
| 620 const base::string16& progid, |
| 621 const base::CommandLine& command_line, |
| 622 const base::string16& file_type_name, |
| 623 const base::FilePath& icon_path, |
| 624 const std::set<base::string16>& file_extensions); |
| 625 |
| 626 // Deletes all associations with a particular application in the Windows |
| 627 // registry, for the current user only. |
| 628 // |progid| is the unique internal name Windows uses for file associations |
| 629 // with this application, as given to AddWindowsFileAssociations. All |
| 630 // information associated with this name will be deleted. |
| 631 static bool DeleteFileAssociations(const base::string16& progid); |
| 632 |
| 603 private: | 633 private: |
| 604 DISALLOW_COPY_AND_ASSIGN(ShellUtil); | 634 DISALLOW_COPY_AND_ASSIGN(ShellUtil); |
| 605 }; | 635 }; |
| 606 | 636 |
| 607 | 637 |
| 608 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ | 638 #endif // CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ |
| OLD | NEW |