Add common_resources.grd for non-localizeable chromoting resources.
The new common_resources.grd will be used for non-loalizeable resources, such as images. Review URL: https://chromiumcodereview.appspot.com/11087059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162226 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -11,16 +11,24 @@
|
||||
|
||||
namespace remoting {
|
||||
|
||||
namespace {
|
||||
const char kLocaleResourcesDirName[] = "remoting_locales";
|
||||
const char kCommonResourcesFileName[] = "chrome_remote_desktop.pak";
|
||||
} // namespace
|
||||
|
||||
// Loads chromoting resources.
|
||||
bool LoadResources(const std::string& locale) {
|
||||
FilePath path;
|
||||
if (!PathService::Get(base::DIR_MODULE, &path))
|
||||
return false;
|
||||
path = path.Append(FILE_PATH_LITERAL("remoting_locales"));
|
||||
PathService::Override(ui::DIR_LOCALES, path);
|
||||
|
||||
PathService::Override(ui::DIR_LOCALES,
|
||||
path.AppendASCII(kLocaleResourcesDirName));
|
||||
ui::ResourceBundle::InitSharedInstanceLocaleOnly(locale, NULL);
|
||||
|
||||
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
|
||||
path.AppendASCII(kCommonResourcesFileName), ui::SCALE_FACTOR_100P);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "remoting/base/resources.h"
|
||||
|
||||
#include "remoting/base/common_resources.h"
|
||||
#include "remoting/base/string_resources.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
@ -15,19 +16,37 @@ namespace remoting {
|
||||
// the test.
|
||||
#if !defined(OS_MACOSX)
|
||||
#define MAYBE_ProductName ProductName
|
||||
#define MAYBE_ProductLogo ProductLogo
|
||||
#else // !defined(OS_MACOSX)
|
||||
#define MAYBE_ProductName DISABLED_ProductName
|
||||
#define MAYBE_ProductLogo DISABLED_ProductLogo
|
||||
#endif // defined(OS_MACOSX)
|
||||
TEST(Resources, MAYBE_ProductName) {
|
||||
|
||||
class ResourcesTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() OVERRIDE {
|
||||
ASSERT_TRUE(LoadResources("en-US"));
|
||||
}
|
||||
|
||||
void TearDown() OVERRIDE {
|
||||
ui::ResourceBundle::CleanupSharedInstance();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ResourcesTest, MAYBE_ProductName) {
|
||||
#if defined(GOOGLE_CHROME_BUILD)
|
||||
std::string expected_product_name = "Chrome Remote Desktop";
|
||||
#else // defined(GOOGLE_CHROME_BUILD)
|
||||
std::string expected_product_name = "Chromoting";
|
||||
#endif // !defined(GOOGLE_CHROME_BUILD)
|
||||
ASSERT_TRUE(LoadResources("en-US"));
|
||||
EXPECT_EQ(expected_product_name,
|
||||
l10n_util::GetStringUTF8(IDR_REMOTING_PRODUCT_NAME));
|
||||
ui::ResourceBundle::CleanupSharedInstance();
|
||||
}
|
||||
|
||||
TEST_F(ResourcesTest, MAYBE_ProductLogo) {
|
||||
gfx::Image logo = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
|
||||
IDR_PRODUCT_LOGO_16);
|
||||
EXPECT_FALSE(logo.IsEmpty());
|
||||
}
|
||||
|
||||
} // namespace remoting
|
||||
|
31
remoting/grit_action.gypi
Normal file
31
remoting/grit_action.gypi
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2012 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.
|
||||
|
||||
# This file is mostly a copy of base/grit_action.gypi . There are two
|
||||
# differences:
|
||||
# 1. Remoting resources are build with a different resource_ids file.
|
||||
# 2. File specified by variable base_grit_grd_file is used to generate list of
|
||||
# inputs and outputs.
|
||||
|
||||
{
|
||||
'variables': {
|
||||
'grit_cmd': ['python', '<(DEPTH)/tools/grit/grit.py'],
|
||||
},
|
||||
'inputs': [
|
||||
'<(grit_grd_file)',
|
||||
'<!@pymod_do_main(grit_info <@(grit_defines) '
|
||||
'--inputs <(base_grit_grd_file) -fresource_ids)',
|
||||
],
|
||||
'outputs': [
|
||||
'<!@pymod_do_main(grit_info <@(grit_defines) '
|
||||
'--outputs \'<(grit_out_dir)\' <(base_grit_grd_file) -fresource_ids)',
|
||||
],
|
||||
'action': ['<@(grit_cmd)',
|
||||
'-i', '<(grit_grd_file)', 'build',
|
||||
'-fresource_ids',
|
||||
'-o', '<(grit_out_dir)',
|
||||
'<@(grit_defines)' ],
|
||||
'msvs_cygwin_shell': 0,
|
||||
'message': 'Generating resources from <(grit_grd_file)',
|
||||
}
|
@ -1284,34 +1284,36 @@
|
||||
],
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'generate_resources',
|
||||
'action_name': 'string_resources',
|
||||
'variables': {
|
||||
'grit_cmd': ['python', '<(DEPTH)/tools/grit/grit.py'],
|
||||
'grit_grd_file': '<(strings_grd_file)',
|
||||
'base_grit_grd_file': '<(base_strings_grd_file)',
|
||||
},
|
||||
'inputs': [
|
||||
'<(strings_grd_file)',
|
||||
'<(resource_ids_file)',
|
||||
],
|
||||
'outputs': [
|
||||
'<!@pymod_do_main(grit_info <@(grit_defines) '
|
||||
'--outputs \'<(grit_out_dir)\' <(base_strings_grd_file))',
|
||||
],
|
||||
'action': ['<@(grit_cmd)',
|
||||
'-i', '<(strings_grd_file)', 'build',
|
||||
'-fresource_ids',
|
||||
'-o', '<(grit_out_dir)',
|
||||
'<@(grit_defines)' ],
|
||||
'msvs_cygwin_shell': 0,
|
||||
'message': 'Generating resources from <(strings_grd_file)',
|
||||
'includes': [ 'grit_action.gypi' ],
|
||||
},
|
||||
{
|
||||
'action_name': 'common_resources',
|
||||
'variables': {
|
||||
'grit_grd_file': 'resources/common_resources.grd',
|
||||
'base_grit_grd_file': 'resources/common_resources.grd',
|
||||
},
|
||||
'includes': [ 'grit_action.gypi' ],
|
||||
},
|
||||
],
|
||||
'copies': [
|
||||
{ # Copy results to the product directory.
|
||||
# Copy results to the product directory.
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/remoting_locales',
|
||||
'files': [
|
||||
'<(grit_out_dir)/remoting/resources/en-US.pak',
|
||||
]
|
||||
},
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)',
|
||||
'files': [
|
||||
'<(grit_out_dir)/remoting/resources/chrome_remote_desktop.pak',
|
||||
]
|
||||
},
|
||||
],
|
||||
'includes': [ '../build/grit_target.gypi' ],
|
||||
}, # end of target 'remoting_resources'
|
||||
|
18
remoting/resources/common_resources.grd
Normal file
18
remoting/resources/common_resources.grd
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<grit base_dir="." latest_public_release="0" current_release="1"
|
||||
source_lang_id="en" enc_check="möl">
|
||||
<outputs>
|
||||
<output filename="remoting/base/common_resources.h" type="rc_header" context="default_100_percent">
|
||||
<emit emit_type='prepend'></emit>
|
||||
</output>
|
||||
<output filename="remoting/resources/chrome_remote_desktop.pak" type="data_package"
|
||||
lang="en" context="default_100_percent" />
|
||||
</outputs>
|
||||
<release seq="1" allow_pseudo="false">
|
||||
<structures fallback_to_low_resolution="true">
|
||||
<structure type="chrome_scaled_image" name="IDR_PRODUCT_LOGO_16" file="chromoting16.png" />
|
||||
<structure type="chrome_scaled_image" name="IDR_PRODUCT_LOGO_32" file="chromoting32.png" />
|
||||
</structures>
|
||||
</release>
|
||||
</grit>
|
@ -19,4 +19,7 @@
|
||||
"remoting/resources/string_resources.grd": {
|
||||
"messages": [1000],
|
||||
},
|
||||
"remoting/resources/common_resources.grd": {
|
||||
"structures": [10000],
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user