Index: mojo/shell/mojo_url_resolver.cc |
diff --git a/mojo/shell/mojo_url_resolver.cc b/mojo/shell/mojo_url_resolver.cc |
index 35059547e94d797cdc7ffa993de6a8d5841f3112..599fdfd57f870d5aa34e40d79c5c5582eb706b48 100644 |
--- a/mojo/shell/mojo_url_resolver.cc |
+++ b/mojo/shell/mojo_url_resolver.cc |
@@ -6,6 +6,7 @@ |
#include "base/base_paths.h" |
#include "base/files/file_path.h" |
+#include "base/file_util.h" |
#include "base/logging.h" |
#include "base/path_service.h" |
#include "net/base/filename_util.h" |
@@ -15,16 +16,19 @@ namespace mojo { |
namespace shell { |
namespace { |
-std::string MakeSharedLibraryName(const std::string& host_name) { |
+void MakeSharedLibraryNames(const std::string& host_name, |
+ std::vector<std::string>* names) { |
#if defined(OS_WIN) |
- return host_name + ".dll"; |
+ names->push_back(host_name + ".dll"); |
#elif defined(OS_LINUX) || defined(OS_ANDROID) |
- return "lib" + host_name + ".so"; |
+ names->push_back("lib" + host_name + ".so"); |
+#if defined(OS_ANDROID) |
+ names->push_back("lib" + host_name + ".cr.so"); |
qsr
2014/06/26 12:31:47
The component build on android names its library .
viettrungluu
2014/06/26 16:59:57
So I learned that we're probably doing it wrong, a
qsr
2014/06/27 11:18:18
Hum... Very nice. That also probably explain my is
|
+#endif |
#elif defined(OS_MACOSX) |
- return "lib" + host_name + ".dylib"; |
+ names->push_back("lib" + host_name + ".dylib"); |
#else |
NOTREACHED() << "dynamic loading of services not supported"; |
- return std::string(); |
#endif |
} |
@@ -52,26 +56,35 @@ GURL MojoURLResolver::Resolve(const GURL& mojo_url) const { |
if (it != url_map_.end()) |
return it->second; |
- std::string lib = MakeSharedLibraryName(mojo_url.host()); |
+ |
+ std::vector<std::string> libs; |
+ MakeSharedLibraryNames(mojo_url.host(), &libs); |
+ DCHECK(!libs.empty()); |
if (local_file_set_.find(mojo_url) != local_file_set_.end()) { |
// Resolve to a local file URL. |
- base::FilePath path; |
+ base::FilePath base_path; |
#if defined(OS_ANDROID) |
// On Android, additional lib are bundled. |
- PathService::Get(base::DIR_MODULE, &path); |
+ PathService::Get(base::DIR_MODULE, &base_path); |
#else |
- PathService::Get(base::DIR_EXE, &path); |
+ PathService::Get(base::DIR_EXE, &base_path); |
#if !defined(OS_WIN) |
- path = path.Append(FILE_PATH_LITERAL("lib")); |
+ base_path = base_path.Append(FILE_PATH_LITERAL("lib")); |
#endif // !defined(OS_WIN) |
#endif // defined(OS_ANDROID) |
- path = path.Append(base::FilePath::FromUTF8Unsafe(lib)); |
- return net::FilePathToFileURL(path); |
+ for (std::vector<std::string>::iterator it = libs.begin(); it != libs.end(); |
+ ++it) { |
+ base::FilePath path = |
+ base_path.Append(base::FilePath::FromUTF8Unsafe(*it)); |
+ if (base::PathExists(path)) { |
+ return net::FilePathToFileURL(path); |
+ } |
+ } |
} |
// Otherwise, resolve to an URL relative to origin_. |
- return GURL(origin_ + "/" + lib); |
+ return GURL(origin_ + "/" + libs[0]); |
} |
} // namespace shell |