Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_ash.h" | 6 #include "win8/metro_driver/chrome_app_view_ash.h" |
| 7 | 7 |
| 8 #include <corewindow.h> | 8 #include <corewindow.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.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/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/win/metro.h" | 18 #include "base/win/metro.h" |
| 19 #include "base/win/win_util.h" | 19 #include "base/win/win_util.h" |
| 20 #include "base/win/windows_version.h" | |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "ipc/ipc_channel.h" | 22 #include "ipc/ipc_channel.h" |
| 22 #include "ipc/ipc_channel_proxy.h" | 23 #include "ipc/ipc_channel_proxy.h" |
| 23 #include "ipc/ipc_sender.h" | 24 #include "ipc/ipc_sender.h" |
| 24 #include "ui/events/gestures/gesture_sequence.h" | 25 #include "ui/events/gestures/gesture_sequence.h" |
| 25 #include "ui/metro_viewer/metro_viewer_messages.h" | 26 #include "ui/metro_viewer/metro_viewer_messages.h" |
| 26 #include "win8/metro_driver/file_picker_ash.h" | 27 #include "win8/metro_driver/file_picker_ash.h" |
| 27 #include "win8/metro_driver/ime/ime_popup_monitor.h" | 28 #include "win8/metro_driver/ime/ime_popup_monitor.h" |
| 28 #include "win8/metro_driver/ime/input_source.h" | 29 #include "win8/metro_driver/ime/input_source.h" |
| 29 #include "win8/metro_driver/ime/text_service.h" | 30 #include "win8/metro_driver/ime/text_service.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 } | 266 } |
| 266 | 267 |
| 267 scoped_refptr<base::MessageLoopProxy> ui_proxy_; | 268 scoped_refptr<base::MessageLoopProxy> ui_proxy_; |
| 268 ChromeAppViewAsh* app_view_; | 269 ChromeAppViewAsh* app_view_; |
| 269 }; | 270 }; |
| 270 | 271 |
| 271 bool WaitForChromeIPCConnection(const std::string& channel_name) { | 272 bool WaitForChromeIPCConnection(const std::string& channel_name) { |
| 272 int ms_elapsed = 0; | 273 int ms_elapsed = 0; |
| 273 while (!IPC::Channel::IsNamedServerInitialized(channel_name) && | 274 while (!IPC::Channel::IsNamedServerInitialized(channel_name) && |
| 274 ms_elapsed < 10000) { | 275 ms_elapsed < 10000) { |
| 275 ms_elapsed += 500; | 276 ms_elapsed += 100; |
| 276 Sleep(500); | 277 Sleep(100); |
|
cpu_(ooo_6.6-7.5)
2014/03/26 19:22:53
this is really unrelated to the change, just saw i
| |
| 277 } | 278 } |
| 278 return IPC::Channel::IsNamedServerInitialized(channel_name); | 279 return IPC::Channel::IsNamedServerInitialized(channel_name); |
| 279 } | 280 } |
| 280 | 281 |
| 281 void RunMessageLoop(winui::Core::ICoreDispatcher* dispatcher) { | 282 void RunMessageLoop(winui::Core::ICoreDispatcher* dispatcher) { |
| 282 // We're entering a nested message loop, let's allow dispatching | 283 // We're entering a nested message loop, let's allow dispatching |
| 283 // tasks while we're in there. | 284 // tasks while we're in there. |
| 284 base::MessageLoop::current()->SetNestableTasksAllowed(true); | 285 base::MessageLoop::current()->SetNestableTasksAllowed(true); |
| 285 | 286 |
| 286 // Enter main core message loop. There are several ways to exit it | 287 // Enter main core message loop. There are several ways to exit it |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 this, &ChromeAppViewAsh::OnKeyDown).Get(), | 567 this, &ChromeAppViewAsh::OnKeyDown).Get(), |
| 567 &keydown_token_); | 568 &keydown_token_); |
| 568 CheckHR(hr); | 569 CheckHR(hr); |
| 569 | 570 |
| 570 hr = window_->add_KeyUp(mswr::Callback<KeyEventHandler>( | 571 hr = window_->add_KeyUp(mswr::Callback<KeyEventHandler>( |
| 571 this, &ChromeAppViewAsh::OnKeyUp).Get(), | 572 this, &ChromeAppViewAsh::OnKeyUp).Get(), |
| 572 &keyup_token_); | 573 &keyup_token_); |
| 573 CheckHR(hr); | 574 CheckHR(hr); |
| 574 | 575 |
| 575 mswr::ComPtr<winui::Core::ICoreDispatcher> dispatcher; | 576 mswr::ComPtr<winui::Core::ICoreDispatcher> dispatcher; |
| 576 hr = window_->get_Dispatcher(&dispatcher); | 577 hr = window_->get_Dispatcher(dispatcher.GetAddressOf()); |
|
cpu_(ooo_6.6-7.5)
2014/03/26 19:22:53
this is just to stay at one style of passing point
| |
| 577 CheckHR(hr, "Get Dispatcher failed."); | 578 CheckHR(hr, "Get Dispatcher failed."); |
| 578 | 579 |
| 579 mswr::ComPtr<winui::Core::ICoreAcceleratorKeys> accelerator_keys; | 580 mswr::ComPtr<winui::Core::ICoreAcceleratorKeys> accelerator_keys; |
| 580 hr = dispatcher.CopyTo(__uuidof(winui::Core::ICoreAcceleratorKeys), | 581 hr = dispatcher.CopyTo(__uuidof(winui::Core::ICoreAcceleratorKeys), |
| 581 reinterpret_cast<void**>( | 582 reinterpret_cast<void**>( |
| 582 accelerator_keys.GetAddressOf())); | 583 accelerator_keys.GetAddressOf())); |
| 583 CheckHR(hr, "QI for ICoreAcceleratorKeys failed."); | 584 CheckHR(hr, "QI for ICoreAcceleratorKeys failed."); |
| 584 hr = accelerator_keys->add_AcceleratorKeyActivated( | 585 hr = accelerator_keys->add_AcceleratorKeyActivated( |
| 585 mswr::Callback<AcceleratorKeyEventHandler>( | 586 mswr::Callback<AcceleratorKeyEventHandler>( |
| 586 this, &ChromeAppViewAsh::OnAcceleratorKeyDown).Get(), | 587 this, &ChromeAppViewAsh::OnAcceleratorKeyDown).Get(), |
| 587 &accel_keydown_token_); | 588 &accel_keydown_token_); |
| 588 CheckHR(hr); | 589 CheckHR(hr); |
| 589 | 590 |
| 590 hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>( | 591 hr = window_->add_PointerWheelChanged(mswr::Callback<PointerEventHandler>( |
| 591 this, &ChromeAppViewAsh::OnWheel).Get(), | 592 this, &ChromeAppViewAsh::OnWheel).Get(), |
| 592 &wheel_token_); | 593 &wheel_token_); |
| 593 CheckHR(hr); | 594 CheckHR(hr); |
| 594 | 595 |
| 595 hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>( | 596 hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>( |
| 596 this, &ChromeAppViewAsh::OnCharacterReceived).Get(), | 597 this, &ChromeAppViewAsh::OnCharacterReceived).Get(), |
| 597 &character_received_token_); | 598 &character_received_token_); |
| 598 CheckHR(hr); | 599 CheckHR(hr); |
| 599 | 600 |
| 600 hr = window_->add_Activated(mswr::Callback<WindowActivatedHandler>( | 601 hr = window_->add_Activated(mswr::Callback<WindowActivatedHandler>( |
| 601 this, &ChromeAppViewAsh::OnWindowActivated).Get(), | 602 this, &ChromeAppViewAsh::OnWindowActivated).Get(), |
| 602 &window_activated_token_); | 603 &window_activated_token_); |
| 603 CheckHR(hr); | 604 CheckHR(hr); |
| 604 | 605 |
| 605 // Register for edge gesture notifications. | 606 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 606 mswr::ComPtr<winui::Input::IEdgeGestureStatics> edge_gesture_statics; | 607 // Register for edge gesture notifications only for Windows 8 and above. |
| 607 hr = winrt_utils::CreateActivationFactory( | 608 mswr::ComPtr<winui::Input::IEdgeGestureStatics> edge_gesture_statics; |
| 608 RuntimeClass_Windows_UI_Input_EdgeGesture, | 609 hr = winrt_utils::CreateActivationFactory( |
| 609 edge_gesture_statics.GetAddressOf()); | 610 RuntimeClass_Windows_UI_Input_EdgeGesture, |
| 610 CheckHR(hr); | 611 edge_gesture_statics.GetAddressOf()); |
| 612 CheckHR(hr); | |
| 611 | 613 |
| 612 mswr::ComPtr<winui::Input::IEdgeGesture> edge_gesture; | 614 mswr::ComPtr<winui::Input::IEdgeGesture> edge_gesture; |
| 613 hr = edge_gesture_statics->GetForCurrentView(&edge_gesture); | 615 hr = edge_gesture_statics->GetForCurrentView(&edge_gesture); |
| 614 CheckHR(hr); | 616 CheckHR(hr); |
| 615 | 617 |
| 616 hr = edge_gesture->add_Completed(mswr::Callback<EdgeEventHandler>( | 618 hr = edge_gesture->add_Completed(mswr::Callback<EdgeEventHandler>( |
| 617 this, &ChromeAppViewAsh::OnEdgeGestureCompleted).Get(), | 619 this, &ChromeAppViewAsh::OnEdgeGestureCompleted).Get(), |
| 618 &edgeevent_token_); | 620 &edgeevent_token_); |
| 619 CheckHR(hr); | 621 CheckHR(hr); |
| 622 } | |
| 620 | 623 |
| 621 // By initializing the direct 3D swap chain with the corewindow | 624 // By initializing the direct 3D swap chain with the corewindow |
| 622 // we can now directly blit to it from the browser process. | 625 // we can now directly blit to it from the browser process. |
| 623 direct3d_helper_.Initialize(window); | 626 direct3d_helper_.Initialize(window); |
| 624 DVLOG(1) << "Initialized Direct3D."; | 627 DVLOG(1) << "Initialized Direct3D."; |
| 625 return S_OK; | 628 return S_OK; |
| 626 } | 629 } |
| 627 | 630 |
| 628 IFACEMETHODIMP | 631 IFACEMETHODIMP |
| 629 ChromeAppViewAsh::Load(HSTRING entryPoint) { | 632 ChromeAppViewAsh::Load(HSTRING entryPoint) { |
| 633 // On Win7 |entryPoint| is NULL. | |
|
cpu_(ooo_6.6-7.5)
2014/03/26 19:22:53
cause we don't have machinery to create hstrings o
| |
| 630 DVLOG(1) << __FUNCTION__; | 634 DVLOG(1) << __FUNCTION__; |
| 631 return S_OK; | 635 return S_OK; |
| 632 } | 636 } |
| 633 | 637 |
| 634 IFACEMETHODIMP | 638 IFACEMETHODIMP |
| 635 ChromeAppViewAsh::Run() { | 639 ChromeAppViewAsh::Run() { |
| 636 DVLOG(1) << __FUNCTION__; | 640 DVLOG(1) << __FUNCTION__; |
| 637 mswr::ComPtr<winui::Core::ICoreDispatcher> dispatcher; | 641 mswr::ComPtr<winui::Core::ICoreDispatcher> dispatcher; |
| 638 HRESULT hr = window_->get_Dispatcher(&dispatcher); | 642 HRESULT hr = window_->get_Dispatcher(dispatcher.GetAddressOf()); |
| 639 CheckHR(hr, "Dispatcher failed."); | 643 CheckHR(hr, "Dispatcher failed."); |
| 640 | 644 |
| 641 hr = window_->Activate(); | 645 hr = window_->Activate(); |
| 642 if (FAILED(hr)) { | 646 if (FAILED(hr)) { |
| 643 DLOG(WARNING) << "activation failed hr=" << hr; | 647 DLOG(WARNING) << "activation failed hr=" << hr; |
| 644 return hr; | 648 return hr; |
| 645 } | 649 } |
| 646 | 650 |
| 647 // Create the IPC channel IO thread. It needs to out-live the ChannelProxy. | 651 // Create the IPC channel IO thread. It needs to out-live the ChannelProxy. |
| 648 base::Thread io_thread("metro_IO_thread"); | 652 base::Thread io_thread("metro_IO_thread"); |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1343 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; | 1347 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; |
| 1344 CheckHR(core_app.As(&app_exit)); | 1348 CheckHR(core_app.As(&app_exit)); |
| 1345 globals.app_exit = app_exit.Detach(); | 1349 globals.app_exit = app_exit.Detach(); |
| 1346 } | 1350 } |
| 1347 | 1351 |
| 1348 IFACEMETHODIMP | 1352 IFACEMETHODIMP |
| 1349 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 1353 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
| 1350 *view = mswr::Make<ChromeAppViewAsh>().Detach(); | 1354 *view = mswr::Make<ChromeAppViewAsh>().Detach(); |
| 1351 return (*view) ? S_OK : E_OUTOFMEMORY; | 1355 return (*view) ? S_OK : E_OUTOFMEMORY; |
| 1352 } | 1356 } |
| OLD | NEW |