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

Side by Side Diff: chrome/browser/ui/ash/window_manager_extension.cc

Issue 10824364: [NOT FOR REVIEW] ash: Add some implementation for the window management extension API. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/ash/window_manager_extension.h"
6
7 #include "base/json/json_writer.h"
8 #include "base/memory/ref_counted.h"
9 #include "chrome/browser/extensions/api/wm/wm_utils.h"
10 #include "chrome/browser/extensions/event_names.h"
11 #include "chrome/browser/extensions/event_router.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/extensions/api/experimental_wm.h"
15 #include "ui/aura/window.h"
16 #include "ui/gfx/native_widget_types.h"
17
18 namespace {
19
20 bool ShouldProcessWindow(const aura::Window* window) {
21 return (window->type() == aura::client::WINDOW_TYPE_NORMAL ||
22 window->type() == aura::client::WINDOW_TYPE_PANEL);
23 }
24
25 } // namespace
26
27 using namespace extensions;
28
29 WindowManagerExtension::WindowManagerExtension() {
30 }
31
32 WindowManagerExtension::~WindowManagerExtension() {
33 }
34
35 void WindowManagerExtension::DispatchEventForWindow(aura::Window* window,
36 const char event_name[]) {
37 extensions::api::experimental_wm::WmWindow extension_window;
38 extensions::api::wm::utils::NativeWindowToExtensionWindow(window,
39 &extension_window);
40 scoped_ptr<ListValue> args(new ListValue());
41 args->Append(extension_window.ToValue().release());
42
43 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
44 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
45 event_name,
46 args.Pass(),
47 NULL,
48 GURL());
49 }
50
51 void WindowManagerExtension::OnWindowCreated(aura::Window* window) {
52 if (!ShouldProcessWindow(window))
53 return;
54 DispatchEventForWindow(window, event_names::kWmOnWindowCreated);
55 }
56
57 void WindowManagerExtension::OnWindowClosed(aura::Window* window) {
58 if (!ShouldProcessWindow(window))
59 return;
60 DispatchEventForWindow(window, event_names::kWmOnWindowClosed);
61 extensions::api::wm::WindowIdTracker::GetInstance()->UntrackWindow(window);
62 }
63
64 void WindowManagerExtension::OnWindowHidden(aura::Window* window) {
65 if (!ShouldProcessWindow(window))
66 return;
67 DispatchEventForWindow(window, event_names::kWmOnWindowHidden);
68 }
69
70 void WindowManagerExtension::OnWindowShown(aura::Window* window) {
71 if (!ShouldProcessWindow(window))
72 return;
73 DispatchEventForWindow(window, event_names::kWmOnWindowShown);
74 }
75
76 void WindowManagerExtension::OnActiveWindowChanged(aura::Window* window) {
77 if (window && !ShouldProcessWindow(window))
78 return;
79 DispatchEventForWindow(window,
80 event_names::kWmOnActiveWindowChanged);
81 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/window_manager_extension.h ('k') | chrome/browser/ui/views/ash/chrome_shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698