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

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: Rebase. 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>
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,
13 const base::CommandLine& command_line,
14 const std::string& file_type_name,
15 const base::FilePath& icon_path,
16 const std::set<std::string>& file_extensions) {
17 std::set<base::string16> file_extensions_16;
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);
gab 2014/09/12 13:32:36 IIRC this will also produce a fly-in on Win8 telli
gab 2014/09/18 01:16:14 ping.
Matt Giuca 2014/09/30 10:21:12 I tried this on Windows 8 and I didn't see any fly
gab 2014/10/01 14:31:11 The default is for the notification to be buffered
Matt Giuca 2014/10/02 09:36:33 Thanks for the summary. Makes sense.
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