summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_browser_event_router.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-22 00:32:52 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-22 00:32:52 +0000
commit14d8c66e0f2ab42aa3a0bf4f626140ba3a3a6d76 (patch)
tree70ae56de0ae927fe89e6beee96bb41977c06b401 /chrome/browser/extensions/extension_browser_event_router.cc
parent2d3c4998438e0de2d1e159023a79834e3a74e9e6 (diff)
downloadchromium_src-14d8c66e0f2ab42aa3a0bf4f626140ba3a3a6d76.zip
chromium_src-14d8c66e0f2ab42aa3a0bf4f626140ba3a3a6d76.tar.gz
chromium_src-14d8c66e0f2ab42aa3a0bf4f626140ba3a3a6d76.tar.bz2
Add NotificationType::BROWSER_WINDOW_READY, chrome.windows.onCreated now sends full window
BUG=NONE Review URL: http://codereview.chromium.org/195030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_browser_event_router.cc')
-rw-r--r--chrome/browser/extensions/extension_browser_event_router.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc
index c1bce54..b20853e 100644
--- a/chrome/browser/extensions/extension_browser_event_router.cc
+++ b/chrome/browser/extensions/extension_browser_event_router.cc
@@ -121,13 +121,19 @@ void ExtensionBrowserEventRouter::OnBrowserAdded(const Browser* browser) {
// Start listening to TabStripModel events for this browser.
browser->tabstrip_model()->AddObserver(this);
+ // The window isn't ready at this point, so we defer until it is.
+ registrar_.Add(this, NotificationType::BROWSER_WINDOW_READY,
+ Source<const Browser>(browser));
+}
+
+void ExtensionBrowserEventRouter::OnBrowserWindowReady(const Browser* browser) {
ListValue args;
- // TODO(rafaelw): This would ideally be returning a full Window object
- // via ExtensionTabUtil::CreateWindowValue(), but the browser->window()
- // isn't ready at the time we get the OnBrowserAdded event.
- DictionaryValue* window_dictionary = new DictionaryValue();
- window_dictionary->SetInteger(extension_tabs_module_constants::kIdKey,
- ExtensionTabUtil::GetWindowId(browser));
+
+ registrar_.Remove(this, NotificationType::BROWSER_WINDOW_READY,
+ Source<const Browser>(browser));
+
+ DictionaryValue* window_dictionary = ExtensionTabUtil::CreateWindowValue(
+ browser, false);
args.Append(window_dictionary);
std::string json_args;
@@ -329,6 +335,9 @@ void ExtensionBrowserEventRouter::Observe(NotificationType type,
Source<NavigationController>(&contents->controller()));
registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED,
Source<TabContents>(contents));
+ } else if (type == NotificationType::BROWSER_WINDOW_READY) {
+ const Browser* browser = Source<const Browser>(source).ptr();
+ OnBrowserWindowReady(browser);
} else {
NOTREACHED();
}