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

Unified Diff: chrome/browser/ui/views/ash/window_manager_extension.cc

Issue 10803037: [WIP] ash/extensions: Add experimental extension support for window-management in ash. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge-152100 Created 8 years, 4 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
« no previous file with comments | « chrome/browser/ui/views/ash/window_manager_extension.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/ash/window_manager_extension.cc
diff --git a/chrome/browser/ui/views/ash/window_manager_extension.cc b/chrome/browser/ui/views/ash/window_manager_extension.cc
new file mode 100644
index 0000000000000000000000000000000000000000..12c03c0c65f96e06f6280591182ce7a6cdd2cff7
--- /dev/null
+++ b/chrome/browser/ui/views/ash/window_manager_extension.cc
@@ -0,0 +1,82 @@
+// 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.
+
+#include "chrome/browser/ui/views/ash/window_manager_extension.h"
+
+#include "base/json/json_writer.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/extensions/api/wm/wm_utils.h"
+#include "chrome/browser/extensions/event_names.h"
+#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/extensions/api/experimental_wm.h"
+#include "ui/aura/window.h"
+
+namespace {
+
+bool ShouldProcessWindow(const aura::Window* window) {
+ return (window->type() == aura::client::WINDOW_TYPE_NORMAL ||
+ window->type() == aura::client::WINDOW_TYPE_PANEL);
+}
+
+} // namespace
+
+using namespace extensions;
+
+WindowManagerExtension::WindowManagerExtension() {
+}
+
+WindowManagerExtension::~WindowManagerExtension() {
+}
+
+void WindowManagerExtension::DispatchEventForWindow(const aura::Window* window,
+ const char event_name[]) {
+ extensions::api::experimental_wm::AshWindow extension_window;
+ extensions::api::wm::utils::AuraWindowToExtensionWindow(window,
+ &extension_window);
+ scoped_ptr<ListValue> args(new ListValue());
+ args->Append(extension_window.ToValue().release());
+
+ Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
+ profile->GetExtensionEventRouter()->DispatchEventToRenderers(
+ event_name,
+ args.Pass(),
+ NULL,
+ GURL());
+}
+
+void WindowManagerExtension::OnWindowCreated(const aura::Window* window) {
+ if (!ShouldProcessWindow(window))
+ return;
+ extensions::api::wm::WindowIdTracker::GetInstance()->TrackWindow(window);
+ DispatchEventForWindow(window, event_names::kAshWmOnWindowCreated);
+}
+
+void WindowManagerExtension::OnWindowClosed(const aura::Window* window) {
+ if (!ShouldProcessWindow(window))
+ return;
+ DispatchEventForWindow(window, event_names::kAshWmOnWindowClosed);
+ extensions::api::wm::WindowIdTracker::GetInstance()->UntrackWindow(window);
+}
+
+void WindowManagerExtension::OnWindowHidden(const aura::Window* window) {
+ if (!ShouldProcessWindow(window))
+ return;
+ DispatchEventForWindow(window, event_names::kAshWmOnWindowHidden);
+}
+
+void WindowManagerExtension::OnWindowShown(const aura::Window* window) {
+ if (!ShouldProcessWindow(window))
+ return;
+ DispatchEventForWindow(window, event_names::kAshWmOnWindowShown);
+}
+
+void WindowManagerExtension::OnActiveWindowChanged(const aura::Window* window) {
+ if (window && !ShouldProcessWindow(window))
+ return;
+ extensions::api::wm::WindowIdTracker::GetInstance()->ActivateWindow(window);
+ DispatchEventForWindow(window,
+ event_names::kAshWmOnActiveWindowChanged);
+}
« no previous file with comments | « chrome/browser/ui/views/ash/window_manager_extension.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698