Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1384835 (part 3, attempt 2) - Remove the Preferences::Get*CString…
Browse files Browse the repository at this point in the history
…() variants that return nsAdoptingCString. r=froydnj.
  • Loading branch information
nnethercote committed Jul 31, 2017
1 parent d67cd0f commit a9f2193
Show file tree
Hide file tree
Showing 49 changed files with 216 additions and 229 deletions.
6 changes: 4 additions & 2 deletions caps/nsScriptSecurityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,8 @@ nsScriptSecurityManager::EnsureFileURIWhitelist()
//

mFileURIWhitelist.emplace();
auto policies = mozilla::Preferences::GetCString("capability.policy.policynames");
nsAutoCString policies;
mozilla::Preferences::GetCString("capability.policy.policynames", policies);
for (uint32_t base = SkipPast<IsWhitespaceOrComma>(policies, 0), bound = 0;
base < policies.Length();
base = SkipPast<IsWhitespaceOrComma>(policies, bound))
Expand All @@ -1665,7 +1666,8 @@ nsScriptSecurityManager::EnsureFileURIWhitelist()
nsCString domainPrefName = NS_LITERAL_CSTRING("capability.policy.") +
policyName +
NS_LITERAL_CSTRING(".sites");
auto siteList = Preferences::GetCString(domainPrefName.get());
nsAutoCString siteList;
Preferences::GetCString(domainPrefName.get(), siteList);
AddSitesToFileURIWhitelist(siteList);
}

Expand Down
9 changes: 5 additions & 4 deletions chrome/nsChromeRegistryChrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,12 @@ nsChromeRegistryChrome::OverrideLocalePackage(const nsACString& aPackage,
nsACString& aOverride)
{
const nsACString& pref = NS_LITERAL_CSTRING(PACKAGE_OVERRIDE_BRANCH) + aPackage;
nsAdoptingCString override = mozilla::Preferences::GetCString(PromiseFlatCString(pref).get());
if (override) {
nsAutoCString override;
nsresult rv =
mozilla::Preferences::GetCString(PromiseFlatCString(pref).get(), override);
if (NS_SUCCEEDED(rv)) {
aOverride = override;
}
else {
} else {
aOverride = aPackage;
}
return NS_OK;
Expand Down
13 changes: 7 additions & 6 deletions docshell/base/nsDefaultURIFixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,16 +578,17 @@ nsDefaultURIFixup::MakeAlternateURI(nsIURI* aURI)
// are www. & .com but they could be any other value, e.g. www. & .org

nsAutoCString prefix("www.");
nsAdoptingCString prefPrefix =
Preferences::GetCString("browser.fixup.alternate.prefix");
if (prefPrefix) {
nsAutoCString prefPrefix;
nsresult rv =
Preferences::GetCString("browser.fixup.alternate.prefix", prefPrefix);
if (NS_SUCCEEDED(rv)) {
prefix.Assign(prefPrefix);
}

nsAutoCString suffix(".com");
nsAdoptingCString prefSuffix =
Preferences::GetCString("browser.fixup.alternate.suffix");
if (prefSuffix) {
nsAutoCString prefSuffix;
rv = Preferences::GetCString("browser.fixup.alternate.suffix", prefSuffix);
if (NS_SUCCEEDED(rv)) {
suffix.Assign(prefSuffix);
}

Expand Down
15 changes: 9 additions & 6 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5099,9 +5099,11 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
}

// See if an alternate cert error page is registered
nsAdoptingCString alternateErrorPage =
Preferences::GetCString("security.alternate_certificate_error_page");
if (alternateErrorPage) {
nsAutoCString alternateErrorPage;
nsresult rv =
Preferences::GetCString("security.alternate_certificate_error_page",
alternateErrorPage);
if (NS_SUCCEEDED(rv)) {
errorPage.Assign(alternateErrorPage);
}

Expand All @@ -5123,9 +5125,10 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,

// Malware and phishing detectors may want to use an alternate error
// page, but if the pref's not set, we'll fall back on the standard page
nsAdoptingCString alternateErrorPage =
Preferences::GetCString("urlclassifier.alternate_error_page");
if (alternateErrorPage) {
nsAutoCString alternateErrorPage;
nsresult rv = Preferences::GetCString("urlclassifier.alternate_error_page",
alternateErrorPage);
if (NS_SUCCEEDED(rv)) {
errorPage.Assign(alternateErrorPage);
}

Expand Down
7 changes: 4 additions & 3 deletions dom/audiochannel/AudioChannelAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ AudioChannelAgent::FindCorrectWindow(nsPIDOMWindowInner* aWindow)
return NS_OK;
}

nsAdoptingCString systemAppUrl =
mozilla::Preferences::GetCString("b2g.system_startup_url");
if (!systemAppUrl) {
nsAutoCString systemAppUrl;
nsresult rv =
mozilla::Preferences::GetCString("b2g.system_startup_url", systemAppUrl);
if (NS_FAILED(rv)) {
return NS_OK;
}

Expand Down
12 changes: 6 additions & 6 deletions dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,12 +1705,11 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
}

if (gDumpFile == nullptr) {
const nsAdoptingCString& fname =
Preferences::GetCString("browser.dom.window.dump.file");
nsAutoCString fname;
Preferences::GetCString("browser.dom.window.dump.file", fname);
if (!fname.IsEmpty()) {
// if this fails to open, Dump() knows to just go to stdout
// on null.
gDumpFile = fopen(fname, "wb+");
// If this fails to open, Dump() knows to just go to stdout on null.
gDumpFile = fopen(fname.get(), "wb+");
} else {
gDumpFile = stdout;
}
Expand Down Expand Up @@ -6941,7 +6940,8 @@ GetFullscreenTransitionDuration(bool aEnterFullscreen,
const char* pref = aEnterFullscreen ?
"full-screen-api.transition-duration.enter" :
"full-screen-api.transition-duration.leave";
nsAdoptingCString prefValue = Preferences::GetCString(pref);
nsAutoCString prefValue;
Preferences::GetCString(pref, prefValue);
if (!prefValue.IsEmpty()) {
sscanf(prefValue.get(), "%hu%hu",
&aDuration->mFadeIn, &aDuration->mFadeOut);
Expand Down
9 changes: 5 additions & 4 deletions dom/base/nsObjectLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,8 @@ nsObjectLoadingContent::BuildParametersArray()
NS_ENSURE_SUCCESS(rv, rv);
}

nsAdoptingCString wmodeOverride = Preferences::GetCString("plugins.force.wmode");
nsAutoCString wmodeOverride;
Preferences::GetCString("plugins.force.wmode", wmodeOverride);
for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
if (!wmodeOverride.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);
Expand Down Expand Up @@ -1663,8 +1664,7 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI)
///

if (aJavaURI || thisContent->NodeInfo()->Equals(nsGkAtoms::applet)) {
nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
newMime = javaMIME;
Preferences::GetCString(kPrefJavaMIME, newMime);
NS_ASSERTION(IsJavaMIME(newMime),
"plugin.mime.java should be recognized as java");
isJava = true;
Expand All @@ -1687,7 +1687,8 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI)
thisContent->GetAttr(kNameSpaceID_None, nsGkAtoms::classid, classIDAttr);
if (!classIDAttr.IsEmpty()) {
// Our classid support is limited to 'java:' ids
nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
nsAutoCString javaMIME;
Preferences::GetCString(kPrefJavaMIME, javaMIME);
NS_ASSERTION(IsJavaMIME(javaMIME),
"plugin.mime.java should be recognized as java");
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
Expand Down
4 changes: 3 additions & 1 deletion dom/base/nsPluginArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ operator<(const RefPtr<nsPluginElement>& lhs,
static bool
PluginShouldBeHidden(const nsCString& aName) {
// This only supports one hidden plugin
return Preferences::GetCString("plugins.navigator.hidden_ctp_plugin").Equals(aName);
nsAutoCString value;
Preferences::GetCString("plugins.navigator.hidden_ctp_plugin", value);
return value.Equals(aName);
}

void
Expand Down
4 changes: 2 additions & 2 deletions dom/encoding/FallbackEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ FallbackEncoding::Get()
return WrapNotNull(mFallback);
}

const nsAdoptingCString& override =
Preferences::GetCString("intl.charset.fallback.override");
nsAutoCString override;
Preferences::GetCString("intl.charset.fallback.override", override);
// Don't let the user break things by setting the override to unreasonable
// values via about:config
auto encoding = Encoding::ForLabel(override);
Expand Down
3 changes: 2 additions & 1 deletion dom/events/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,8 @@ Event::PopupAllowedEventsChanged()
free(sPopupAllowedEvents);
}

nsAdoptingCString str = Preferences::GetCString("dom.popup_allowed_events");
nsAutoCString str;
Preferences::GetCString("dom.popup_allowed_events", str);

// We'll want to do this even if str is empty to avoid looking up
// this pref all the time if it's not set.
Expand Down
4 changes: 2 additions & 2 deletions dom/indexedDB/IndexedDatabaseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ IndexedDatabaseManager::Init()
kPrefMaxSerilizedMsgSize);

#ifdef ENABLE_INTL_API
const nsAdoptingCString& acceptLang =
Preferences::GetLocalizedCString("intl.accept_languages");
nsAutoCString acceptLang;
Preferences::GetLocalizedCString("intl.accept_languages", acceptLang);

// Split values on commas.
nsCCharSeparatedTokenizer langTokenizer(acceptLang, ',');
Expand Down
19 changes: 11 additions & 8 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1511,13 +1511,15 @@ StartMacOSContentSandbox()
// These paths are used to whitelist certain directories used by the testing
// system. They should not be considered a public API, and are only intended
// for use in automation.
nsAdoptingCString testingReadPath1 =
Preferences::GetCString("security.sandbox.content.mac.testing_read_path1");
nsAutoCString testingReadPath1;
Preferences::GetCString("security.sandbox.content.mac.testing_read_path1",
testingReadPath1);
if (!testingReadPath1.IsEmpty()) {
info.testingReadPath1.assign(testingReadPath1.get());
}
nsAdoptingCString testingReadPath2 =
Preferences::GetCString("security.sandbox.content.mac.testing_read_path2");
nsAutoCString testingReadPath2;
Preferences::GetCString("security.sandbox.content.mac.testing_read_path2",
testingReadPath2);
if (!testingReadPath2.IsEmpty()) {
info.testingReadPath2.assign(testingReadPath2.get());
}
Expand Down Expand Up @@ -1605,11 +1607,12 @@ ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker)
}
// Allow user overrides of seccomp-bpf syscall filtering
std::vector<int> syscallWhitelist;
nsAdoptingCString extraSyscalls =
Preferences::GetCString("security.sandbox.content.syscall_whitelist");
if (extraSyscalls) {
nsAutoCString extraSyscalls;
nsresult rv =
Preferences::GetCString("security.sandbox.content.syscall_whitelist",
extraSyscalls);
if (NS_SUCCEEDED(rv)) {
for (const nsACString& callNrString : extraSyscalls.Split(',')) {
nsresult rv;
int callNr = PromiseFlatCString(callNrString).ToInteger(&rv);
if (NS_SUCCEEDED(rv)) {
syscallWhitelist.push_back(callNr);
Expand Down
3 changes: 2 additions & 1 deletion dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,8 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
boolPrefs.Append(nsPrintfCString("%u:%d|", i, Preferences::GetBool(ContentPrefs::GetContentPref(i))));
break;
case nsIPrefBranch::PREF_STRING: {
nsAdoptingCString value(Preferences::GetCString(ContentPrefs::GetContentPref(i)));
nsAutoCString value;
Preferences::GetCString(ContentPrefs::GetContentPref(i), value);
stringPrefs.Append(nsPrintfCString("%u:%d;%s|", i, value.Length(), value.get()));

}
Expand Down
13 changes: 7 additions & 6 deletions dom/media/DecoderDoctorDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ AllowNotification(const NotificationAndReportStringId& aNotification)
// - Comma-separater list of ids -> Allow if aReportStringId (from
// dom.properties) is one of them.
// - Nothing (missing or empty) -> Disable everything.
nsAdoptingCString filter =
Preferences::GetCString("media.decoder-doctor.notifications-allowed");
nsAutoCString filter;
Preferences::GetCString("media.decoder-doctor.notifications-allowed", filter);
return filter.EqualsLiteral("*") ||
StringListContains(filter, aNotification.mReportStringId);
}
Expand All @@ -424,10 +424,11 @@ AllowDecodeIssue(const MediaResult& aDecodeIssue, bool aDecodeIssueIsError)
// - '*' -> Allow everything.
// - Comma-separater list of ids -> Allow if the issue name is one of them.
// - Nothing (missing or empty) -> Disable everything.
nsAdoptingCString filter =
Preferences::GetCString(aDecodeIssueIsError
? "media.decoder-doctor.decode-errors-allowed"
: "media.decoder-doctor.decode-warnings-allowed");
nsAutoCString filter;
Preferences::GetCString(aDecodeIssueIsError
? "media.decoder-doctor.decode-errors-allowed"
: "media.decoder-doctor.decode-warnings-allowed",
filter);
if (filter.EqualsLiteral("*")) {
return true;
}
Expand Down
12 changes: 7 additions & 5 deletions dom/media/MediaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,16 +1699,16 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
RefPtr<PledgeSourceSet> p = new PledgeSourceSet();
uint32_t id = mOutstandingPledges.Append(*p);

nsAdoptingCString audioLoopDev, videoLoopDev;
nsAutoCString audioLoopDev, videoLoopDev;
if (!aFake) {
// Fake stream not requested. The entire device stack is available.
// Loop in loopback devices if they are set, and their respective type is
// requested. This is currently used for automated media tests only.
if (aVideoType == MediaSourceEnum::Camera) {
videoLoopDev = Preferences::GetCString("media.video_loopback_dev");
Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
}
if (aAudioType == MediaSourceEnum::Microphone) {
audioLoopDev = Preferences::GetCString("media.audio_loopback_dev");
Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
}
}

Expand All @@ -1735,15 +1735,17 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
if (hasVideo) {
nsTArray<RefPtr<VideoDevice>> videos;
GetSources(fakeCams? fakeBackend : realBackend, aVideoType,
&MediaEngine::EnumerateVideoDevices, videos, videoLoopDev);
&MediaEngine::EnumerateVideoDevices, videos,
videoLoopDev.get());
for (auto& source : videos) {
result->AppendElement(source);
}
}
if (hasAudio) {
nsTArray<RefPtr<AudioDevice>> audios;
GetSources(fakeMics? fakeBackend : realBackend, aAudioType,
&MediaEngine::EnumerateAudioDevices, audios, audioLoopDev);
&MediaEngine::EnumerateAudioDevices, audios,
audioLoopDev.get());
for (auto& source : audios) {
result->AppendElement(source);
}
Expand Down
4 changes: 2 additions & 2 deletions dom/media/webspeech/recognition/SpeechRecognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ GetSpeechRecognitionService(const nsAString& aLang)
{
nsAutoCString speechRecognitionServiceCID;

nsAdoptingCString prefValue =
Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE);
nsAutoCString prefValue;
Preferences::GetCString(PREFERENCE_DEFAULT_RECOGNITION_SERVICE, prefValue);
nsAutoCString speechRecognitionService;

if (!aLang.IsEmpty()) {
Expand Down
26 changes: 14 additions & 12 deletions dom/plugins/base/nsPluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,8 +1554,8 @@ nsPluginHost::RegisterFakePlugin(JS::Handle<JS::Value> aInitDictionary,

mFakePlugins.AppendElement(newTag);

nsAdoptingCString disableFullPage =
Preferences::GetCString(kPrefDisableFullPage);
nsAutoCString disableFullPage;
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
for (uint32_t i = 0; i < newTag->MimeTypes().Length(); i++) {
if (!IsTypeInList(newTag->MimeTypes()[i], disableFullPage)) {
RegisterWithCategoryManager(newTag->MimeTypes()[i],
Expand Down Expand Up @@ -1822,8 +1822,9 @@ nsPluginHost::GetSpecialType(const nsACString & aMIMEType)

// The java mime pref may well not be one of these,
// e.g. application/x-java-test used in the test suite
nsAdoptingCString javaMIME = Preferences::GetCString(kPrefJavaMIME);
if ((!javaMIME.IsEmpty() && noParam.LowerCaseEqualsASCII(javaMIME)) ||
nsAutoCString javaMIME;
Preferences::GetCString(kPrefJavaMIME, javaMIME);
if ((!javaMIME.IsEmpty() && noParam.LowerCaseEqualsASCII(javaMIME.get())) ||
noParam.LowerCaseEqualsASCII("application/x-java-vm") ||
noParam.LowerCaseEqualsASCII("application/x-java-applet") ||
noParam.LowerCaseEqualsASCII("application/x-java-bean")) {
Expand Down Expand Up @@ -2013,8 +2014,8 @@ nsPluginHost::AddPluginTag(nsPluginTag* aPluginTag)
mPlugins = aPluginTag;

if (aPluginTag->IsActive()) {
nsAdoptingCString disableFullPage =
Preferences::GetCString(kPrefDisableFullPage);
nsAutoCString disableFullPage;
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
if (!IsTypeInList(aPluginTag->MimeTypes()[i], disableFullPage)) {
RegisterWithCategoryManager(aPluginTag->MimeTypes()[i],
Expand Down Expand Up @@ -2407,8 +2408,8 @@ nsPluginHost::SetPluginsInContent(uint32_t aPluginEpoch,
tag.extensions(),
tag.niceName(),
tag.sandboxScript()));
nsAdoptingCString disableFullPage =
Preferences::GetCString(kPrefDisableFullPage);
nsAutoCString disableFullPage;
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
for (uint32_t i = 0; i < pluginTag->MimeTypes().Length(); i++) {
if (!IsTypeInList(pluginTag->MimeTypes()[i], disableFullPage)) {
RegisterWithCategoryManager(pluginTag->MimeTypes()[i],
Expand Down Expand Up @@ -2655,8 +2656,8 @@ nsPluginHost::UpdateInMemoryPluginInfo(nsPluginTag* aPluginTag)
}

// Update types with category manager
nsAdoptingCString disableFullPage =
Preferences::GetCString(kPrefDisableFullPage);
nsAutoCString disableFullPage;
Preferences::GetCString(kPrefDisableFullPage, disableFullPage);
for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
nsRegisterType shouldRegister;

Expand Down Expand Up @@ -2694,8 +2695,9 @@ nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
/* static */ bool
nsPluginHost::IsTypeWhitelisted(const char *aMimeType)
{
nsAdoptingCString whitelist = Preferences::GetCString(kPrefWhitelist);
if (!whitelist.Length()) {
nsAutoCString whitelist;
Preferences::GetCString(kPrefWhitelist, whitelist);
if (whitelist.IsEmpty()) {
return true;
}
nsDependentCString wrap(aMimeType);
Expand Down
Loading

0 comments on commit a9f2193

Please sign in to comment.