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

Unified Diff: chrome/browser/extensions/extension_browser_event_router.cc

Issue 346006: New event style for pageAction API.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
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);
}
« no previous file with comments | « chrome/browser/extensions/extension_browser_event_router.h ('k') | chrome/browser/extensions/page_action_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698