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

Side by Side Diff: chrome/browser/extensions/extension_browser_event_router.cc

Issue 289006: Issue 21729: Add new event chrome.tabs.onStatusChange . (Closed)
Patch Set: '' Created 11 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extension_browser_event_router.h" 5 #include "chrome/browser/extensions/extension_browser_event_router.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 DictionaryValue* changed_properties = NULL; 304 DictionaryValue* changed_properties = NULL;
305 if (did_navigate) 305 if (did_navigate)
306 changed_properties = entry.DidNavigate(contents); 306 changed_properties = entry.DidNavigate(contents);
307 else 307 else
308 changed_properties = entry.UpdateLoadState(contents); 308 changed_properties = entry.UpdateLoadState(contents);
309 309
310 if (changed_properties) { 310 if (changed_properties) {
311 // The state of the tab (as seen from the extension point of view) has 311 // The state of the tab (as seen from the extension point of view) has
312 // changed. Send a notification to the extension. 312 // changed. Send a notification to the extension.
313 ListValue args; 313 ListValue args;
314
315 // First arg: The id of the tab that changed.
314 args.Append(Value::CreateIntegerValue(tab_id)); 316 args.Append(Value::CreateIntegerValue(tab_id));
317
318 // Second arg: An object containing the changes to the tab state.
315 args.Append(changed_properties); 319 args.Append(changed_properties);
316 320
321 // Third arg: An object containing the state of the tab.
322 args.Append(ExtensionTabUtil::CreateTabValue(contents));
323
317 std::string json_args; 324 std::string json_args;
318 base::JSONWriter::Write(&args, false, &json_args); 325 base::JSONWriter::Write(&args, false, &json_args);
319 326
320 DispatchEvent(contents->profile(), events::kOnTabUpdated, json_args); 327 DispatchEvent(contents->profile(), events::kOnTabUpdated, json_args);
321 } 328 }
322 } 329 }
323 330
324 void ExtensionBrowserEventRouter::Observe(NotificationType type, 331 void ExtensionBrowserEventRouter::Observe(NotificationType type,
325 const NotificationSource& source, 332 const NotificationSource& source,
326 const NotificationDetails& details) { 333 const NotificationDetails& details) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 return; 389 return;
383 390
384 ListValue args; 391 ListValue args;
385 args.Append(ExtensionTabUtil::CreateTabValue(tab_contents)); 392 args.Append(ExtensionTabUtil::CreateTabValue(tab_contents));
386 std::string json_args; 393 std::string json_args;
387 base::JSONWriter::Write(&args, false, &json_args); 394 base::JSONWriter::Write(&args, false, &json_args);
388 395
389 std::string event_name = std::string("browserAction/") + extension_id; 396 std::string event_name = std::string("browserAction/") + extension_id;
390 DispatchEvent(profile, event_name.c_str(), json_args); 397 DispatchEvent(profile, event_name.c_str(), json_args);
391 } 398 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698