diff options
author | alexeypa@google.com <alexeypa@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-26 23:04:24 +0000 |
---|---|---|
committer | alexeypa@google.com <alexeypa@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-26 23:04:24 +0000 |
commit | 93cfcc6f75ffd86895a6f95013b7df8becccfb91 (patch) | |
tree | dec5252259e825efd3db95cd7096880b0df54f01 /remoting/base | |
parent | 40f42682afc1bd543f9fde452f7f1f20fcf55492 (diff) | |
download | chromium_src-93cfcc6f75ffd86895a6f95013b7df8becccfb91.zip chromium_src-93cfcc6f75ffd86895a6f95013b7df8becccfb91.tar.gz chromium_src-93cfcc6f75ffd86895a6f95013b7df8becccfb91.tar.bz2 |
Revert 213997 "Localized Chromoting Host on Mac and Linux."
It passed CQ but broke Linux Builder. I'm filing a bug agains CQ.
> Localized Chromoting Host on Mac and Linux.
>
> This CL implements generation of localizable strings from remoting_strings.grd file. Depending on the platform the localized resources are placed to:
> - Mac: localized .string and .pak resources are added to each application bundle under 'Resources/<locale>.lproj'
> - Linux: localized .pak files are placed under 'remoting_locales' directory next to the binary locading them.
> - Windows: .rc resources are generated from .jinja2 templates and embedded into a relevant binary.
>
> Chrome l10n and i18n APIs are used to retrieve the current locale and RTL flag (Mac & Linux). The it2me plugin sets the locale to match the locale of the browser.
>
> Collateral changes:
> - UiString is not used any more.
> - Increased width of disconnect window message on Mac.
> - The host plugin version is correctly reported on Mac.
> - Dialogs use RTL templates in case of RTL languages. No more updating the templates dynamically (Windows).
> - remoting_unittests.ResourcesTest row runs on Mac, LInux and Windows.
> - '@' is used for variable substitutions by remoting_localize.py.
> - HOST_PLUGIN_MIME_TYPE is defined in one place now.
> - Deleted unused commong_resources.grd.
>
> Mac installer and preference panel are not localized yet.
>
> BUG=155204
>
> Review URL: https://chromiumcodereview.appspot.com/19803010
TBR=alexeypa@chromium.org
Review URL: https://codereview.chromium.org/20854002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r-- | remoting/base/resources.cc | 35 | ||||
-rw-r--r-- | remoting/base/resources.h | 8 | ||||
-rw-r--r-- | remoting/base/resources_linux.cc | 44 | ||||
-rw-r--r-- | remoting/base/resources_mac.mm | 43 | ||||
-rw-r--r-- | remoting/base/resources_unittest.cc | 44 | ||||
-rw-r--r-- | remoting/base/resources_win.cc | 17 |
6 files changed, 62 insertions, 129 deletions
diff --git a/remoting/base/resources.cc b/remoting/base/resources.cc new file mode 100644 index 0000000..933be87 --- /dev/null +++ b/remoting/base/resources.cc @@ -0,0 +1,35 @@ +// 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. + +#include "remoting/base/resources.h" + +#include "base/files/file_path.h" +#include "base/path_service.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_paths.h" + +namespace remoting { + +namespace { +const char kLocaleResourcesDirName[] = "remoting_locales"; +const char kCommonResourcesFileName[] = "chrome_remote_desktop.pak"; +} // namespace + +// Loads chromoting resources. +bool LoadResources(const std::string& pref_locale) { + base::FilePath path; + if (!PathService::Get(base::DIR_MODULE, &path)) + return false; + + PathService::Override(ui::DIR_LOCALES, + path.AppendASCII(kLocaleResourcesDirName)); + ui::ResourceBundle::InitSharedInstanceLocaleOnly(pref_locale, NULL); + + ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( + path.AppendASCII(kCommonResourcesFileName), ui::SCALE_FACTOR_100P); + + return true; +} + +} // namespace remoting diff --git a/remoting/base/resources.h b/remoting/base/resources.h index 371c533..b08eb8d 100644 --- a/remoting/base/resources.h +++ b/remoting/base/resources.h @@ -9,15 +9,11 @@ namespace remoting { -// Loads (or reloads) Chromoting resources for the given locale. |pref_locale| +// Loads chromoting resources. Returns false in case of a failure. |pref_locale| // is passed to l10n_util::GetApplicationLocale(), so the default system locale -// is used if |pref_locale| is empty. Returns |true| if the shared resource -// bundle has been initialized. +// is used if |pref_locale| is empty. bool LoadResources(const std::string& pref_locale); -// Unloads Chromoting resources. -void UnloadResources(); - } // namespace remoting #endif // REMOTING_HOST_BASE_RESOURCES_H_ diff --git a/remoting/base/resources_linux.cc b/remoting/base/resources_linux.cc deleted file mode 100644 index af530e8..0000000 --- a/remoting/base/resources_linux.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2013 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 "remoting/base/resources.h" - -#include <dlfcn.h> - -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/path_service.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/base/ui_base_paths.h" - -namespace remoting { - -namespace { -const char kLocaleResourcesDirName[] = "remoting_locales"; -} // namespace - -bool LoadResources(const std::string& pref_locale) { - if (ui::ResourceBundle::HasSharedInstance()) { - ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(pref_locale); - } else { - // Retrive the path to the module containing this function. - Dl_info info; - CHECK(dladdr(reinterpret_cast<void*>(&LoadResources), &info) != 0); - - // Point DIR_LOCALES to 'remoting_locales'. - base::FilePath path = base::FilePath(info.dli_fname).DirName(); - PathService::Override(ui::DIR_LOCALES, - path.AppendASCII(kLocaleResourcesDirName)); - - ui::ResourceBundle::InitSharedInstanceLocaleOnly(pref_locale, NULL); - } - - return true; -} - -void UnloadResources() { - ui::ResourceBundle::CleanupSharedInstance(); -} - -} // namespace remoting diff --git a/remoting/base/resources_mac.mm b/remoting/base/resources_mac.mm deleted file mode 100644 index d1ce4af..0000000 --- a/remoting/base/resources_mac.mm +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2013 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. - -#import <Cocoa/Cocoa.h> - -#include "remoting/base/resources.h" -#include "base/mac/bundle_locations.h" -#include "ui/base/l10n/l10n_util_mac.h" -#include "ui/base/resource/resource_bundle.h" - -// A dummy class used to locate the host plugin's bundle. -@interface NSBundleLocator : NSObject -@end - -@implementation NSBundleLocator -@end - -namespace remoting { - -bool LoadResources(const std::string& pref_locale) { - if (ui::ResourceBundle::HasSharedInstance()) { - ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(pref_locale); - } else { - // Use the plugin's bundle instead of the hosting app bundle. - base::mac::SetOverrideFrameworkBundle( - [NSBundle bundleForClass:[NSBundleLocator class]]); - - // Override the locale with the value from Cocoa. - if (pref_locale.empty()) - l10n_util::OverrideLocaleWithCocoaLocale(); - - ui::ResourceBundle::InitSharedInstanceLocaleOnly(pref_locale, NULL); - } - - return true; -} - -void UnloadResources() { - ui::ResourceBundle::CleanupSharedInstance(); -} - -} // namespace remoting diff --git a/remoting/base/resources_unittest.cc b/remoting/base/resources_unittest.cc index b02a12b..6d69cee 100644 --- a/remoting/base/resources_unittest.cc +++ b/remoting/base/resources_unittest.cc @@ -4,46 +4,52 @@ #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" #include "testing/gtest/include/gtest/gtest.h" namespace remoting { +// TODO(sergeyu): Resources loading doesn't work yet on OSX. Fix it and enable +// 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) + class ResourcesTest : public testing::Test { protected: - ResourcesTest(): resources_available_(false) { - } - virtual void SetUp() OVERRIDE { - resources_available_ = LoadResources("en-US"); + ASSERT_TRUE(LoadResources("en-US")); } virtual void TearDown() OVERRIDE { - UnloadResources(); + ui::ResourceBundle::CleanupSharedInstance(); } - - bool resources_available_; }; -TEST_F(ResourcesTest, ProductName) { +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) + EXPECT_EQ(expected_product_name, + l10n_util::GetStringUTF8(IDR_PRODUCT_NAME)); +} - // Chrome-style i18n is not used on Windows. -#if defined(OS_WIN) - EXPECT_FALSE(resources_available_); -#else - EXPECT_TRUE(resources_available_); -#endif - - if (resources_available_) { - EXPECT_EQ(expected_product_name, - l10n_util::GetStringUTF8(IDR_PRODUCT_NAME)); - } +TEST_F(ResourcesTest, MAYBE_ProductLogo) { + gfx::Image logo16 = ui::ResourceBundle::GetSharedInstance().GetImageNamed( + IDR_PRODUCT_LOGO_16); + EXPECT_FALSE(logo16.IsEmpty()); + gfx::Image logo32 = ui::ResourceBundle::GetSharedInstance().GetImageNamed( + IDR_PRODUCT_LOGO_32); + EXPECT_FALSE(logo32.IsEmpty()); } } // namespace remoting diff --git a/remoting/base/resources_win.cc b/remoting/base/resources_win.cc deleted file mode 100644 index e4d9efa..0000000 --- a/remoting/base/resources_win.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 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 "remoting/base/resources.h" - -namespace remoting { - -bool LoadResources(const std::string& pref_locale) { - // Do nothing since .pak files are not used on Windows. - return false; -} - -void UnloadResources() { -} - -} // namespace remoting |