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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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/api/extension_action/extension_page_actions_ api_constants.h" 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
11 #include "chrome/browser/extensions/extension_event_names.h" 11 #include "chrome/browser/extensions/extension_event_names.h"
12 #include "chrome/browser/extensions/extension_event_router.h" 12 #include "chrome/browser/extensions/extension_event_router.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_tab_util.h" 14 #include "chrome/browser/extensions/extension_tab_util.h"
15 #include "chrome/browser/extensions/extension_window_controller.h" 15 #include "chrome/browser/extensions/extension_window_controller.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_tabstrip.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
22 #include "chrome/common/extensions/extension_constants.h" 23 #include "chrome/common/extensions/extension_constants.h"
23 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 27
27 #if defined(TOOLKIT_GTK) 28 #if defined(TOOLKIT_GTK)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Init() can happen after the browser is running, so catch up with any 91 // Init() can happen after the browser is running, so catch up with any
91 // windows that already exist. 92 // windows that already exist.
92 for (BrowserList::const_iterator iter = BrowserList::begin(); 93 for (BrowserList::const_iterator iter = BrowserList::begin();
93 iter != BrowserList::end(); ++iter) { 94 iter != BrowserList::end(); ++iter) {
94 RegisterForBrowserNotifications(*iter); 95 RegisterForBrowserNotifications(*iter);
95 96
96 // Also catch up our internal bookkeeping of tab entries. 97 // Also catch up our internal bookkeeping of tab entries.
97 Browser* browser = *iter; 98 Browser* browser = *iter;
98 if (browser->tab_strip_model()) { 99 if (browser->tab_strip_model()) {
99 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { 100 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) {
100 WebContents* contents = browser->GetTabContentsAt(i)->web_contents(); 101 WebContents* contents =
102 chrome::GetTabContentsAt(browser, i)->web_contents();
101 int tab_id = ExtensionTabUtil::GetTabId(contents); 103 int tab_id = ExtensionTabUtil::GetTabId(contents);
102 tab_entries_[tab_id] = TabEntry(); 104 tab_entries_[tab_id] = TabEntry();
103 } 105 }
104 } 106 }
105 } 107 }
106 108
107 initialized_ = true; 109 initialized_ = true;
108 } 110 }
109 111
110 ExtensionBrowserEventRouter::ExtensionBrowserEventRouter(Profile* profile) 112 ExtensionBrowserEventRouter::ExtensionBrowserEventRouter(Profile* profile)
(...skipping 25 matching lines...) Expand all
136 browser->tab_strip_model()->AddObserver(this); 138 browser->tab_strip_model()->AddObserver(this);
137 139
138 // If this is a new window, it isn't ready at this point, so we register to be 140 // If this is a new window, it isn't ready at this point, so we register to be
139 // notified when it is. If this is an existing window, this is a no-op that we 141 // notified when it is. If this is an existing window, this is a no-op that we
140 // just do to reduce code complexity. 142 // just do to reduce code complexity.
141 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, 143 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY,
142 content::Source<Browser>(browser)); 144 content::Source<Browser>(browser));
143 145
144 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { 146 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) {
145 RegisterForTabNotifications( 147 RegisterForTabNotifications(
146 browser->GetTabContentsAt(i)->web_contents()); 148 chrome::GetTabContentsAt(browser, i)->web_contents());
147 } 149 }
148 } 150 }
149 151
150 void ExtensionBrowserEventRouter::RegisterForTabNotifications( 152 void ExtensionBrowserEventRouter::RegisterForTabNotifications(
151 WebContents* contents) { 153 WebContents* contents) {
152 registrar_.Add( 154 registrar_.Add(
153 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 155 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
154 content::Source<NavigationController>(&contents->GetController())); 156 content::Source<NavigationController>(&contents->GetController()));
155 157
156 // Observing NOTIFICATION_WEB_CONTENTS_DESTROYED is necessary because it's 158 // Observing NOTIFICATION_WEB_CONTENTS_DESTROYED is necessary because it's
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 702 }
701 703
702 if (event_name) { 704 if (event_name) {
703 DispatchEventWithTab(profile, 705 DispatchEventWithTab(profile,
704 extension_action.extension_id(), 706 extension_action.extension_id(),
705 event_name, 707 event_name,
706 tab_contents->web_contents(), 708 tab_contents->web_contents(),
707 true); 709 true);
708 } 710 }
709 } 711 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/content_script_apitest.cc ('k') | chrome/browser/extensions/extension_context_menu_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698