OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import <AppKit/AppKit.h> | 5 #import <AppKit/AppKit.h> |
6 | 6 |
7 #include "base/environment.h" | 7 #include "base/environment.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "content/common/plugin_carbon_interpose_constants_mac.h" | 10 #include "content/common/plugin_carbon_interpose_constants_mac.h" |
11 #include "content/plugin/plugin_interpose_util_mac.h" | 11 #include "content/plugin/plugin_interpose_util_mac.h" |
12 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
13 | 13 |
| 14 namespace content { |
| 15 |
14 #if !defined(__LP64__) | 16 #if !defined(__LP64__) |
15 void TrimInterposeEnvironment() { | 17 void TrimInterposeEnvironment() { |
16 scoped_ptr<base::Environment> env(base::Environment::Create()); | 18 scoped_ptr<base::Environment> env(base::Environment::Create()); |
17 | 19 |
18 std::string interpose_list; | 20 std::string interpose_list; |
19 if (!env->GetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey, | 21 if (!env->GetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey, |
20 &interpose_list)) { | 22 &interpose_list)) { |
21 LOG(INFO) << "No Carbon Interpose library found."; | 23 LOG(INFO) << "No Carbon Interpose library found."; |
22 return; | 24 return; |
23 } | 25 } |
24 | 26 |
25 // The list is a :-separated list of paths. Because we append our interpose | 27 // The list is a :-separated list of paths. Because we append our interpose |
26 // library just before forking in plugin_process_host.cc, the only cases we | 28 // library just before forking in plugin_process_host.cc, the only cases we |
27 // need to handle are: | 29 // need to handle are: |
28 // 1) The whole string is "<kInterposeLibraryPath>", so just clear it, or | 30 // 1) The whole string is "<kInterposeLibraryPath>", so just clear it, or |
29 // 2) ":<kInterposeLibraryPath>" is the end of the string, so trim and re-set. | 31 // 2) ":<kInterposeLibraryPath>" is the end of the string, so trim and re-set. |
30 std::string interpose_library_path = | 32 std::string interpose_library_path = |
31 content::GetContentClient()->GetCarbonInterposePath(); | 33 GetContentClient()->GetCarbonInterposePath(); |
32 DCHECK_GE(interpose_list.size(), interpose_library_path.size()); | 34 DCHECK_GE(interpose_list.size(), interpose_library_path.size()); |
33 size_t suffix_offset = interpose_list.size() - interpose_library_path.size(); | 35 size_t suffix_offset = interpose_list.size() - interpose_library_path.size(); |
34 if (suffix_offset == 0 && | 36 if (suffix_offset == 0 && |
35 interpose_list == interpose_library_path) { | 37 interpose_list == interpose_library_path) { |
36 env->UnSetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey); | 38 env->UnSetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey); |
37 } else if (suffix_offset > 0 && interpose_list[suffix_offset - 1] == ':' && | 39 } else if (suffix_offset > 0 && interpose_list[suffix_offset - 1] == ':' && |
38 interpose_list.substr(suffix_offset) == interpose_library_path) { | 40 interpose_list.substr(suffix_offset) == interpose_library_path) { |
39 std::string trimmed_list = interpose_list.substr(0, suffix_offset - 1); | 41 std::string trimmed_list = interpose_list.substr(0, suffix_offset - 1); |
40 env->SetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey, | 42 env->SetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey, |
41 trimmed_list.c_str()); | 43 trimmed_list.c_str()); |
42 } else { | 44 } else { |
43 NOTREACHED() << "Missing Carbon interposing library"; | 45 NOTREACHED() << "Missing Carbon interposing library"; |
44 } | 46 } |
45 } | 47 } |
46 #endif | 48 #endif |
47 | 49 |
48 void InitializeChromeApplication() { | 50 void InitializeChromeApplication() { |
49 [NSApplication sharedApplication]; | 51 [NSApplication sharedApplication]; |
50 mac_plugin_interposing::SetUpCocoaInterposing(); | 52 mac_plugin_interposing::SetUpCocoaInterposing(); |
51 } | 53 } |
| 54 |
| 55 } // namespace content |
OLD | NEW |