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

Unified Diff: chrome/browser/extensions/window_event_router.cc

Issue 10694085: Refactor extension event distribution to use Values instead of JSON strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing memory leak in a test. Created 8 years, 4 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
« no previous file with comments | « chrome/browser/extensions/window_event_router.h ('k') | chrome/browser/history/history_extension_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/window_event_router.cc
diff --git a/chrome/browser/extensions/window_event_router.cc b/chrome/browser/extensions/window_event_router.cc
index dc056de22018f4026d00c98d7a01c30d8a0557a9..00d032b36b5bb34980e6c679c9dc1183e3ae7767 100644
--- a/chrome/browser/extensions/window_event_router.cc
+++ b/chrome/browser/extensions/window_event_router.cc
@@ -67,11 +67,11 @@ void WindowEventRouter::OnWindowControllerAdded(
if (!profile_->IsSameProfile(window_controller->profile()))
return;
- base::ListValue args;
+ scoped_ptr<base::ListValue> args(new ListValue());
DictionaryValue* window_dictionary = window_controller->CreateWindowValue();
- args.Append(window_dictionary);
+ args->Append(window_dictionary);
DispatchEvent(event_names::kOnWindowCreated, window_controller->profile(),
- &args);
+ args.Pass());
}
void WindowEventRouter::OnWindowControllerRemoved(
@@ -80,10 +80,10 @@ void WindowEventRouter::OnWindowControllerRemoved(
return;
int window_id = window_controller->GetWindowId();
- base::ListValue args;
- args.Append(Value::CreateIntegerValue(window_id));
+ scoped_ptr<base::ListValue> args(new ListValue());
+ args->Append(Value::CreateIntegerValue(window_id));
DispatchEvent(event_names::kOnWindowRemoved, window_controller->profile(),
- &args);
+ args.Pass());
}
#if defined(TOOLKIT_VIEWS)
@@ -132,22 +132,18 @@ void WindowEventRouter::OnActiveWindowChanged(
focused_profile_ = window_profile;
focused_window_id_ = window_id;
- base::ListValue real_args;
- real_args.Append(Value::CreateIntegerValue(window_id));
- std::string real_json_args;
- base::JSONWriter::Write(&real_args, &real_json_args);
+ scoped_ptr<base::ListValue> real_args(new ListValue());
+ real_args->Append(Value::CreateIntegerValue(window_id));
// When switching between windows in the default and incognitoi profiles,
// dispatch WINDOW_ID_NONE to extensions whose profile lost focus that
// can't see the new focused window across the incognito boundary.
// See crbug.com/46610.
- std::string none_json_args;
+ scoped_ptr<base::ListValue> none_args(new ListValue());
if (focused_profile_ != NULL && previous_focused_profile != NULL &&
focused_profile_ != previous_focused_profile) {
- ListValue none_args;
- none_args.Append(
+ none_args->Append(
Value::CreateIntegerValue(extension_misc::kUnknownWindowId));
- base::JSONWriter::Write(&none_args, &none_json_args);
}
if (!window_profile)
@@ -160,19 +156,17 @@ void WindowEventRouter::OnActiveWindowChanged(
ExtensionSystem::Get(window_profile)->event_router()->
DispatchEventsToRenderersAcrossIncognito(
event_names::kOnWindowFocusedChanged,
- real_json_args,
+ real_args.Pass(),
window_profile,
- none_json_args,
+ none_args.Pass(),
GURL());
}
void WindowEventRouter::DispatchEvent(const char* event_name,
Profile* profile,
- base::ListValue* args) {
- std::string json_args;
- base::JSONWriter::Write(args, &json_args);
+ scoped_ptr<base::ListValue> args) {
ExtensionSystem::Get(profile)->event_router()->
- DispatchEventToRenderers(event_name, json_args, profile, GURL());
+ DispatchEventToRenderers(event_name, args.Pass(), profile, GURL());
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/window_event_router.h ('k') | chrome/browser/history/history_extension_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698