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

Unified Diff: chrome/browser/extensions/extension_panel_event_router.h

Issue 10777004: Support chrome.windows extension API events for browserless Panels. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_panel_event_router.h
diff --git a/chrome/browser/extensions/extension_panel_event_router.h b/chrome/browser/extensions/extension_panel_event_router.h
new file mode 100644
index 0000000000000000000000000000000000000000..6bd8962dff1b37c2f6dd2edec6131bbe4d57ae5e
--- /dev/null
+++ b/chrome/browser/extensions/extension_panel_event_router.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PANEL_EVENT_ROUTER_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PANEL_EVENT_ROUTER_H_
+
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Panel;
+class Profile;
+
+// The ExtensinoPanelEventRouter listens to Panel window events
+// and routes them to listeners inside extension process renderers.
+class ExtensionPanelEventRouter : public content::NotificationObserver {
+ public:
+ explicit ExtensionPanelEventRouter(Profile* profile);
+ virtual ~ExtensionPanelEventRouter();
+
+ // Must be called once. Subsequent calls have no effect.
+ void Init();
+
+ // content::NotificationObserver.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+ private:
+ void OnPanelOpened(Panel* panel);
+ void OnPanelActiveStatusChanged(Panel* panel, bool is_active_now);
+ void OnPanelClosed(Panel* panel);
+
+ content::NotificationRegistrar registrar_;
+
+ bool initialized_;
+
+ // The main profile that owns this event router.
+ Profile* profile_;
+
+ // The profile the currently focused panel belongs to; either the main or
+ // incognito profile or NULL (none of the above). We remember this in order
+ // to correctly handle focus changes between non-OTR and OTR panels.
+ Profile* focused_profile_;
+
+ // The currently focused panel. We keep this so as to avoid sending multiple
+ // windows.onFocusChanged events with the same windowId.
+ int focused_window_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionPanelEventRouter);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PANEL_EVENT_ROUTER_H_

Powered by Google App Engine
This is Rietveld 408576698