summaryrefslogtreecommitdiffstats
path: root/remoting/base
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 00:57:25 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 00:57:25 +0000
commitccdd33a705a2b4988513b4585878fef67334c8b8 (patch)
tree42a5d7fdca49d0a3e597f34ee9a896c1abdb7695 /remoting/base
parent6581246501397683c273ee19ecf89b00f071dc9f (diff)
downloadchromium_src-ccdd33a705a2b4988513b4585878fef67334c8b8.zip
chromium_src-ccdd33a705a2b4988513b4585878fef67334c8b8.tar.gz
chromium_src-ccdd33a705a2b4988513b4585878fef67334c8b8.tar.bz2
Add grd file for chromoting resources.
Currently all chromoting resources are in json file readable by the webapp. They are not usable by the host. This change adds grd file that will be used by native host code. Review URL: https://codereview.chromium.org/11032038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r--remoting/base/DEPS1
-rw-r--r--remoting/base/resources.cc27
-rw-r--r--remoting/base/resources.h17
-rw-r--r--remoting/base/resources_unittest.cc33
4 files changed, 78 insertions, 0 deletions
diff --git a/remoting/base/DEPS b/remoting/base/DEPS
index 7ef3114..3ac365e 100644
--- a/remoting/base/DEPS
+++ b/remoting/base/DEPS
@@ -3,4 +3,5 @@ include_rules = [
"+google/protobuf",
"+net",
"+third_party/zlib",
+ "+ui/base",
]
diff --git a/remoting/base/resources.cc b/remoting/base/resources.cc
new file mode 100644
index 0000000..cd7e486
--- /dev/null
+++ b/remoting/base/resources.cc
@@ -0,0 +1,27 @@
+// 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/file_path.h"
+#include "base/path_service.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+
+namespace remoting {
+
+// 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);
+
+ ui::ResourceBundle::InitSharedInstanceLocaleOnly(locale, NULL);
+
+ return true;
+}
+
+} // namespace remoting
diff --git a/remoting/base/resources.h b/remoting/base/resources.h
new file mode 100644
index 0000000..a8fdfd6
--- /dev/null
+++ b/remoting/base/resources.h
@@ -0,0 +1,17 @@
+// 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.
+
+#ifndef REMOTING_HOST_BASE_RESOURCES_H_
+#define REMOTING_HOST_BASE_RESOURCES_H_
+
+#include <string>
+
+namespace remoting {
+
+// Loads chromoting resources. Returns false in case of a failure.
+bool LoadResources(const std::string& locale);
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_BASE_RESOURCES_H_
diff --git a/remoting/base/resources_unittest.cc b/remoting/base/resources_unittest.cc
new file mode 100644
index 0000000..45f94ee
--- /dev/null
+++ b/remoting/base/resources_unittest.cc
@@ -0,0 +1,33 @@
+// 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 "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
+#else // !defined(OS_MACOSX)
+#define MAYBE_ProductName DISABLED_ProductName
+#endif // defined(OS_MACOSX)
+TEST(Resources, 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();
+}
+
+} // namespace remoting