OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 #include "base/environment.h" | |
6 #include "base/scoped_ptr.h" | |
7 #include "base/string_util.h" | |
8 #include "chrome/plugin/plugin_interpose_util_mac.h" | |
9 #include "content/common/chrome_application_mac.h" | |
10 #include "content/common/plugin_carbon_interpose_constants_mac.h" | |
11 | |
12 #if !defined(__LP64__) | |
13 void TrimInterposeEnvironment() { | |
14 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
15 | |
16 std::string interpose_list; | |
17 if (!env->GetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey, | |
18 &interpose_list)) { | |
19 NOTREACHED() << "No interposing libraries set"; | |
20 return; | |
21 } | |
22 | |
23 // The list is a :-separated list of paths. Because we append our interpose | |
24 // library just before forking in plugin_process_host.cc, the only cases we | |
25 // need to handle are: | |
26 // 1) The whole string is "<kInterposeLibraryPath>", so just clear it, or | |
27 // 2) ":<kInterposeLibraryPath>" is the end of the string, so trim and re-set. | |
28 std::string interpose_library_path( | |
29 plugin_interpose_strings::kInterposeLibraryPath); | |
30 DCHECK_GE(interpose_list.size(), interpose_library_path.size()); | |
31 size_t suffix_offset = interpose_list.size() - interpose_library_path.size(); | |
32 if (suffix_offset == 0 && | |
33 interpose_list == interpose_library_path) { | |
34 env->UnSetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey); | |
35 } else if (suffix_offset > 0 && interpose_list[suffix_offset - 1] == ':' && | |
36 interpose_list.substr(suffix_offset) == interpose_library_path) { | |
37 std::string trimmed_list = interpose_list.substr(0, suffix_offset - 1); | |
38 env->SetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey, | |
39 trimmed_list.c_str()); | |
40 } else { | |
41 NOTREACHED() << "Missing Carbon interposing library"; | |
42 } | |
43 } | |
44 #endif | |
45 | |
46 void InitializeChromeApplication() { | |
47 [CrApplication sharedApplication]; | |
48 | |
49 mac_plugin_interposing::SetUpCocoaInterposing(); | |
50 } | |
OLD | NEW |