Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5479)

Unified Diff: chrome/plugin/plugin_main_mac.mm

Issue 3043018: base: Add UnSetEnv function to EnvVarGetter API. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/plugin/plugin_main_mac.mm
diff --git a/chrome/plugin/plugin_main_mac.mm b/chrome/plugin/plugin_main_mac.mm
index 56b7c959f806604ca78952bc21931569f934066f..119f98683dae4ffd0ef7767bffc7565a37354c88 100644
--- a/chrome/plugin/plugin_main_mac.mm
+++ b/chrome/plugin/plugin_main_mac.mm
@@ -1,17 +1,21 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/chrome_application_mac.h"
+#include "base/env_var.h"
+#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "chrome/common/plugin_carbon_interpose_constants_mac.h"
#include "chrome/plugin/plugin_interpose_util_mac.h"
#if !defined(__LP64__)
void TrimInterposeEnvironment() {
- const char* interpose_list =
- getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey);
- if (!interpose_list) {
+ scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create());
+
+ std::string interpose_list;
+ if (!env->GetEnv(plugin_interpose_strings::kDYLDInsertLibrariesKey,
+ &interpose_list)) {
NOTREACHED() << "No interposing libraries set";
return;
}
@@ -21,19 +25,19 @@ void TrimInterposeEnvironment() {
// need to handle are:
// 1) The whole string is "<kInterposeLibraryPath>", so just clear it, or
// 2) ":<kInterposeLibraryPath>" is the end of the string, so trim and re-set.
- int suffix_offset = strlen(interpose_list) -
+ int suffix_offset = strlen(interpose_list.c_str()) -
viettrungluu 2010/07/31 01:50:02 No, don't do strlen(foo.c_str()). std::string has
strlen(plugin_interpose_strings::kInterposeLibraryPath);
+
if (suffix_offset == 0 &&
- strcmp(interpose_list,
+ strcmp(interpose_list.c_str(),
plugin_interpose_strings::kInterposeLibraryPath) == 0) {
- unsetenv(plugin_interpose_strings::kDYLDInsertLibrariesKey);
+ env->UnSetEnv(plugin_interpose_strings::kDYLDInsertLibrariesKey);
} else if (suffix_offset > 0 && interpose_list[suffix_offset - 1] == ':' &&
- strcmp(interpose_list + suffix_offset,
+ strcmp(interpose_list.c_str() + suffix_offset,
viettrungluu 2010/07/31 01:50:02 You shouldn't do foo.c_str() + n either. There's a
plugin_interpose_strings::kInterposeLibraryPath) == 0) {
- std::string trimmed_list =
- std::string(interpose_list).substr(0, suffix_offset - 1);
- setenv(plugin_interpose_strings::kDYLDInsertLibrariesKey,
- trimmed_list.c_str(), 1);
+ std::string trimmed_list = interpose_list.substr(0, suffix_offset - 1);
+ env->SetEnv(plugin_interpose_strings::kDYLDInsertLibrariesKey,
+ trimmed_list.c_str());
} else {
NOTREACHED() << "Missing Carbon interposing library";
}

Powered by Google App Engine
This is Rietveld 408576698