Use different icon for some file types
fix https://github.com/brave/brave-browser/issues/12761 When brave browser is set as a default application, different icon will be used for that file type. Currently, .pdf and .svg files will have different icon. So far, we set BraveBHTML (beta) prog id for supported file types in registry. and that BraveBHTML entry has some attributes such as default icon or commands. That default icon is used for the file type when browser is set as its default application. default icon of BraveBHTML reg entry is brave browser's default icon. Because of this, all file types uses same icon. This PR introduces new BraveFile prog entry and it uses different icon. And, new BraveFile id is set for some file types when brave is its default application.
This commit is contained in:
@@ -60,6 +60,10 @@ IDR_X002_APP_LIST_SXS ICON "theme\\brave\\win\\app_list_sxs.ico"
|
||||
IDR_X003_INCOGNITO ICON "theme\\brave\\win\\incognito.ico"
|
||||
IDR_X004_DEV ICON "theme\\brave\\win\\brave_dev.ico"
|
||||
IDR_X005_BETA ICON "theme\\brave\\win\\brave_beta.ico"
|
||||
IDR_X006_FILE ICON "theme\\brave\\win\\brave_file.ico"
|
||||
IDR_X006_FILE_BETA ICON "theme\\brave\\win\\brave_file_beta.ico"
|
||||
IDR_X006_FILE_DEVA ICON "theme\\brave\\win\\brave_file_dev.ico"
|
||||
IDR_X006_FILE_SXS ICON "theme\\brave\\win\\brave_file_nightly.ico"
|
||||
#else
|
||||
IDR_X001_APP_LIST ICON "theme\\brave\\win\\app_list.ico"
|
||||
IDR_X003_INCOGNITO ICON "theme\\brave\\win\\incognito.ico"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -1,9 +1,10 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef CHROME_COMMON_CHROME_ICON_RESOURCES_WIN_H_
|
||||
#define CHROME_COMMON_CHROME_ICON_RESOURCES_WIN_H_
|
||||
#ifndef BRAVE_CHROMIUM_SRC_CHROME_COMMON_CHROME_ICON_RESOURCES_WIN_H_
|
||||
#define BRAVE_CHROMIUM_SRC_CHROME_COMMON_CHROME_ICON_RESOURCES_WIN_H_
|
||||
|
||||
namespace icon_resources {
|
||||
|
||||
@@ -36,6 +37,12 @@ enum {
|
||||
|
||||
// The Brave Beta application icon.
|
||||
kBetaApplicationIndex = 9,
|
||||
|
||||
// The various file type icon(ex, pdf).
|
||||
kFileTypeIndex = 10,
|
||||
kBetaFileTypeIndex = 11,
|
||||
kDevFileTypeIndex = 12,
|
||||
kSxSFileTypeIndex = 13,
|
||||
#else
|
||||
// The Brave Developer App Launcher icon.
|
||||
kAppLauncherIndex = 1,
|
||||
@@ -47,4 +54,4 @@ enum {
|
||||
|
||||
} // namespace icon_resources
|
||||
|
||||
#endif // CHROME_COMMON_CHROME_ICON_RESOURCES_WIN_H_
|
||||
#endif // BRAVE_CHROMIUM_SRC_CHROME_COMMON_CHROME_ICON_RESOURCES_WIN_H_
|
||||
|
||||
@@ -2,6 +2,8 @@ include_rules = [
|
||||
"+../../../../../chrome/installer/mini_installer",
|
||||
"+../../../../../chrome/installer/setup",
|
||||
"+../../../../../chrome/installer/util",
|
||||
"+chrome/common",
|
||||
"+chrome/installer",
|
||||
"+chrome/install_static",
|
||||
"+components/version_info",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
brave_chromium_src_chrome_installer_setup_sources = []
|
||||
brave_chromium_src_chrome_installer_setup_deps = []
|
||||
|
||||
if (is_win) {
|
||||
brave_chromium_src_chrome_installer_setup_deps += [ "//brave/installer/util" ]
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/installer/util/brave_shell_util.h"
|
||||
|
||||
#define UninstallProduct UninstallProduct_ChromiumImpl
|
||||
|
||||
#include "../../../../../chrome/installer/setup/uninstall.cc"
|
||||
|
||||
#undef UninstallProduct
|
||||
|
||||
namespace installer {
|
||||
|
||||
namespace {
|
||||
|
||||
void DeleteBraveFileKeys(HKEY root) {
|
||||
// Delete Software\Classes\BraveXXXFile.
|
||||
std::wstring reg_prog_id(ShellUtil::kRegClasses);
|
||||
reg_prog_id.push_back(base::FilePath::kSeparators[0]);
|
||||
reg_prog_id.append(GetProgIdForFileType());
|
||||
InstallUtil::DeleteRegistryKey(root, reg_prog_id, WorkItem::kWow64Default);
|
||||
|
||||
// Cleanup OpenWithList and OpenWithProgids:
|
||||
// http://msdn.microsoft.com/en-us/library/bb166549
|
||||
std::wstring file_assoc_key;
|
||||
std::wstring open_with_progids_key;
|
||||
for (int i = 0; ShellUtil::kPotentialFileAssociations[i] != nullptr; ++i) {
|
||||
file_assoc_key.assign(ShellUtil::kRegClasses);
|
||||
file_assoc_key.push_back(base::FilePath::kSeparators[0]);
|
||||
file_assoc_key.append(ShellUtil::kPotentialFileAssociations[i]);
|
||||
file_assoc_key.push_back(base::FilePath::kSeparators[0]);
|
||||
|
||||
open_with_progids_key.assign(file_assoc_key);
|
||||
open_with_progids_key.append(ShellUtil::kRegOpenWithProgids);
|
||||
if (ShouldUseFileTypeProgId(ShellUtil::kPotentialFileAssociations[i])) {
|
||||
InstallUtil::DeleteRegistryValue(root, open_with_progids_key,
|
||||
WorkItem::kWow64Default,
|
||||
GetProgIdForFileType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
InstallStatus UninstallProduct(const ModifyParams& modify_params,
|
||||
bool remove_all,
|
||||
bool force_uninstall,
|
||||
const base::CommandLine& cmd_line) {
|
||||
DeleteBraveFileKeys(HKEY_CURRENT_USER);
|
||||
|
||||
const InstallerState& installer_state = modify_params.installer_state;
|
||||
const base::FilePath chrome_exe(
|
||||
installer_state.target_path().Append(installer::kChromeExe));
|
||||
const std::wstring suffix(
|
||||
ShellUtil::GetCurrentInstallationSuffix(chrome_exe));
|
||||
if (installer_state.system_install() ||
|
||||
(remove_all &&
|
||||
ShellUtil::QuickIsChromeRegisteredInHKLM(chrome_exe, suffix))) {
|
||||
DeleteBraveFileKeys(HKEY_LOCAL_MACHINE);
|
||||
}
|
||||
|
||||
return UninstallProduct_ChromiumImpl(modify_params, remove_all,
|
||||
force_uninstall, cmd_line);
|
||||
}
|
||||
|
||||
} // namespace installer
|
||||
@@ -3,6 +3,36 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "brave/installer/util/brave_shell_util.h"
|
||||
#include "chrome/common/chrome_icon_resources_win.h"
|
||||
#include "chrome/install_static/install_util.h"
|
||||
#include "components/version_info/channel.h"
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OFFICIAL_BUILD)
|
||||
|
||||
int GetIconIndexForFileType() {
|
||||
switch (install_static::GetChromeChannel()) {
|
||||
case version_info::Channel::STABLE:
|
||||
return icon_resources::kFileTypeIndex;
|
||||
case version_info::Channel::BETA:
|
||||
return icon_resources::kBetaFileTypeIndex;
|
||||
case version_info::Channel::DEV:
|
||||
return icon_resources::kDevFileTypeIndex;
|
||||
case version_info::Channel::CANARY:
|
||||
return icon_resources::kSxSFileTypeIndex;
|
||||
default:
|
||||
NOTREACHED();
|
||||
return icon_resources::kFileTypeIndex;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // OFFICIAL_BUILD
|
||||
|
||||
} // namespace
|
||||
|
||||
#define BRAVE_IPFS L"ipfs"
|
||||
#define BRAVE_IPNS L"ipns"
|
||||
|
||||
@@ -12,7 +42,43 @@
|
||||
if (base::EqualsCaseInsensitiveASCII(protocol, BRAVE_IPNS)) \
|
||||
return base::StringPrintf(kSystemSettingsDefaultAppsFormat, L"IPNS");
|
||||
|
||||
#if defined(OFFICIAL_BUILD)
|
||||
// Add BraveFile prog id in registry with proper icon.
|
||||
// This prog id will be referenced from serveral file association reg entry.
|
||||
#define BRAVE_GET_CHROME_PROG_ID_ENTRIES \
|
||||
app_info.prog_id = installer::GetProgIdForFileType(); \
|
||||
app_info.file_type_icon_index = GetIconIndexForFileType(); \
|
||||
GetProgIdEntries(app_info, entries);
|
||||
|
||||
// Give BraveXXFile prog id for some file type.(ex, .pdf or .svg) instead of
|
||||
// BraveHTML.
|
||||
#define BRAVE_GET_APP_EXT_REGISTRATION_ENTRIES \
|
||||
if (installer::ShouldUseFileTypeProgId(ext)) { \
|
||||
entries->push_back(std::make_unique<RegistryEntry>( \
|
||||
key_name, installer::GetProgIdForFileType(), std::wstring())); \
|
||||
return; \
|
||||
}
|
||||
|
||||
// Give BraveXXFile prog id for some file type.(ex, .pdf or .svg) instead of
|
||||
// BraveHTML.
|
||||
#define BRAVE_GET_SHELL_INTEGRATION_ENTRIES \
|
||||
const std::wstring file_ext = ShellUtil::kPotentialFileAssociations[i]; \
|
||||
if (installer::ShouldUseFileTypeProgId(file_ext)) { \
|
||||
entries->push_back(std::make_unique<RegistryEntry>( \
|
||||
capabilities + L"\\FileAssociations", file_ext, \
|
||||
installer::GetProgIdForFileType())); \
|
||||
continue; \
|
||||
}
|
||||
#else
|
||||
#define BRAVE_GET_CHROME_PROG_ID_ENTRIES
|
||||
#define BRAVE_GET_APP_EXT_REGISTRATION_ENTRIES
|
||||
#define BRAVE_GET_SHELL_INTEGRATION_ENTRIES
|
||||
#endif
|
||||
|
||||
#include "../../../../../chrome/installer/util/shell_util.cc"
|
||||
#undef BRAVE_GET_SHELL_INTEGRATION_ENTRIES
|
||||
#undef BRAVE_GET_APP_EXT_REGISTRATION_ENTRIES
|
||||
#undef BRAVE_GET_CHROME_PROG_ID_ENTRIES
|
||||
#undef BRAVE_GET_TARGET_FOR_DEFAULT_APP_SETTINGS
|
||||
#undef BRAVE_IPFS
|
||||
#undef BRAVE_IPNS
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
brave_chromium_src_chrome_installer_util_sources = []
|
||||
brave_chromium_src_chrome_installer_util_deps = []
|
||||
|
||||
if (is_win) {
|
||||
brave_chromium_src_chrome_installer_util_deps += [
|
||||
"//brave/installer/util",
|
||||
"//chrome/common:non_code_constants",
|
||||
"//chrome/install_static:install_static_util",
|
||||
"//components/version_info",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
source_set("util") {
|
||||
sources = [
|
||||
"brave_shell_util.cc",
|
||||
"brave_shell_util.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//chrome/install_static:install_static_util",
|
||||
"//components/version_info",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
include_rules = [
|
||||
"+chrome/install_static",
|
||||
"+components/version_info",
|
||||
]
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/installer/util/brave_shell_util.h"
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "chrome/install_static/install_util.h"
|
||||
#include "components/version_info/channel.h"
|
||||
|
||||
namespace installer {
|
||||
|
||||
std::wstring GetProgIdForFileType() {
|
||||
switch (install_static::GetChromeChannel()) {
|
||||
case version_info::Channel::STABLE:
|
||||
return L"BraveFile";
|
||||
case version_info::Channel::BETA:
|
||||
return L"BraveBFile";
|
||||
case version_info::Channel::DEV:
|
||||
return L"BraveDFile";
|
||||
case version_info::Channel::CANARY:
|
||||
return L"BraveSSFile";
|
||||
default:
|
||||
NOTREACHED();
|
||||
return L"BraveFile";
|
||||
}
|
||||
}
|
||||
|
||||
bool ShouldUseFileTypeProgId(const std::wstring& ext) {
|
||||
return (ext == L".pdf" || ext == L".svg");
|
||||
}
|
||||
|
||||
} // namespace installer
|
||||
@@ -0,0 +1,18 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_INSTALLER_UTIL_BRAVE_SHELL_UTIL_H_
|
||||
#define BRAVE_INSTALLER_UTIL_BRAVE_SHELL_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace installer {
|
||||
|
||||
std::wstring GetProgIdForFileType();
|
||||
bool ShouldUseFileTypeProgId(const std::wstring& ext);
|
||||
|
||||
} // namespace installer
|
||||
|
||||
#endif // BRAVE_INSTALLER_UTIL_BRAVE_SHELL_UTIL_H_
|
||||
@@ -0,0 +1,12 @@
|
||||
diff --git a/chrome/installer/setup/BUILD.gn b/chrome/installer/setup/BUILD.gn
|
||||
index db3796b6b6ef7c7c60cd6d75e93259c1a5edc364..e6fa111a618efea3ff70b55b75ed9c9297c4d040 100644
|
||||
--- a/chrome/installer/setup/BUILD.gn
|
||||
+++ b/chrome/installer/setup/BUILD.gn
|
||||
@@ -49,6 +49,7 @@ if (is_win) {
|
||||
]
|
||||
|
||||
libs = [ "netapi32.lib" ]
|
||||
+ import("//brave/chromium_src/chrome/installer/setup/sources.gni") deps += brave_chromium_src_chrome_installer_setup_deps sources+= brave_chromium_src_chrome_installer_setup_sources
|
||||
}
|
||||
|
||||
static_library("lib") {
|
||||
@@ -1,8 +1,16 @@
|
||||
diff --git a/chrome/installer/util/BUILD.gn b/chrome/installer/util/BUILD.gn
|
||||
index 2ea95551d977717045804377090c4e57bb4e0518..c3af7ec8bad26ee56ee5b2a786c1c8ece82f6e7b 100644
|
||||
index 2ea95551d977717045804377090c4e57bb4e0518..6859e33daa7de44c2b53601163bc6949bdebbd0c 100644
|
||||
--- a/chrome/installer/util/BUILD.gn
|
||||
+++ b/chrome/installer/util/BUILD.gn
|
||||
@@ -225,7 +225,18 @@ generate_embedded_i18n("generate_strings") {
|
||||
@@ -190,6 +190,7 @@ static_library("with_no_strings") {
|
||||
"initial_preferences.h",
|
||||
]
|
||||
}
|
||||
+ import("//brave/chromium_src/chrome/installer/util/sources.gni") deps += brave_chromium_src_chrome_installer_util_deps sources += brave_chromium_src_chrome_installer_util_sources
|
||||
}
|
||||
|
||||
# Use this version of installer_util to link to the generated strings in .rc
|
||||
@@ -225,7 +226,18 @@ generate_embedded_i18n("generate_strings") {
|
||||
|
||||
output_file_name_base = "installer_util_strings"
|
||||
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
|
||||
index 3e81aacae5b091da6718b4394289605b86400c02..863f01c37945abb0219ea46bfb07370d6fb2bfe2 100644
|
||||
index 3e81aacae5b091da6718b4394289605b86400c02..af09cf6ba8489196d049fb2044a5bc3d4a58a9c6 100644
|
||||
--- a/chrome/installer/util/shell_util.cc
|
||||
+++ b/chrome/installer/util/shell_util.cc
|
||||
@@ -754,6 +754,7 @@ std::wstring GetTargetForDefaultAppsSettings(const wchar_t* protocol) {
|
||||
@@ -392,6 +392,7 @@ void GetChromeProgIdEntries(
|
||||
app_info.delegate_clsid = install_static::GetLegacyCommandExecuteImplClsid();
|
||||
|
||||
GetProgIdEntries(app_info, entries);
|
||||
+ BRAVE_GET_CHROME_PROG_ID_ENTRIES
|
||||
|
||||
if (!app_info.delegate_clsid.empty()) {
|
||||
auto delegate_execute_entries =
|
||||
@@ -488,6 +489,7 @@ void GetShellIntegrationEntries(
|
||||
|
||||
const std::wstring html_prog_id(GetBrowserProgId(suffix));
|
||||
for (int i = 0; ShellUtil::kPotentialFileAssociations[i] != nullptr; i++) {
|
||||
+ BRAVE_GET_SHELL_INTEGRATION_ENTRIES
|
||||
entries->push_back(std::make_unique<RegistryEntry>(
|
||||
capabilities + L"\\FileAssociations",
|
||||
ShellUtil::kPotentialFileAssociations[i], html_prog_id));
|
||||
@@ -514,6 +516,7 @@ void GetAppExtRegistrationEntries(
|
||||
key_name.append(ext);
|
||||
key_name.push_back(base::FilePath::kSeparators[0]);
|
||||
key_name.append(ShellUtil::kRegOpenWithProgids);
|
||||
+ BRAVE_GET_APP_EXT_REGISTRATION_ENTRIES
|
||||
entries->push_back(
|
||||
std::make_unique<RegistryEntry>(key_name, prog_id, std::wstring()));
|
||||
}
|
||||
@@ -754,6 +757,7 @@ std::wstring GetTargetForDefaultAppsSettings(const wchar_t* protocol) {
|
||||
return base::StringPrintf(kSystemSettingsDefaultAppsFormat, L"Browser");
|
||||
if (base::EqualsCaseInsensitiveASCII(protocol, L"mailto"))
|
||||
return base::StringPrintf(kSystemSettingsDefaultAppsFormat, L"Email");
|
||||
@@ -10,7 +34,7 @@ index 3e81aacae5b091da6718b4394289605b86400c02..863f01c37945abb0219ea46bfb07370d
|
||||
return L"SettingsPageAppsDefaultsProtocolView";
|
||||
}
|
||||
|
||||
@@ -1661,8 +1662,10 @@ const wchar_t* ShellUtil::kPotentialFileAssociations[] = {
|
||||
@@ -1661,8 +1665,10 @@ const wchar_t* ShellUtil::kPotentialFileAssociations[] = {
|
||||
L".htm", L".html", L".pdf", L".shtml", L".svg",
|
||||
L".xht", L".xhtml", L".webp", nullptr};
|
||||
const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"ftp", L"http",
|
||||
|
||||
Reference in New Issue
Block a user