OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #include "remoting/base/resources.h" |
| 8 #include "base/mac/bundle_locations.h" |
| 9 #include "ui/base/l10n/l10n_util_mac.h" |
| 10 #include "ui/base/resource/resource_bundle.h" |
| 11 |
| 12 // A dummy class used to locate the host plugin's bundle. |
| 13 @interface NSBundleLocator : NSObject |
| 14 @end |
| 15 |
| 16 @implementation NSBundleLocator |
| 17 @end |
| 18 |
| 19 namespace remoting { |
| 20 |
| 21 bool LoadResources(const std::string& pref_locale) { |
| 22 if (ui::ResourceBundle::HasSharedInstance()) { |
| 23 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(pref_locale); |
| 24 } else { |
| 25 // Use the plugin's bundle instead of the hosting app bundle. |
| 26 base::mac::SetOverrideFrameworkBundle( |
| 27 [NSBundle bundleForClass:[NSBundleLocator class]]); |
| 28 |
| 29 // Override the locale with the value from Cocoa. |
| 30 if (pref_locale.empty()) |
| 31 l10n_util::OverrideLocaleWithCocoaLocale(); |
| 32 |
| 33 ui::ResourceBundle::InitSharedInstanceLocaleOnly(pref_locale, NULL); |
| 34 } |
| 35 |
| 36 return true; |
| 37 } |
| 38 |
| 39 void UnloadResources() { |
| 40 ui::ResourceBundle::CleanupSharedInstance(); |
| 41 } |
| 42 |
| 43 } // namespace remoting |
OLD | NEW |