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

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

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

Powered by Google App Engine
This is Rietveld 408576698