Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / base / resource / resource_bundle_win.cc
blob045f8ae899f7825f40256cd44d83bf93173e4585
1 // Copyright (c) 2012 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.
5 #include "ui/base/resource/resource_bundle_win.h"
7 #include "base/logging.h"
8 #include "base/path_service.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "skia/ext/image_operations.h"
11 #include "ui/base/layout.h"
12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/base/resource/resource_data_dll_win.h"
14 #include "ui/gfx/geometry/size_conversions.h"
15 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/image/image_skia_source.h"
17 #include "ui/gfx/win/dpi.h"
19 namespace ui {
21 namespace {
23 HINSTANCE resources_data_dll;
25 HINSTANCE GetCurrentResourceDLL() {
26 if (resources_data_dll)
27 return resources_data_dll;
28 return GetModuleHandle(NULL);
31 base::FilePath GetResourcesPakFilePath(const std::string& pak_name) {
32 base::FilePath path;
33 if (PathService::Get(base::DIR_MODULE, &path))
34 return path.AppendASCII(pak_name.c_str());
36 // Return just the name of the pack file.
37 return base::FilePath(base::ASCIIToUTF16(pak_name));
40 } // namespace
42 void ResourceBundle::LoadCommonResources() {
43 // As a convenience, add the current resource module as a data packs.
44 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL()));
46 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) {
47 AddDataPackFromPath(
48 GetResourcesPakFilePath("chrome_100_percent.pak"),
49 SCALE_FACTOR_100P);
51 if (IsScaleFactorSupported(SCALE_FACTOR_200P)) {
52 AddDataPackFromPath(
53 GetResourcesPakFilePath("chrome_200_percent.pak"),
54 SCALE_FACTOR_200P);
58 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
59 // Flipped image is not used on Windows.
60 DCHECK_EQ(rtl, RTL_DISABLED);
62 // Windows only uses SkBitmap for gfx::Image, so this is the same as
63 // GetImageNamed.
64 return GetImageNamed(resource_id);
67 void SetResourcesDataDLL(HINSTANCE handle) {
68 resources_data_dll = handle;
71 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) {
72 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id));
75 } // namespace ui;