Move most of TestNaClBrowserDelegate to another file.
[chromium-blink-merge.git] / win8 / metro_driver / chrome_app_view_ash.h
blobb301b3afc5cab4ad1eeff96a19fc4ba1271a13cd
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 WIN8_METRO_DRIVER_CHROME_APP_VIEW_ASH_H_
6 #define WIN8_METRO_DRIVER_CHROME_APP_VIEW_ASH_H_
8 #include <windows.applicationmodel.core.h>
9 #include <windows.ui.core.h>
10 #include <windows.ui.input.h>
11 #include <windows.ui.viewmanagement.h>
13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h"
15 #include "base/strings/string16.h"
16 #include "ui/events/event_constants.h"
17 #include "win8/metro_driver/direct3d_helper.h"
19 namespace base {
20 class FilePath;
23 namespace IPC {
24 class Listener;
25 class ChannelProxy;
28 class OpenFilePickerSession;
29 class SaveFilePickerSession;
30 class FolderPickerSession;
31 class FilePickerSessionBase;
33 struct MetroViewerHostMsg_SaveAsDialogParams;
35 class ChromeAppViewAsh
36 : public mswr::RuntimeClass<winapp::Core::IFrameworkView> {
37 public:
38 ChromeAppViewAsh();
39 ~ChromeAppViewAsh();
41 // IViewProvider overrides.
42 IFACEMETHOD(Initialize)(winapp::Core::ICoreApplicationView* view);
43 IFACEMETHOD(SetWindow)(winui::Core::ICoreWindow* window);
44 IFACEMETHOD(Load)(HSTRING entryPoint);
45 IFACEMETHOD(Run)();
46 IFACEMETHOD(Uninitialize)();
48 // Helper function to unsnap the chrome metro app if it is snapped.
49 // Returns S_OK on success.
50 static HRESULT Unsnap();
52 void OnActivateDesktop(const base::FilePath& file_path);
53 void OnOpenURLOnDesktop(const base::FilePath& shortcut, const string16& url);
54 void OnSetCursor(HCURSOR cursor);
55 void OnDisplayFileOpenDialog(const string16& title,
56 const string16& filter,
57 const base::FilePath& default_path,
58 bool allow_multiple_files);
59 void OnDisplayFileSaveAsDialog(
60 const MetroViewerHostMsg_SaveAsDialogParams& params);
61 void OnDisplayFolderPicker(const string16& title);
62 void OnSetCursorPos(int x, int y);
64 // This function is invoked when the open file operation completes. The
65 // result of the operation is passed in along with the OpenFilePickerSession
66 // instance which is deleted after we read the required information from
67 // the OpenFilePickerSession class.
68 void OnOpenFileCompleted(OpenFilePickerSession* open_file_picker,
69 bool success);
71 // This function is invoked when the save file operation completes. The
72 // result of the operation is passed in along with the SaveFilePickerSession
73 // instance which is deleted after we read the required information from
74 // the SaveFilePickerSession class.
75 void OnSaveFileCompleted(SaveFilePickerSession* save_file_picker,
76 bool success);
78 // This function is invoked when the folder picker operation completes. The
79 // result of the operation is passed in along with the FolderPickerSession
80 // instance which is deleted after we read the required information from
81 // the FolderPickerSession class.
82 void OnFolderPickerCompleted(FolderPickerSession* folder_picker,
83 bool success);
85 private:
86 HRESULT OnActivate(winapp::Core::ICoreApplicationView* view,
87 winapp::Activation::IActivatedEventArgs* args);
89 HRESULT OnPointerMoved(winui::Core::ICoreWindow* sender,
90 winui::Core::IPointerEventArgs* args);
92 HRESULT OnPointerPressed(winui::Core::ICoreWindow* sender,
93 winui::Core::IPointerEventArgs* args);
95 HRESULT OnPointerReleased(winui::Core::ICoreWindow* sender,
96 winui::Core::IPointerEventArgs* args);
98 HRESULT OnWheel(winui::Core::ICoreWindow* sender,
99 winui::Core::IPointerEventArgs* args);
101 HRESULT OnKeyDown(winui::Core::ICoreWindow* sender,
102 winui::Core::IKeyEventArgs* args);
104 HRESULT OnKeyUp(winui::Core::ICoreWindow* sender,
105 winui::Core::IKeyEventArgs* args);
107 // Invoked for system keys like Alt, etc.
108 HRESULT OnAcceleratorKeyDown(winui::Core::ICoreDispatcher* sender,
109 winui::Core::IAcceleratorKeyEventArgs* args);
111 HRESULT OnCharacterReceived(winui::Core::ICoreWindow* sender,
112 winui::Core::ICharacterReceivedEventArgs* args);
114 HRESULT OnWindowActivated(winui::Core::ICoreWindow* sender,
115 winui::Core::IWindowActivatedEventArgs* args);
117 // Helper to handle search requests received via the search charm in ASH.
118 HRESULT HandleSearchRequest(winapp::Activation::IActivatedEventArgs* args);
119 // Helper to handle http/https url requests in ASH.
120 HRESULT HandleProtocolRequest(winapp::Activation::IActivatedEventArgs* args);
122 // Tasks posted to the UI thread to initiate the search/url navigation
123 // requests.
124 void OnSearchRequest(const string16& search_string);
125 void OnNavigateToUrl(const string16& url);
127 HRESULT OnSizeChanged(winui::Core::ICoreWindow* sender,
128 winui::Core::IWindowSizeChangedEventArgs* args);
130 mswr::ComPtr<winui::Core::ICoreWindow> window_;
131 mswr::ComPtr<winapp::Core::ICoreApplicationView> view_;
132 EventRegistrationToken activated_token_;
133 EventRegistrationToken pointermoved_token_;
134 EventRegistrationToken pointerpressed_token_;
135 EventRegistrationToken pointerreleased_token_;
136 EventRegistrationToken wheel_token_;
137 EventRegistrationToken keydown_token_;
138 EventRegistrationToken keyup_token_;
139 EventRegistrationToken character_received_token_;
140 EventRegistrationToken accel_keydown_token_;
141 EventRegistrationToken accel_keyup_token_;
142 EventRegistrationToken window_activated_token_;
143 EventRegistrationToken sizechange_token_;
145 // Keep state about which button is currently down, if any, as PointerMoved
146 // events do not contain that state, but Ash's MouseEvents need it.
147 ui::EventFlags mouse_down_flags_;
149 // Set the D3D swap chain and nothing else.
150 metro_driver::Direct3DHelper direct3d_helper_;
152 // The channel to Chrome, in particular to the MetroViewerProcessHost.
153 IPC::ChannelProxy* ui_channel_;
155 // The actual window behind the view surface.
156 HWND core_window_hwnd_;
158 // UI message loop to allow message passing into this thread.
159 base::MessageLoop ui_loop_;
162 #endif // WIN8_METRO_DRIVER_CHROME_APP_VIEW_ASH_H_