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

Side by Side Diff: win8/metro_driver/chrome_app_view.cc

Issue 10983015: Metro side of the metro viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | win8/metro_driver/metro_driver.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "win8/metro_driver/stdafx.h" 5 #include "win8/metro_driver/stdafx.h"
6 #include "win8/metro_driver/chrome_app_view.h" 6 #include "win8/metro_driver/chrome_app_view.h"
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <windows.applicationModel.datatransfer.h> 9 #include <windows.applicationModel.datatransfer.h>
10 #include <windows.foundation.h> 10 #include <windows.foundation.h>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/win/metro.h" 14 #include "base/win/metro.h"
15 15
16 #include "base/threading/thread.h"
17 #include "ipc/ipc_channel.h"
18 #include "ipc/ipc_channel_proxy.h"
19 #include "ipc/ipc_sender.h"
20
16 // This include allows to send WM_SYSCOMMANDs to chrome. 21 // This include allows to send WM_SYSCOMMANDs to chrome.
17 #include "chrome/app/chrome_command_ids.h" 22 #include "chrome/app/chrome_command_ids.h"
18 #include "win8/metro_driver/winrt_utils.h" 23 #include "win8/metro_driver/winrt_utils.h"
19 #include "ui/base/ui_base_switches.h" 24 #include "ui/base/ui_base_switches.h"
20 25
26 //=============================================================================
27
28 // Get basic type definitions.
29 #define IPC_MESSAGE_IMPL
30 #include "win8/metro_driver/viewer_messages.h"
jam 2012/09/27 21:20:46 this is usually done in a separate cc file, i.e. v
31
32 // Generate constructors.
33 #include "ipc/struct_constructor_macros.h"
34 #include "win8/metro_driver/viewer_messages.h"
35
36 // Generate destructors.
37 #include "ipc/struct_destructor_macros.h"
38 #include "win8/metro_driver/viewer_messages.h"
39
40 // Generate param traits write methods.
41 #include "ipc/param_traits_write_macros.h"
42 namespace IPC {
43 #include "win8/metro_driver/viewer_messages.h"
44 } // namespace IPC
45
46 // Generate param traits read methods.
47 #include "ipc/param_traits_read_macros.h"
48 namespace IPC {
49 #include "win8/metro_driver/viewer_messages.h"
50 } // namespace IPC
51
52 // Generate param traits log methods.
53 #include "ipc/param_traits_log_macros.h"
54 namespace IPC {
55 #include "win8/metro_driver/viewer_messages.h"
56 } // namespace IPC
57
58 //=============================================================================
59
21 typedef winfoundtn::ITypedEventHandler< 60 typedef winfoundtn::ITypedEventHandler<
22 winapp::Core::CoreApplicationView*, 61 winapp::Core::CoreApplicationView*,
23 winapp::Activation::IActivatedEventArgs*> ActivatedHandler; 62 winapp::Activation::IActivatedEventArgs*> ActivatedHandler;
24 63
25 typedef winfoundtn::ITypedEventHandler< 64 typedef winfoundtn::ITypedEventHandler<
26 winui::Core::CoreWindow*, 65 winui::Core::CoreWindow*,
27 winui::Core::WindowSizeChangedEventArgs*> SizeChangedHandler; 66 winui::Core::WindowSizeChangedEventArgs*> SizeChangedHandler;
28 67
29 typedef winfoundtn::ITypedEventHandler< 68 typedef winfoundtn::ITypedEventHandler<
30 winui::Input::EdgeGesture*, 69 winui::Input::EdgeGesture*,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 304
266 DVLOG(1) << "Hiding current top window:" 305 DVLOG(1) << "Hiding current top window:"
267 << reinterpret_cast<int>(current_top_window.first); 306 << reinterpret_cast<int>(current_top_window.first);
268 AnimateWindow(current_top_window.first, kAnimateWindowTimeoutMs, 307 AnimateWindow(current_top_window.first, kAnimateWindowTimeoutMs,
269 AW_HIDE | AW_HOR_POSITIVE | AW_SLIDE); 308 AW_HIDE | AW_HOR_POSITIVE | AW_SLIDE);
270 309
271 globals.host_windows.push_back(current_top_window); 310 globals.host_windows.push_back(current_top_window);
272 } 311 }
273 } 312 }
274 313
314 class ChromeChannelListener : public IPC::Listener {
315 public:
316 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
317 DVLOG(1) << "Received ipc message " << message.type();
318 return true;
319 }
320
321 virtual void OnChannelError() OVERRIDE {
322 DVLOG(1) << "Channel error";
323 MessageLoop::current()->Quit();
324 }
325
326 void Init(IPC::Sender* s) {
327 sender_ = s;
328 }
329
330 private:
331 IPC::Sender* sender_;
332 };
333
275 } // namespace 334 } // namespace
276 335
277 HRESULT ChromeAppView::TileRequestCreateDone( 336 HRESULT ChromeAppView::TileRequestCreateDone(
278 winfoundtn::IAsyncOperation<bool>* async, 337 winfoundtn::IAsyncOperation<bool>* async,
279 AsyncStatus status) { 338 AsyncStatus status) {
280 if (status == Completed) { 339 if (status == Completed) {
281 unsigned char result; 340 unsigned char result;
282 CheckHR(async->GetResults(&result)); 341 CheckHR(async->GetResults(&result));
283 DVLOG(1) << __FUNCTION__ << " result " << static_cast<int>(result); 342 DVLOG(1) << __FUNCTION__ << " result " << static_cast<int>(result);
284 } else { 343 } else {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 HRESULT hr = window_->get_Dispatcher(&dispatcher); 840 HRESULT hr = window_->get_Dispatcher(&dispatcher);
782 CheckHR(hr, "Dispatcher failed."); 841 CheckHR(hr, "Dispatcher failed.");
783 842
784 hr = window_->Activate(); 843 hr = window_->Activate();
785 if (SUCCEEDED(hr)) { 844 if (SUCCEEDED(hr)) {
786 // TODO(cpu): Draw something here. 845 // TODO(cpu): Draw something here.
787 } else { 846 } else {
788 DVLOG(1) << "Activate failed, hr=" << hr; 847 DVLOG(1) << "Activate failed, hr=" << hr;
789 } 848 }
790 849
850 // The thread needs to out-live the ChannelProxy.
851 base::Thread thread("metro_IO_thread");
852 base::Thread::Options options;
853 options.message_loop_type = MessageLoop::TYPE_IO;
854 thread.StartWithOptions(options);
855
856 ChromeChannelListener channel_listener;
857 IPC::ChannelProxy chan("viewer", IPC::Channel::MODE_CLIENT,
858 &channel_listener, thread.message_loop_proxy());
859 channel_listener.Init(&chan);
860 chan.Send(new ViewerHostMsg_SetTargetSurface(uint32(globals.core_window)));
861
862 DVLOG(1) << "corewindow sent " << globals.core_window;
863
791 // Create a message loop to allow message passing into this thread. 864 // Create a message loop to allow message passing into this thread.
792 MessageLoop msg_loop(MessageLoop::TYPE_UI); 865 MessageLoop msg_loop(MessageLoop::TYPE_UI);
793 866
794 // Announce our message loop to the world. 867 // Announce our message loop to the world.
795 globals.appview_msg_loop = msg_loop.message_loop_proxy(); 868 globals.appview_msg_loop = msg_loop.message_loop_proxy();
796 869
797 // And post the task that'll do the inner Metro message pumping to it. 870 // And post the task that'll do the inner Metro message pumping to it.
798 msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get())); 871 msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get()));
799 872
800 // Post the recurring task which checks for OSK activation in metro chrome. 873 // Post the recurring task which checks for OSK activation in metro chrome.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 return S_OK; 968 return S_OK;
896 } 969 }
897 970
898 do { 971 do {
899 ::Sleep(10); 972 ::Sleep(10);
900 ::EnumThreadWindows(globals.main_thread_id, &CoreWindowFinder, 0); 973 ::EnumThreadWindows(globals.main_thread_id, &CoreWindowFinder, 0);
901 } while (globals.core_window == NULL); 974 } while (globals.core_window == NULL);
902 975
903 DVLOG(1) << "CoreWindow found: " << std::hex << globals.core_window; 976 DVLOG(1) << "CoreWindow found: " << std::hex << globals.core_window;
904 977
978 #if 0
905 if (!globals.host_thread) { 979 if (!globals.host_thread) {
906 DWORD chrome_ui_thread_id = 0; 980 DWORD chrome_ui_thread_id = 0;
907 globals.host_thread = 981 globals.host_thread =
908 ::CreateThread(NULL, 0, HostMainThreadProc, NULL, 0, 982 ::CreateThread(NULL, 0, HostMainThreadProc, NULL, 0,
909 &chrome_ui_thread_id); 983 &chrome_ui_thread_id);
910 984
911 if (!globals.host_thread) { 985 if (!globals.host_thread) {
912 NOTREACHED() << "thread creation failed."; 986 NOTREACHED() << "thread creation failed.";
913 return E_UNEXPECTED; 987 return E_UNEXPECTED;
914 } 988 }
915 989
916 ::AttachThreadInput(chrome_ui_thread_id, globals.main_thread_id, TRUE); 990 ::AttachThreadInput(chrome_ui_thread_id, globals.main_thread_id, TRUE);
917 } 991 }
992 #endif
918 993
919 if (RegisterHotKey(globals.core_window, kFlipWindowsHotKeyId, 994 if (RegisterHotKey(globals.core_window, kFlipWindowsHotKeyId,
920 MOD_CONTROL, VK_F12)) { 995 MOD_CONTROL, VK_F12)) {
921 DVLOG(1) << "Registered flip window hotkey."; 996 DVLOG(1) << "Registered flip window hotkey.";
922 } else { 997 } else {
923 VPLOG(1) << "Failed to register flip window hotkey."; 998 VPLOG(1) << "Failed to register flip window hotkey.";
924 } 999 }
925 HRESULT hr = settings_handler_.Initialize(); 1000 HRESULT hr = settings_handler_.Initialize();
926 CheckHR(hr,"Failed to initialize settings handler."); 1001 CheckHR(hr,"Failed to initialize settings handler.");
927 return hr; 1002 return hr;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 CheckHR(core_app.As(&app_exit)); 1261 CheckHR(core_app.As(&app_exit));
1187 globals.app_exit = app_exit.Detach(); 1262 globals.app_exit = app_exit.Detach();
1188 } 1263 }
1189 1264
1190 IFACEMETHODIMP 1265 IFACEMETHODIMP
1191 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { 1266 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) {
1192 globals.view = mswr::Make<ChromeAppView>().Detach(); 1267 globals.view = mswr::Make<ChromeAppView>().Detach();
1193 *view = globals.view; 1268 *view = globals.view;
1194 return (*view) ? S_OK : E_OUTOFMEMORY; 1269 return (*view) ? S_OK : E_OUTOFMEMORY;
1195 } 1270 }
OLDNEW
« no previous file with comments | « no previous file | win8/metro_driver/metro_driver.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698