| Index: chrome/browser/ui/ash/window_manager_extension.cc
|
| diff --git a/chrome/browser/ui/ash/window_manager_extension.cc b/chrome/browser/ui/ash/window_manager_extension.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8698f17682c8eb57d25e04e85042dc7ac123641c
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/ash/window_manager_extension.cc
|
| @@ -0,0 +1,81 @@
|
| +// 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/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"
|
| +#include "ui/gfx/native_widget_types.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(aura::Window* window,
|
| + const char event_name[]) {
|
| + extensions::api::experimental_wm::WmWindow extension_window;
|
| + extensions::api::wm::utils::NativeWindowToExtensionWindow(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(aura::Window* window) {
|
| + if (!ShouldProcessWindow(window))
|
| + return;
|
| + DispatchEventForWindow(window, event_names::kWmOnWindowCreated);
|
| +}
|
| +
|
| +void WindowManagerExtension::OnWindowClosed(aura::Window* window) {
|
| + if (!ShouldProcessWindow(window))
|
| + return;
|
| + DispatchEventForWindow(window, event_names::kWmOnWindowClosed);
|
| + extensions::api::wm::WindowIdTracker::GetInstance()->UntrackWindow(window);
|
| +}
|
| +
|
| +void WindowManagerExtension::OnWindowHidden(aura::Window* window) {
|
| + if (!ShouldProcessWindow(window))
|
| + return;
|
| + DispatchEventForWindow(window, event_names::kWmOnWindowHidden);
|
| +}
|
| +
|
| +void WindowManagerExtension::OnWindowShown(aura::Window* window) {
|
| + if (!ShouldProcessWindow(window))
|
| + return;
|
| + DispatchEventForWindow(window, event_names::kWmOnWindowShown);
|
| +}
|
| +
|
| +void WindowManagerExtension::OnActiveWindowChanged(aura::Window* window) {
|
| + if (window && !ShouldProcessWindow(window))
|
| + return;
|
| + DispatchEventForWindow(window,
|
| + event_names::kWmOnActiveWindowChanged);
|
| +}
|
|
|