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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_tab_id_map.h" 5 #include "chrome/browser/extensions/extension_tab_id_map.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/sessions/restore_tab_helper.h" 9 #include "chrome/browser/sessions/restore_tab_helper.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
11 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
12 #include "content/browser/tab_contents/tab_contents.h" 12 #include "content/browser/tab_contents/tab_contents.h"
13 #include "content/browser/renderer_host/render_view_host.h" 13 #include "content/browser/renderer_host/render_view_host.h"
14 #include "content/browser/renderer_host/render_process_host.h" 14 #include "content/browser/renderer_host/render_process_host.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/common/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
19 19
20 // 20 //
21 // ExtensionTabIdMap::TabObserver 21 // ExtensionTabIdMap::TabObserver
22 // 22 //
23 23
24 // This class listens for notifications about new and closed tabs on the UI 24 // This class listens for notifications about new and closed tabs on the UI
25 // thread, and notifies the ExtensionTabIdMap on the IO thread. It should only 25 // thread, and notifies the ExtensionTabIdMap on the IO thread. It should only
26 // ever be accessed on the UI thread. 26 // ever be accessed on the UI thread.
27 class ExtensionTabIdMap::TabObserver : public content::NotificationObserver { 27 class ExtensionTabIdMap::TabObserver : public content::NotificationObserver {
28 public: 28 public:
29 TabObserver(); 29 TabObserver();
30 ~TabObserver(); 30 ~TabObserver();
31 31
32 private: 32 private:
33 // content::NotificationObserver interface. 33 // content::NotificationObserver interface.
34 virtual void Observe(int type, 34 virtual void Observe(int type,
35 const content::NotificationSource& source, 35 const content::NotificationSource& source,
36 const content::NotificationDetails& details); 36 const content::NotificationDetails& details);
37 37
38 content::NotificationRegistrar registrar_; 38 content::NotificationRegistrar registrar_;
39 }; 39 };
40 40
41 ExtensionTabIdMap::TabObserver::TabObserver() { 41 ExtensionTabIdMap::TabObserver::TabObserver() {
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
43 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, 43 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
44 NotificationService::AllBrowserContextsAndSources()); 44 content::NotificationService::AllBrowserContextsAndSources());
45 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, 45 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
46 NotificationService::AllBrowserContextsAndSources()); 46 content::NotificationService::AllBrowserContextsAndSources());
47 registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, 47 registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED,
48 NotificationService::AllBrowserContextsAndSources()); 48 content::NotificationService::AllBrowserContextsAndSources());
49 } 49 }
50 50
51 ExtensionTabIdMap::TabObserver::~TabObserver() { 51 ExtensionTabIdMap::TabObserver::~TabObserver() {
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
53 } 53 }
54 54
55 void ExtensionTabIdMap::TabObserver::Observe( 55 void ExtensionTabIdMap::TabObserver::Observe(
56 int type, const content::NotificationSource& source, 56 int type, const content::NotificationSource& source,
57 const content::NotificationDetails& details) { 57 const content::NotificationDetails& details) {
58 switch (type) { 58 switch (type) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
148 RenderId render_id(render_process_host_id, routing_id); 148 RenderId render_id(render_process_host_id, routing_id);
149 TabAndWindowIdMap::iterator iter = map_.find(render_id); 149 TabAndWindowIdMap::iterator iter = map_.find(render_id);
150 if (iter != map_.end()) { 150 if (iter != map_.end()) {
151 *tab_id = iter->second.first; 151 *tab_id = iter->second.first;
152 *window_id = iter->second.second; 152 *window_id = iter->second.second;
153 return true; 153 return true;
154 } 154 }
155 return false; 155 return false;
156 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_helper.cc ('k') | chrome/browser/extensions/extension_tabs_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698