Index: chrome/browser/extensions/extension_browser_event_router.cc |
=================================================================== |
--- chrome/browser/extensions/extension_browser_event_router.cc (revision 30461) |
+++ chrome/browser/extensions/extension_browser_event_router.cc (working copy) |
@@ -93,6 +93,16 @@ |
} |
} |
+static void DispatchEventWithTab(Profile* profile, |
+ const char* event_name, |
+ const TabContents* tab_contents) { |
+ ListValue args; |
+ args.Append(ExtensionTabUtil::CreateTabValue(tab_contents)); |
+ std::string json_args; |
+ base::JSONWriter::Write(&args, false, &json_args); |
+ DispatchEvent(profile, event_name, json_args); |
+} |
+ |
static void DispatchSimpleBrowserEvent(Profile* profile, |
const int window_id, |
const char* event_name) { |
@@ -204,13 +214,8 @@ |
void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents, |
int index, |
bool foreground) { |
- ListValue args; |
- args.Append(ExtensionTabUtil::CreateTabValue(contents)); |
- std::string json_args; |
- base::JSONWriter::Write(&args, false, &json_args); |
+ DispatchEventWithTab(contents->profile(), events::kOnTabCreated, contents); |
- DispatchEvent(contents->profile(), events::kOnTabCreated, json_args); |
- |
RegisterForTabNotifications(contents); |
} |
@@ -393,7 +398,7 @@ |
void ExtensionBrowserEventRouter::TabStripEmpty() { } |
-void ExtensionBrowserEventRouter::PageActionExecuted( |
+void ExtensionBrowserEventRouter::DispatchOldPageActionEvent( |
Profile* profile, |
const std::string& extension_id, |
const std::string& page_action_id, |
@@ -412,22 +417,34 @@ |
std::string json_args; |
base::JSONWriter::Write(&args, false, &json_args); |
- std::string event_name = std::string("pageAction/") + extension_id; |
+ std::string event_name = std::string("pageActions/") + extension_id; |
DispatchEvent(profile, event_name.c_str(), json_args); |
} |
+void ExtensionBrowserEventRouter::PageActionExecuted( |
+ Profile* profile, |
+ const std::string& extension_id, |
+ const std::string& page_action_id, |
+ int tab_id, |
+ const std::string& url, |
+ int button) { |
+ DispatchOldPageActionEvent(profile, extension_id, page_action_id, tab_id, url, |
+ button); |
+ TabContents* tab_contents = NULL; |
+ if (!ExtensionTabUtil::GetTabById(tab_id, profile, NULL, NULL, &tab_contents, |
+ NULL)) { |
+ return; |
+ } |
+ std::string event_name = std::string("pageAction/") + extension_id; |
+ DispatchEventWithTab(profile, event_name.c_str(), tab_contents); |
+} |
+ |
void ExtensionBrowserEventRouter::BrowserActionExecuted( |
Profile* profile, const std::string& extension_id, Browser* browser) { |
TabContents* tab_contents = NULL; |
int tab_id = 0; |
if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
return; |
- |
- ListValue args; |
- args.Append(ExtensionTabUtil::CreateTabValue(tab_contents)); |
- std::string json_args; |
- base::JSONWriter::Write(&args, false, &json_args); |
- |
std::string event_name = std::string("browserAction/") + extension_id; |
- DispatchEvent(profile, event_name.c_str(), json_args); |
+ DispatchEventWithTab(profile, event_name.c_str(), tab_contents); |
} |