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

Side by Side Diff: chrome/browser/file_associations_win.cc

Issue 487693002: ShellUtil: Add generic methods to add/delete Windows file associations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a TODO. Created 6 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/file_associations_win.h"
6
7 #include <shlobj.h>
grt (UTC plus 2) 2014/09/15 13:38:37 i believe <windows.h> should always be included be
Matt Giuca 2014/09/16 07:29:13 Done.
8
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/installer/util/shell_util.h"
11
12 bool AddWindowsFileAssociations(const std::string& progid,
grt (UTC plus 2) 2014/09/15 13:38:37 what will call this? why is |progid| a string rath
Matt Giuca 2014/09/16 07:29:12 I'm trying to abstract over the implementation det
grt (UTC plus 2) 2014/09/16 13:34:56 The reason I asked about the caller is that it wou
Matt Giuca 2014/09/18 00:07:04 Yeah, that would be unfortunate, but not a huge pr
13 const base::CommandLine& command_line,
grt (UTC plus 2) 2014/09/15 13:38:37 #include "base/command_line.h"
Matt Giuca 2014/09/16 07:29:13 I don't think this is needed because this file nev
grt (UTC plus 2) 2014/09/16 13:34:56 Acknowledged.
14 const std::string& file_type_name,
15 const base::FilePath& icon_path,
grt (UTC plus 2) 2014/09/15 13:38:37 #include "base/files/file_path.h"
Matt Giuca 2014/09/16 07:29:13 Same.
grt (UTC plus 2) 2014/09/16 13:34:55 Acknowledged.
16 const std::set<std::string>& file_extensions) {
17 std::set<base::string16> file_extensions_16;
grt (UTC plus 2) 2014/09/15 13:38:37 #include "base/strings/string16.h"
Matt Giuca 2014/09/16 07:29:12 Done.
18 for (std::set<std::string>::const_iterator it = file_extensions.begin();
19 it != file_extensions.end();
20 ++it) {
21 file_extensions_16.insert(base::UTF8ToUTF16(*it));
22 }
23 if (!ShellUtil::AddFileAssociations(base::UTF8ToUTF16(progid),
24 command_line,
25 base::UTF8ToUTF16(file_type_name),
26 icon_path,
27 file_extensions_16)) {
28 return false;
29 }
30
31 // Success. Tell Windows Explorer to update its cache.
32 SHChangeNotify(
33 SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, NULL, NULL);
34 return true;
35 }
36
37 bool DeleteWindowsFileAssociations(const std::string& progid) {
38 if (!ShellUtil::DeleteFileAssociations(base::UTF8ToUTF16(progid)))
39 return false;
40
41 // Success. Tell Windows Explorer to update its cache.
42 SHChangeNotify(
43 SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, NULL, NULL);
44 return true;
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698