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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 363 |
364 DictionaryValue* data = new DictionaryValue(); | 364 DictionaryValue* data = new DictionaryValue(); |
365 data->Set(tab_keys::kTabIdKey, Value::CreateIntegerValue(tab_id)); | 365 data->Set(tab_keys::kTabIdKey, Value::CreateIntegerValue(tab_id)); |
366 data->Set(tab_keys::kTabUrlKey, Value::CreateStringValue(url)); | 366 data->Set(tab_keys::kTabUrlKey, Value::CreateStringValue(url)); |
367 data->Set(page_action_keys::kButtonKey, Value::CreateIntegerValue(button)); | 367 data->Set(page_action_keys::kButtonKey, Value::CreateIntegerValue(button)); |
368 args.Append(data); | 368 args.Append(data); |
369 | 369 |
370 std::string json_args; | 370 std::string json_args; |
371 JSONWriter::Write(&args, false, &json_args); | 371 JSONWriter::Write(&args, false, &json_args); |
372 | 372 |
373 std::string event_name = extension_id + std::string("/") + page_action_id; | 373 std::string event_name = std::string("pageAction/") + extension_id; |
374 DispatchEvent(profile, event_name.c_str(), json_args); | 374 DispatchEvent(profile, event_name.c_str(), json_args); |
375 } | 375 } |
376 | 376 |
377 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 377 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
378 Profile* profile, const std::string& extension_id, int window_id) { | 378 Profile* profile, const std::string& extension_id, int window_id) { |
379 ListValue args; | 379 ListValue args; |
380 args.Append(Value::CreateIntegerValue(window_id)); | 380 args.Append(Value::CreateIntegerValue(window_id)); |
381 | 381 |
382 std::string json_args; | 382 std::string json_args; |
383 JSONWriter::Write(&args, false, &json_args); | 383 JSONWriter::Write(&args, false, &json_args); |
384 | 384 |
385 std::string event_name = std::string("browserAction/") + extension_id; | 385 std::string event_name = std::string("browserAction/") + extension_id; |
386 DispatchEvent(profile, event_name.c_str(), json_args); | 386 DispatchEvent(profile, event_name.c_str(), json_args); |
387 } | 387 } |
OLD | NEW |