| 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..f36256606dd8fe0b5eff1514ce7983a14273c6d3
|
| --- /dev/null
|
| +++ b/chrome/browser/file_associations_win.cc
|
| @@ -0,0 +1,47 @@
|
| +// 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 <windows.h>
|
| +#include <shlobj.h>
|
| +
|
| +#include "base/strings/string16.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/installer/util/shell_util.h"
|
| +
|
| +bool AddWindowsFileAssociations(const std::string& progid,
|
| + const base::CommandLine& command_line,
|
| + const std::string& file_type_name,
|
| + const base::FilePath& icon_path,
|
| + const std::set<std::string>& file_extensions) {
|
| + std::set<base::string16> file_extensions_16;
|
| + 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;
|
| +}
|
|
|