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

Side by Side Diff: chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.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: Build fix. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h" 5 #include "chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 void OffscreenTab::Observe(int type, 258 void OffscreenTab::Observe(int type,
259 const NotificationSource& source, 259 const NotificationSource& source,
260 const NotificationDetails& details) { 260 const NotificationDetails& details) {
261 CHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); 261 CHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
262 262
263 DictionaryValue* changed_properties = new DictionaryValue(); 263 DictionaryValue* changed_properties = new DictionaryValue();
264 changed_properties->SetString( 264 changed_properties->SetString(
265 tabs_keys::kUrlKey, web_contents()->GetURL().spec()); 265 tabs_keys::kUrlKey, web_contents()->GetURL().spec());
266 266
267 ListValue args; 267 ListValue* args = new ListValue();
268 args.Append(Value::CreateIntegerValue( 268 args->Append(Value::CreateIntegerValue(
269 ExtensionTabUtil::GetTabId(web_contents()))); 269 ExtensionTabUtil::GetTabId(web_contents())));
270 args.Append(changed_properties); 270 args->Append(changed_properties);
271 args.Append(CreateValue()); 271 args->Append(CreateValue());
272 std::string json_args;
273 base::JSONWriter::Write(&args, &json_args);
274 272
275 // The event router only dispatches the event to renderers listening for the 273 // The event router only dispatches the event to renderers listening for the
276 // event. 274 // event.
277 Profile* profile = parent_tab_->tab_contents()->profile(); 275 Profile* profile = parent_tab_->tab_contents()->profile();
278 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 276 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
279 events::kOnOffscreenTabUpdated, json_args, profile, GURL()); 277 events::kOnOffscreenTabUpdated, args, profile, GURL());
280 } 278 }
281 279
282 ParentTab::ParentTab() : tab_contents_(NULL) {} 280 ParentTab::ParentTab() : tab_contents_(NULL) {}
283 ParentTab::~ParentTab() {} 281 ParentTab::~ParentTab() {}
284 282
285 void ParentTab::Init(WebContents* web_contents, 283 void ParentTab::Init(WebContents* web_contents,
286 const std::string& extension_id) { 284 const std::string& extension_id) {
287 CHECK(web_contents); 285 CHECK(web_contents);
288 286
289 extension_id_ = extension_id; 287 extension_id_ = extension_id;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 // async case (when a "javascript": URL is sent to a tab). 829 // async case (when a "javascript": URL is sent to a tab).
832 if (!is_async) 830 if (!is_async)
833 SendResponse(true); 831 SendResponse(true);
834 832
835 return true; 833 return true;
836 } 834 }
837 835
838 void UpdateOffscreenTabFunction::PopulateResult() { 836 void UpdateOffscreenTabFunction::PopulateResult() {
839 // There's no result associated with this callback. 837 // There's no result associated with this callback.
840 } 838 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698