summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autocomplete/search_provider.cc15
-rw-r--r--chrome/browser/bookmarks/bookmark_storage.cc2
-rw-r--r--chrome/browser/debugger/debugger_host_impl.cpp4
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc8
-rw-r--r--chrome/browser/dom_ui/dom_ui_host.cc8
-rw-r--r--chrome/browser/extensions/extensions_service.cc7
-rw-r--r--chrome/browser/page_state.cc13
7 files changed, 28 insertions, 29 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 32c2fb2..17bdcc8 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -129,13 +129,14 @@ void SearchProvider::OnURLFetchComplete(const URLFetcher* source,
}
}
- JSONStringValueSerializer deserializer(json_data);
- deserializer.set_allow_trailing_comma(true);
- Value* root_val = NULL;
- have_suggest_results_ = status.is_success() && (response_code == 200) &&
- deserializer.Deserialize(&root_val, NULL) &&
- ParseSuggestResults(root_val);
- delete root_val;
+ if (status.is_success() && response_code == 200) {
+ JSONStringValueSerializer deserializer(json_data);
+ deserializer.set_allow_trailing_comma(true);
+ scoped_ptr<Value> root_val(deserializer.Deserialize(NULL));
+ have_suggest_results_ =
+ root_val.get() && ParseSuggestResults(root_val.get());
+ }
+
ConvertResultsToAutocompleteMatches();
listener_->OnProviderUpdate(!suggest_results_.empty());
}
diff --git a/chrome/browser/bookmarks/bookmark_storage.cc b/chrome/browser/bookmarks/bookmark_storage.cc
index e6e9a50..23f47b4 100644
--- a/chrome/browser/bookmarks/bookmark_storage.cc
+++ b/chrome/browser/bookmarks/bookmark_storage.cc
@@ -167,7 +167,7 @@ void BookmarkStorageBackend::Read(scoped_refptr<BookmarkStorage> service,
Value* root = NULL;
if (bookmark_file_exists) {
JSONFileValueSerializer serializer(path);
- serializer.Deserialize(&root, NULL);
+ root = serializer.Deserialize(NULL);
}
// BookmarkStorage takes ownership of root.
diff --git a/chrome/browser/debugger/debugger_host_impl.cpp b/chrome/browser/debugger/debugger_host_impl.cpp
index c2eb41d..32c13fd 100644
--- a/chrome/browser/debugger/debugger_host_impl.cpp
+++ b/chrome/browser/debugger/debugger_host_impl.cpp
@@ -83,8 +83,8 @@ void DebuggerHostImpl::Debug(TabContents* tab) {
void DebuggerHostImpl::DebugMessage(const std::wstring& msg) {
- Value* msg_value = NULL;
- if (!JSONReader::Read(WideToUTF8(msg), &msg_value, false)) {
+ Value* msg_value = JSONReader::Read(WideToUTF8(msg), false);
+ if (!msg_value) {
msg_value = Value::CreateStringValue(L"Message parse error!");
}
ListValue* argv = new ListValue;
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index 4fe9070..e7f2765 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -31,9 +31,10 @@ void DOMUI::ProcessDOMUIMessage(const std::string& message,
return;
// Convert the content JSON into a Value.
- Value* value = NULL;
+ scoped_ptr<Value> value;
if (!content.empty()) {
- if (!JSONReader::Read(content, &value, false)) {
+ value.reset(JSONReader::Read(content, false));
+ if (!value.get()) {
// The page sent us something that we didn't understand.
// This probably indicates a programming error.
NOTREACHED();
@@ -42,8 +43,7 @@ void DOMUI::ProcessDOMUIMessage(const std::string& message,
}
// Forward this message and content on.
- callback->second->Run(value);
- delete value;
+ callback->second->Run(value.get());
}
void DOMUI::CallJavascriptFunction(const std::wstring& function_name,
diff --git a/chrome/browser/dom_ui/dom_ui_host.cc b/chrome/browser/dom_ui/dom_ui_host.cc
index d9d0333..ff2ca1e 100644
--- a/chrome/browser/dom_ui/dom_ui_host.cc
+++ b/chrome/browser/dom_ui/dom_ui_host.cc
@@ -78,9 +78,10 @@ void DOMUIHost::ProcessDOMUIMessage(const std::string& message,
return;
// Convert the content JSON into a Value.
- Value* value = NULL;
+ scoped_ptr<Value> value;
if (!content.empty()) {
- if (!JSONReader::Read(content, &value, false)) {
+ value.reset(JSONReader::Read(content, false));
+ if (!value.get()) {
// The page sent us something that we didn't understand.
// This probably indicates a programming error.
NOTREACHED();
@@ -89,8 +90,7 @@ void DOMUIHost::ProcessDOMUIMessage(const std::string& message,
}
// Forward this message and content on.
- callback->second->Run(value);
- delete value;
+ callback->second->Run(value.get());
}
WebPreferences DOMUIHost::GetWebkitPrefs() {
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index cd0397c..f38ff04 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -88,15 +88,14 @@ bool ExtensionsServiceBackend::LoadExtensionsFromDirectory(
}
JSONFileValueSerializer serializer(manifest_path.ToWStringHack());
- Value* root = NULL;
std::string error;
- if (!serializer.Deserialize(&root, &error)) {
+ scoped_ptr<Value> root(serializer.Deserialize(&error));
+ if (!root.get()) {
ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
error);
continue;
}
- scoped_ptr<Value> scoped_root(root);
if (!root->IsType(Value::TYPE_DICTIONARY)) {
ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
Extension::kInvalidManifestError);
@@ -104,7 +103,7 @@ bool ExtensionsServiceBackend::LoadExtensionsFromDirectory(
}
scoped_ptr<Extension> extension(new Extension(child_path));
- if (!extension->InitFromValue(*static_cast<DictionaryValue*>(root),
+ if (!extension->InitFromValue(*static_cast<DictionaryValue*>(root.get()),
&error)) {
ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
error);
diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc
index f47a4cf..1d52ffb 100644
--- a/chrome/browser/page_state.cc
+++ b/chrome/browser/page_state.cc
@@ -40,16 +40,15 @@ void PageState::InitWithBytes(const std::string& bytes) {
state_.reset(new DictionaryValue);
JSONStringValueSerializer serializer(bytes);
- Value* root = NULL;
+ scoped_ptr<Value> root(serializer.Deserialize(NULL));
- if (!serializer.Deserialize(&root, NULL))
+ if (!root.get()) {
NOTREACHED();
-
- if (root != NULL && root->GetType() == Value::TYPE_DICTIONARY) {
- state_.reset(static_cast<DictionaryValue*>(root));
- } else if (root) {
- delete root;
+ return;
}
+
+ if (root->GetType() == Value::TYPE_DICTIONARY)
+ state_.reset(static_cast<DictionaryValue*>(root.release()));
}
void PageState::GetByteRepresentation(std::string* out) const {