| OLD | NEW |
| 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_writer.h" | 7 #include "base/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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 322 |
| 323 void ExtensionBrowserEventRouter::TabChangedAt(TabContents* contents, | 323 void ExtensionBrowserEventRouter::TabChangedAt(TabContents* contents, |
| 324 int index, | 324 int index, |
| 325 bool loading_only) { | 325 bool loading_only) { |
| 326 TabUpdated(contents, false); | 326 TabUpdated(contents, false); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void ExtensionBrowserEventRouter::TabStripEmpty() { } | 329 void ExtensionBrowserEventRouter::TabStripEmpty() { } |
| 330 | 330 |
| 331 void ExtensionBrowserEventRouter::PageActionExecuted(Profile* profile, | 331 void ExtensionBrowserEventRouter::PageActionExecuted(Profile* profile, |
| 332 std::string extension_id, |
| 332 std::string page_action_id, | 333 std::string page_action_id, |
| 333 int tab_id, | 334 int tab_id, |
| 334 std::string url) { | 335 std::string url) { |
| 335 ListValue args; | 336 ListValue args; |
| 336 DictionaryValue* object_args = new DictionaryValue(); | 337 DictionaryValue* object_args = new DictionaryValue(); |
| 337 object_args->Set(tab_keys::kPageActionIdKey, | 338 object_args->Set(tab_keys::kPageActionIdKey, |
| 338 Value::CreateStringValue(page_action_id)); | 339 Value::CreateStringValue(page_action_id)); |
| 339 DictionaryValue* data = new DictionaryValue(); | 340 DictionaryValue* data = new DictionaryValue(); |
| 340 data->Set(tab_keys::kTabIdKey, Value::CreateIntegerValue(tab_id)); | 341 data->Set(tab_keys::kTabIdKey, Value::CreateIntegerValue(tab_id)); |
| 341 data->Set(tab_keys::kTabUrlKey, Value::CreateStringValue(url)); | 342 data->Set(tab_keys::kTabUrlKey, Value::CreateStringValue(url)); |
| 342 object_args->Set(tab_keys::kDataKey, data); | 343 object_args->Set(tab_keys::kDataKey, data); |
| 343 | 344 |
| 344 args.Append(object_args); | 345 args.Append(object_args); |
| 345 | 346 |
| 346 std::string json_args; | 347 std::string json_args; |
| 347 JSONWriter::Write(&args, false, &json_args); | 348 JSONWriter::Write(&args, false, &json_args); |
| 348 | 349 |
| 349 DispatchEvent(profile, events::kOnPageActionExecuted, json_args); | 350 std::string event_name = extension_id + std::string("/") + page_action_id; |
| 351 DispatchEvent(profile, event_name.c_str(), json_args); |
| 350 } | 352 } |
| OLD | NEW |