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

Side by Side Diff: chrome/browser/extensions/extension_browser_event_router.cc

Issue 9428018: Create BaseWindow and ExtensionWindowWrapper for extension API access to Panels (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments. Created 8 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_event_names.h" 9 #include "chrome/browser/extensions/extension_event_names.h"
10 #include "chrome/browser/extensions/extension_event_router.h" 10 #include "chrome/browser/extensions/extension_event_router.h"
11 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" 11 #include "chrome/browser/extensions/extension_page_actions_module_constants.h"
12 #include "chrome/browser/extensions/extension_tab_util.h" 12 #include "chrome/browser/extensions/extension_tab_util.h"
13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" 13 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
14 #include "chrome/browser/extensions/extension_window_controller.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/tabs/tab_strip_model.h" 16 #include "chrome/browser/tabs/tab_strip_model.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_constants.h" 21 #include "chrome/common/extensions/extension_constants.h"
21 #include "content/public/browser/navigation_controller.h" 22 #include "content/public/browser/navigation_controller.h"
22 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 WebContents* contents) { 165 WebContents* contents) {
165 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 166 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
166 content::Source<NavigationController>(&contents->GetController())); 167 content::Source<NavigationController>(&contents->GetController()));
167 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 168 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
168 content::Source<WebContents>(contents)); 169 content::Source<WebContents>(contents));
169 } 170 }
170 171
171 void ExtensionBrowserEventRouter::OnBrowserWindowReady(const Browser* browser) { 172 void ExtensionBrowserEventRouter::OnBrowserWindowReady(const Browser* browser) {
172 ListValue args; 173 ListValue args;
173 174
174 DictionaryValue* window_dictionary = ExtensionTabUtil::CreateWindowValue( 175 DCHECK(browser->extension_window_controller());
175 browser, false); 176 DictionaryValue* window_dictionary =
177 browser->extension_window_controller()->CreateWindowValue();
176 args.Append(window_dictionary); 178 args.Append(window_dictionary);
177 179
178 std::string json_args; 180 std::string json_args;
179 base::JSONWriter::Write(&args, false, &json_args); 181 base::JSONWriter::Write(&args, false, &json_args);
180 182
181 DispatchEvent(browser->profile(), events::kOnWindowCreated, json_args); 183 DispatchEvent(browser->profile(), events::kOnWindowCreated, json_args);
182 } 184 }
183 185
184 void ExtensionBrowserEventRouter::OnBrowserRemoved(const Browser* browser) { 186 void ExtensionBrowserEventRouter::OnBrowserRemoved(const Browser* browser) {
185 if (!profile_->IsSameProfile(browser->profile())) 187 if (!profile_->IsSameProfile(browser->profile()))
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 648
647 void ExtensionBrowserEventRouter::BrowserActionExecuted( 649 void ExtensionBrowserEventRouter::BrowserActionExecuted(
648 Profile* profile, const std::string& extension_id, Browser* browser) { 650 Profile* profile, const std::string& extension_id, Browser* browser) {
649 TabContentsWrapper* tab_contents = NULL; 651 TabContentsWrapper* tab_contents = NULL;
650 int tab_id = 0; 652 int tab_id = 0;
651 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) 653 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id))
652 return; 654 return;
653 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", 655 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked",
654 tab_contents->web_contents(), true); 656 tab_contents->web_contents(), true);
655 } 657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698