mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-04 21:17:37 +01:00
chrome: win: Add CefSettings.chrome_app_icon_id (see #3606)
This commit is contained in:
parent
2b1922746f
commit
738192addf
@ -42,13 +42,13 @@
|
||||
// way that may cause binary incompatibility with other builds. The universal
|
||||
// hash value will change if any platform is affected whereas the platform hash
|
||||
// values will change only if that particular platform is affected.
|
||||
#define CEF_API_HASH_UNIVERSAL "ce9401699c6753553cba867b1f5c329f759d2c67"
|
||||
#define CEF_API_HASH_UNIVERSAL "dd6f61e464170f580618fc291753ebd3a6d1ca3b"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "e094f42b7a60d2c8c9bcb3db51907a3b42f51d04"
|
||||
#define CEF_API_HASH_PLATFORM "5465fd7a2a8e85a96cd5a88898140a65abb61754"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "6ce44bd7182aa7e9544f5ca33c310f2a096ab638"
|
||||
#define CEF_API_HASH_PLATFORM "e6510fc20f99a016da2d5419083208e2e81dbbf7"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "8e9886cd490aefc89283d65f5f7d104a51e2d289"
|
||||
#define CEF_API_HASH_PLATFORM "d2332f866e89d827151e6eb70c38f44d91cee5a2"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -484,6 +484,15 @@ typedef struct _cef_settings_t {
|
||||
/// for details.
|
||||
///
|
||||
cef_string_t chrome_policy_id;
|
||||
|
||||
///
|
||||
/// Specify an ID for an ICON resource that can be loaded from the main
|
||||
/// executable and used when creating default Chrome windows such as DevTools
|
||||
/// and Task Manager. If unspecified the default Chromium ICON (IDR_MAINFRAME
|
||||
/// [101]) will be loaded from libcef.dll. Only supported with the Chrome
|
||||
/// runtime on Windows.
|
||||
///
|
||||
int chrome_app_icon_id;
|
||||
} cef_settings_t;
|
||||
|
||||
///
|
||||
|
@ -434,6 +434,7 @@ struct CefSettingsTraits {
|
||||
|
||||
cef_string_set(src->chrome_policy_id.str, src->chrome_policy_id.length,
|
||||
&target->chrome_policy_id, copy);
|
||||
target->chrome_app_icon_id = src->chrome_app_icon_id;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -13,6 +13,10 @@
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "chrome/browser/win/app_icon.h"
|
||||
#endif
|
||||
|
||||
ChromeBrowserMainExtraPartsCef::ChromeBrowserMainExtraPartsCef() = default;
|
||||
|
||||
ChromeBrowserMainExtraPartsCef::~ChromeBrowserMainExtraPartsCef() = default;
|
||||
@ -49,4 +53,11 @@ void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
|
||||
context_menu::RegisterMenuCreatedCallback();
|
||||
file_dialog_runner::RegisterFactory();
|
||||
permission_prompt::RegisterCreateCallback();
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
const auto& settings = CefContext::Get()->settings();
|
||||
if (settings.chrome_app_icon_id > 0) {
|
||||
SetExeAppIconResourceId(settings.chrome_app_icon_id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1,35 +1,66 @@
|
||||
diff --git chrome/browser/win/app_icon.cc chrome/browser/win/app_icon.cc
|
||||
index db721b75aad6f..a4826e16dd43d 100644
|
||||
index db721b75aad6f..fac8b38c7dde7 100644
|
||||
--- chrome/browser/win/app_icon.cc
|
||||
+++ chrome/browser/win/app_icon.cc
|
||||
@@ -25,6 +25,10 @@ HICON GetAppIcon() {
|
||||
@@ -18,13 +18,26 @@ int GetAppIconResourceId() {
|
||||
return install_static::InstallDetails::Get().app_icon_resource_id();
|
||||
}
|
||||
|
||||
+int g_exe_app_icon_resource_id = 0;
|
||||
+
|
||||
} // namespace
|
||||
|
||||
+void SetExeAppIconResourceId(int icon_id) {
|
||||
+ g_exe_app_icon_resource_id = icon_id;
|
||||
+}
|
||||
+
|
||||
HICON GetAppIcon() {
|
||||
// TODO(mgiuca): Use GetAppIconImageFamily/CreateExact instead of LoadIcon, to
|
||||
// get correct scaling. (See http://crbug.com/551256)
|
||||
const int icon_id = GetAppIconResourceId();
|
||||
- const int icon_id = GetAppIconResourceId();
|
||||
// HICON returned from LoadIcon do not leak and do not have to be destroyed.
|
||||
+ // Try to load the icon from the exe first.
|
||||
+ if (auto icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(icon_id))) {
|
||||
+ return icon;
|
||||
+ if (g_exe_app_icon_resource_id > 0) {
|
||||
+ // Try to load the icon from the exe first.
|
||||
+ if (auto icon = LoadIcon(GetModuleHandle(NULL),
|
||||
+ MAKEINTRESOURCE(g_exe_app_icon_resource_id))) {
|
||||
+ return icon;
|
||||
+ }
|
||||
+ }
|
||||
+ const int icon_id = GetAppIconResourceId();
|
||||
return LoadIcon(GetModuleHandle(chrome::kBrowserResourcesDll),
|
||||
MAKEINTRESOURCE(icon_id));
|
||||
}
|
||||
@@ -35,6 +39,13 @@ HICON GetSmallAppIcon() {
|
||||
const int icon_id = GetAppIconResourceId();
|
||||
@@ -32,9 +45,18 @@ HICON GetAppIcon() {
|
||||
HICON GetSmallAppIcon() {
|
||||
// TODO(mgiuca): Use GetAppIconImageFamily/CreateExact instead of LoadIcon, to
|
||||
// get correct scaling. (See http://crbug.com/551256)
|
||||
- const int icon_id = GetAppIconResourceId();
|
||||
gfx::Size size = GetSmallAppIconSize();
|
||||
// HICON returned from LoadImage must be released using DestroyIcon.
|
||||
+ // Try to load the icon from the exe first.
|
||||
+ if (auto icon = static_cast<HICON>(LoadImage(
|
||||
+ GetModuleHandle(NULL), MAKEINTRESOURCE(icon_id),
|
||||
+ IMAGE_ICON, size.width(), size.height(),
|
||||
+ LR_DEFAULTCOLOR | LR_SHARED))) {
|
||||
+ return icon;
|
||||
+ if (g_exe_app_icon_resource_id > 0) {
|
||||
+ // Try to load the icon from the exe first.
|
||||
+ if (auto icon = static_cast<HICON>(LoadImage(
|
||||
+ GetModuleHandle(NULL), MAKEINTRESOURCE(g_exe_app_icon_resource_id),
|
||||
+ IMAGE_ICON, size.width(), size.height(),
|
||||
+ LR_DEFAULTCOLOR | LR_SHARED))) {
|
||||
+ return icon;
|
||||
+ }
|
||||
+ }
|
||||
+ const int icon_id = GetAppIconResourceId();
|
||||
return static_cast<HICON>(LoadImage(
|
||||
GetModuleHandle(chrome::kBrowserResourcesDll), MAKEINTRESOURCE(icon_id),
|
||||
IMAGE_ICON, size.width(), size.height(), LR_DEFAULTCOLOR | LR_SHARED));
|
||||
@@ -51,14 +62,11 @@ gfx::Size GetSmallAppIconSize() {
|
||||
@@ -50,15 +72,14 @@ gfx::Size GetSmallAppIconSize() {
|
||||
}
|
||||
|
||||
std::unique_ptr<gfx::ImageFamily> GetAppIconImageFamily() {
|
||||
+ if (g_exe_app_icon_resource_id > 0) {
|
||||
+ // Try to load the icon from the exe first.
|
||||
+ if (auto image_family = IconUtil::CreateImageFamilyFromIconResource(
|
||||
+ GetModuleHandle(NULL), g_exe_app_icon_resource_id)) {
|
||||
+ return image_family;
|
||||
+ }
|
||||
+ }
|
||||
const int icon_id = GetAppIconResourceId();
|
||||
- // Get the icon from chrome.dll (not chrome.exe, which has different resource
|
||||
- // IDs). If chrome.dll is not loaded, we are probably in a unit test, so fall
|
||||
@ -41,14 +72,22 @@ index db721b75aad6f..a4826e16dd43d 100644
|
||||
- DCHECK(module);
|
||||
-
|
||||
- return IconUtil::CreateImageFamilyFromIconResource(module, icon_id);
|
||||
+ // Try to load the icon from the exe first.
|
||||
+ if (auto image_family = IconUtil::CreateImageFamilyFromIconResource(
|
||||
+ GetModuleHandle(NULL), icon_id)) {
|
||||
+ return image_family;
|
||||
+ }
|
||||
+ return IconUtil::CreateImageFamilyFromIconResource(
|
||||
+ GetModuleHandle(chrome::kBrowserResourcesDll), icon_id);
|
||||
}
|
||||
diff --git chrome/browser/win/app_icon.h chrome/browser/win/app_icon.h
|
||||
index db8209bbcc214..b50bce7fae5b5 100644
|
||||
--- chrome/browser/win/app_icon.h
|
||||
+++ chrome/browser/win/app_icon.h
|
||||
@@ -14,6 +14,8 @@ class ImageFamily;
|
||||
class Size;
|
||||
}
|
||||
|
||||
+void SetExeAppIconResourceId(int icon_id);
|
||||
+
|
||||
HICON GetAppIcon();
|
||||
HICON GetSmallAppIcon();
|
||||
|
||||
diff --git chrome/common/chrome_constants.cc chrome/common/chrome_constants.cc
|
||||
index 3a39e2bb7b608..27c6038cf7a47 100644
|
||||
--- chrome/common/chrome_constants.cc
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "include/cef_sandbox_win.h"
|
||||
#include "tests/cefclient/browser/main_context_impl.h"
|
||||
#include "tests/cefclient/browser/main_message_loop_multithreaded_win.h"
|
||||
#include "tests/cefclient/browser/resource.h"
|
||||
#include "tests/cefclient/browser/root_window_manager.h"
|
||||
#include "tests/cefclient/browser/test_runner.h"
|
||||
#include "tests/shared/browser/client_app_browser.h"
|
||||
@ -79,6 +80,11 @@ int RunMain(HINSTANCE hInstance, int nCmdShow) {
|
||||
// Populate the settings based on command line arguments.
|
||||
context->PopulateSettings(&settings);
|
||||
|
||||
// Set the ID for the ICON resource that will be loaded from the main
|
||||
// executable and used when creating default Chrome windows such as DevTools
|
||||
// and Task Manager. Only used with the Chrome runtime.
|
||||
settings.chrome_app_icon_id = IDR_MAINFRAME;
|
||||
|
||||
// Create the main message loop object.
|
||||
std::unique_ptr<MainMessageLoop> message_loop;
|
||||
if (settings.multi_threaded_message_loop) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user