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

Side by Side Diff: chrome/browser/extensions/window_event_router.h

Issue 11366074: Coalesce event router Init calls into their constructors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: aa Created 8 years, 1 month 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 #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/extensions/window_controller_list_observer.h" 10 #include "chrome/browser/extensions/window_controller_list_observer.h"
(...skipping 21 matching lines...) Expand all
32 #if defined(TOOLKIT_VIEWS) 32 #if defined(TOOLKIT_VIEWS)
33 public views::WidgetFocusChangeListener, 33 public views::WidgetFocusChangeListener,
34 #elif defined(TOOLKIT_GTK) 34 #elif defined(TOOLKIT_GTK)
35 public ui::ActiveWindowWatcherXObserver, 35 public ui::ActiveWindowWatcherXObserver,
36 #endif 36 #endif
37 public content::NotificationObserver { 37 public content::NotificationObserver {
38 public: 38 public:
39 explicit WindowEventRouter(Profile* profile); 39 explicit WindowEventRouter(Profile* profile);
40 virtual ~WindowEventRouter(); 40 virtual ~WindowEventRouter();
41 41
42 // Must be called once. Subsequent calls have no effect.
43 void Init();
44
45 // WindowControllerListObserver methods: 42 // WindowControllerListObserver methods:
46 virtual void OnWindowControllerAdded( 43 virtual void OnWindowControllerAdded(
47 WindowController* window_controller) OVERRIDE; 44 WindowController* window_controller) OVERRIDE;
48 virtual void OnWindowControllerRemoved( 45 virtual void OnWindowControllerRemoved(
49 WindowController* window) OVERRIDE; 46 WindowController* window) OVERRIDE;
50 47
51 #if defined(TOOLKIT_VIEWS) 48 #if defined(TOOLKIT_VIEWS)
52 virtual void OnNativeFocusChange(gfx::NativeView focused_before, 49 virtual void OnNativeFocusChange(gfx::NativeView focused_before,
53 gfx::NativeView focused_now) OVERRIDE; 50 gfx::NativeView focused_now) OVERRIDE;
54 #elif defined(TOOLKIT_GTK) 51 #elif defined(TOOLKIT_GTK)
55 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; 52 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
56 #endif 53 #endif
57 54
58 // content::NotificationObserver. 55 // content::NotificationObserver.
59 virtual void Observe(int type, 56 virtual void Observe(int type,
60 const content::NotificationSource& source, 57 const content::NotificationSource& source,
61 const content::NotificationDetails& details) OVERRIDE; 58 const content::NotificationDetails& details) OVERRIDE;
62 59
63 // |window_controller| is NULL to indicate a focused window has lost focus. 60 // |window_controller| is NULL to indicate a focused window has lost focus.
64 void OnActiveWindowChanged(WindowController* window_controller); 61 void OnActiveWindowChanged(WindowController* window_controller);
65 62
66 private: 63 private:
67 void DispatchEvent(const char* event_name, 64 void DispatchEvent(const char* event_name,
68 Profile* profile, 65 Profile* profile,
69 scoped_ptr<base::ListValue> args); 66 scoped_ptr<base::ListValue> args);
70 67
71 content::NotificationRegistrar registrar_; 68 content::NotificationRegistrar registrar_;
72 bool initialized_;
73 69
74 // The main profile that owns this event router. 70 // The main profile that owns this event router.
75 Profile* profile_; 71 Profile* profile_;
76 72
77 // The profile the currently focused window belongs to; either the main or 73 // The profile the currently focused window belongs to; either the main or
78 // incognito profile or NULL (none of the above). We remember this in order 74 // incognito profile or NULL (none of the above). We remember this in order
79 // to correctly handle focus changes between non-OTR and OTR windows. 75 // to correctly handle focus changes between non-OTR and OTR windows.
80 Profile* focused_profile_; 76 Profile* focused_profile_;
81 77
82 // The currently focused window. We keep this so as to avoid sending multiple 78 // The currently focused window. We keep this so as to avoid sending multiple
83 // windows.onFocusChanged events with the same windowId. 79 // windows.onFocusChanged events with the same windowId.
84 int focused_window_id_; 80 int focused_window_id_;
85 81
86 DISALLOW_COPY_AND_ASSIGN(WindowEventRouter); 82 DISALLOW_COPY_AND_ASSIGN(WindowEventRouter);
87 }; 83 };
88 84
89 } // namespace extensions 85 } // namespace extensions
90 86
91 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_ 87 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_EVENT_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/window_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698