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