1 // Copyright 2013 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 "remoting/base/resources.h"
9 #include "base/files/file_path.h"
10 #include "base/logging.h"
11 #include "base/path_service.h"
12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/base/ui_base_paths.h"
18 const char kLocaleResourcesDirName
[] = "remoting_locales";
21 bool LoadResources(const std::string
& pref_locale
) {
22 if (ui::ResourceBundle::HasSharedInstance()) {
23 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(pref_locale
);
25 // Retrieve the path to the module containing this function.
27 CHECK(dladdr(reinterpret_cast<void*>(&LoadResources
), &info
) != 0);
29 // Point DIR_LOCALES to 'remoting_locales'.
30 base::FilePath path
= base::FilePath(info
.dli_fname
).DirName();
31 PathService::Override(ui::DIR_LOCALES
,
32 path
.AppendASCII(kLocaleResourcesDirName
));
34 ui::ResourceBundle::InitSharedInstanceLocaleOnly(pref_locale
, NULL
);
40 void UnloadResources() {
41 ui::ResourceBundle::CleanupSharedInstance();
44 } // namespace remoting