Fix build break
[chromium-blink-merge.git] / ui / aura / remote_root_window_host_win.h
blobeb094b0bfae7601719a622edb5f90cc96223753f
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.
5 #ifndef UI_AURA_REMOTE_ROOT_WINDOW_HOST_WIN_H_
6 #define UI_AURA_REMOTE_ROOT_WINDOW_HOST_WIN_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "base/string16.h"
13 #include "ui/aura/root_window_host.h"
14 #include "ui/base/events/event_constants.h"
15 #include "ui/gfx/native_widget_types.h"
17 namespace base {
18 class FilePath;
21 namespace ui {
22 class ViewProp;
25 namespace IPC {
26 class Message;
27 class Sender;
30 namespace aura {
32 typedef base::Callback<void(const base::FilePath&, int, void*)>
33 OpenFileCompletion;
35 typedef base::Callback<void(const std::vector<base::FilePath>&, void*)>
36 OpenMultipleFilesCompletion;
38 typedef base::Callback<void(const base::FilePath&, int, void*)>
39 SaveFileCompletion;
41 // Handles the open file operation for Metro Chrome Ash. The callback passed in
42 // is invoked when we receive the opened file name from the metro viewer.
43 AURA_EXPORT void HandleOpenFile(
44 const string16& title,
45 const base::FilePath& default_path,
46 const string16& filter,
47 const OpenFileCompletion& callback);
49 // Handles the open multiple file operation for Metro Chrome Ash. The callback
50 // passed in is invoked when we receive the opened file names from the metro
51 // viewer.
52 AURA_EXPORT void HandleOpenMultipleFiles(
53 const string16& title,
54 const base::FilePath& default_path,
55 const string16& filter,
56 const OpenMultipleFilesCompletion& callback);
58 // Handles the save file operation for Metro Chrome Ash. The callback passed in
59 // is invoked when we receive the saved file name from the metro viewer.
60 AURA_EXPORT void HandleSaveFile(
61 const string16& title,
62 const base::FilePath& default_path,
63 const string16& filter,
64 int filter_index,
65 const string16& default_extension,
66 const SaveFileCompletion& callback);
69 // RootWindowHost implementaton that receives events from a different
70 // process. In the case of Windows this is the Windows 8 (aka Metro)
71 // frontend process, which forwards input events to this class.
72 class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
73 public:
74 static RemoteRootWindowHostWin* Instance();
75 static RemoteRootWindowHostWin* Create(const gfx::Rect& bounds);
77 // Called when the remote process has established its IPC connection.
78 // The |host| can be used when we need to send a message to it.
79 void Connected(IPC::Sender* host);
80 // Called when the remote process has closed its IPC connection.
81 void Disconnected();
83 // Called when we have a message from the remote process.
84 bool OnMessageReceived(const IPC::Message& message);
86 void HandleOpenFile(
87 const string16& title,
88 const base::FilePath& default_path,
89 const string16& filter,
90 const OpenFileCompletion& callback);
92 void HandleOpenMultipleFiles(
93 const string16& title,
94 const base::FilePath& default_path,
95 const string16& filter,
96 const OpenMultipleFilesCompletion& callback);
98 void HandleSaveFile(
99 const string16& title,
100 const base::FilePath& default_path,
101 const string16& filter,
102 int filter_index,
103 const string16& default_extension,
104 const SaveFileCompletion& callback);
106 private:
107 explicit RemoteRootWindowHostWin(const gfx::Rect& bounds);
108 virtual ~RemoteRootWindowHostWin();
110 // IPC message handing methods:
111 void OnMouseMoved(int32 x, int32 y, int32 flags);
112 void OnMouseButton(int32 x,
113 int32 y,
114 int32 extra,
115 ui::EventType type,
116 ui::EventFlags flags);
117 void OnKeyDown(uint32 vkey,
118 uint32 repeat_count,
119 uint32 scan_code,
120 uint32 flags);
121 void OnKeyUp(uint32 vkey,
122 uint32 repeat_count,
123 uint32 scan_code,
124 uint32 flags);
125 void OnChar(uint32 key_code,
126 uint32 repeat_count,
127 uint32 scan_code,
128 uint32 flags);
129 void OnVisibilityChanged(bool visible);
130 void OnTouchDown(int32 x, int32 y, uint64 timestamp, uint32 pointer_id);
131 void OnTouchUp(int32 x, int32 y, uint64 timestamp, uint32 pointer_id);
132 void OnTouchMoved(int32 x, int32 y, uint64 timestamp, uint32 pointer_id);
133 void OnFileSaveAsDone(bool success,
134 string16 filename,
135 int filter_index);
136 void OnFileOpenDone(bool success, string16 filename);
137 void OnMultiFileOpenDone(bool success,
138 const std::vector<base::FilePath>& files);
140 // RootWindowHost overrides:
141 virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE;
142 virtual RootWindow* GetRootWindow() OVERRIDE;
143 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
144 virtual void Show() OVERRIDE;
145 virtual void Hide() OVERRIDE;
146 virtual void ToggleFullScreen() OVERRIDE;
147 virtual gfx::Rect GetBounds() const OVERRIDE;
148 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
149 virtual gfx::Insets GetInsets() const OVERRIDE;
150 virtual void SetInsets(const gfx::Insets& insets) OVERRIDE;
151 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
152 virtual void SetCapture() OVERRIDE;
153 virtual void ReleaseCapture() OVERRIDE;
154 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
155 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
156 virtual bool ConfineCursorToRootWindow() OVERRIDE;
157 virtual void UnConfineCursor() OVERRIDE;
158 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE;
159 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
160 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
161 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
162 const gfx::Point& dest_offset,
163 SkCanvas* canvas) OVERRIDE;
164 virtual bool GrabSnapshot(
165 const gfx::Rect& snapshot_bounds,
166 std::vector<unsigned char>* png_representation) OVERRIDE;
167 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
168 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
169 virtual void PrepareForShutdown() OVERRIDE;
171 // Helper function to dispatch a keyboard message to the desired target.
172 // The default target is the RootWindowHostDelegate. For nested message loop
173 // invocations we post a synthetic keyboard message directly into the message
174 // loop. The dispatcher for the nested loop would then decide how this
175 // message is routed.
176 void DispatchKeyboardMessage(ui::EventType type,
177 uint32 vkey,
178 uint32 repeat_count,
179 uint32 scan_code,
180 uint32 flags,
181 bool is_character);
183 RootWindowHostDelegate* delegate_;
184 IPC::Sender* host_;
185 scoped_ptr<ui::ViewProp> prop_;
187 // Saved callbacks which inform the caller about the result of the open file/
188 // save file operations.
189 OpenFileCompletion file_open_completion_callback_;
190 OpenMultipleFilesCompletion multi_file_open_completion_callback_;
191 SaveFileCompletion file_saveas_completion_callback_;
193 DISALLOW_COPY_AND_ASSIGN(RemoteRootWindowHostWin);
196 } // namespace aura
198 #endif // UI_AURA_REMOTE_ROOT_WINDOW_HOST_WIN_H_