Index: chrome/browser/file_associations_win.cc |
diff --git a/chrome/browser/file_associations_win.cc b/chrome/browser/file_associations_win.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..38e9f7ec67c896efcd0d31140869c79eea099dd7 |
--- /dev/null |
+++ b/chrome/browser/file_associations_win.cc |
@@ -0,0 +1,45 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/file_associations_win.h" |
+ |
+#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.
|
+ |
+#include "base/strings/utf_string_conversions.h" |
+#include "chrome/installer/util/shell_util.h" |
+ |
+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
|
+ 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.
|
+ const std::string& file_type_name, |
+ 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.
|
+ const std::set<std::string>& file_extensions) { |
+ 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.
|
+ for (std::set<std::string>::const_iterator it = file_extensions.begin(); |
+ it != file_extensions.end(); |
+ ++it) { |
+ file_extensions_16.insert(base::UTF8ToUTF16(*it)); |
+ } |
+ if (!ShellUtil::AddFileAssociations(base::UTF8ToUTF16(progid), |
+ command_line, |
+ base::UTF8ToUTF16(file_type_name), |
+ icon_path, |
+ file_extensions_16)) { |
+ return false; |
+ } |
+ |
+ // Success. Tell Windows Explorer to update its cache. |
+ SHChangeNotify( |
+ SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, NULL, NULL); |
+ return true; |
+} |
+ |
+bool DeleteWindowsFileAssociations(const std::string& progid) { |
+ if (!ShellUtil::DeleteFileAssociations(base::UTF8ToUTF16(progid))) |
+ return false; |
+ |
+ // Success. Tell Windows Explorer to update its cache. |
+ SHChangeNotify( |
+ SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, NULL, NULL); |
+ return true; |
+} |