diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 02:13:37 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 02:13:37 +0000 |
commit | d0a89a3b5789e4913dacce736e30c92391f23503 (patch) | |
tree | ea9e097b88c2ee312dd6600b10247cb5e0d9c7be /remoting/base | |
parent | 09f9fe7f2602524d432f0bf75f3b03b2b34e7c21 (diff) | |
download | chromium_src-d0a89a3b5789e4913dacce736e30c92391f23503.zip chromium_src-d0a89a3b5789e4913dacce736e30c92391f23503.tar.gz chromium_src-d0a89a3b5789e4913dacce736e30c92391f23503.tar.bz2 |
Fixed loading resources from the host plugin's bundle on Mac.
The plugins shares the Cocoa class namespace with the Chrome's helper binary hosting the plugin. Because the client plugin is compiled into Chrome, Chrome's instance of NSBundleLocator is passed to NSBundle::bundleForClass, breaking resource loading as the result.
This CL switches to using dladdr() to get the bundle path instead of NSBUndle::bundleForClass.
BUG=267239
Review URL: https://chromiumcodereview.appspot.com/21976003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r-- | remoting/base/resources_linux.cc | 2 | ||||
-rw-r--r-- | remoting/base/resources_mac.cc (renamed from remoting/base/resources_mac.mm) | 26 |
2 files changed, 15 insertions, 13 deletions
diff --git a/remoting/base/resources_linux.cc b/remoting/base/resources_linux.cc index af530e8..d7d23ba 100644 --- a/remoting/base/resources_linux.cc +++ b/remoting/base/resources_linux.cc @@ -22,7 +22,7 @@ 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. + // Retrieve the path to the module containing this function. Dl_info info; CHECK(dladdr(reinterpret_cast<void*>(&LoadResources), &info) != 0); diff --git a/remoting/base/resources_mac.mm b/remoting/base/resources_mac.cc index d1ce4af..7ea59b6 100644 --- a/remoting/base/resources_mac.mm +++ b/remoting/base/resources_mac.cc @@ -2,29 +2,31 @@ // 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 <dlfcn.h> + +#include "base/files/file_path.h" +#include "base/logging.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]]); + // Retrieve the path to the module containing this function. + Dl_info info; + CHECK(dladdr(reinterpret_cast<void*>(&LoadResources), &info) != 0); + + // Use the plugin's bundle instead of the hosting app bundle. The three + // DirName() calls strip "Contents/MacOS/<binary>" from the path. + base::FilePath path = + base::FilePath(info.dli_fname).DirName().DirName().DirName(); + base::mac::SetOverrideFrameworkBundlePath(path); // Override the locale with the value from Cocoa. if (pref_locale.empty()) |