| Index: win8/metro_driver/chrome_app_view.cc
|
| diff --git a/win8/metro_driver/chrome_app_view.cc b/win8/metro_driver/chrome_app_view.cc
|
| index 0c936571049571f1f591d5b363bafbb1ded7fd7a..9eaa92b0a248473e068c508a4c111dd7e4c8ee17 100644
|
| --- a/win8/metro_driver/chrome_app_view.cc
|
| +++ b/win8/metro_driver/chrome_app_view.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "win8/metro_driver/stdafx.h"
|
| #include "win8/metro_driver/chrome_app_view.h"
|
| +#include "win8/metro_driver/direct3d_helper.h"
|
|
|
| #include <algorithm>
|
| #include <windows.applicationModel.datatransfer.h>
|
| @@ -13,11 +14,50 @@
|
| #include "base/message_loop.h"
|
| #include "base/win/metro.h"
|
|
|
| +#include "base/threading/thread.h"
|
| +#include "ipc/ipc_channel.h"
|
| +#include "ipc/ipc_channel_proxy.h"
|
| +#include "ipc/ipc_sender.h"
|
| +
|
| // This include allows to send WM_SYSCOMMANDs to chrome.
|
| #include "chrome/app/chrome_command_ids.h"
|
| #include "win8/metro_driver/winrt_utils.h"
|
| #include "ui/base/ui_base_switches.h"
|
|
|
| +//=============================================================================
|
| +
|
| +// Get basic type definitions.
|
| +#define IPC_MESSAGE_IMPL
|
| +#include "chrome/common/viewer_messages.h"
|
| +
|
| +// Generate constructors.
|
| +#include "ipc/struct_constructor_macros.h"
|
| +#include "chrome/common/viewer_messages.h"
|
| +
|
| +// Generate destructors.
|
| +#include "ipc/struct_destructor_macros.h"
|
| +#include "chrome/common/viewer_messages.h"
|
| +
|
| +// Generate param traits write methods.
|
| +#include "ipc/param_traits_write_macros.h"
|
| +namespace IPC {
|
| +#include "chrome/common/viewer_messages.h"
|
| +} // namespace IPC
|
| +
|
| +// Generate param traits read methods.
|
| +#include "ipc/param_traits_read_macros.h"
|
| +namespace IPC {
|
| +#include "chrome/common/viewer_messages.h"
|
| +} // namespace IPC
|
| +
|
| +// Generate param traits log methods.
|
| +#include "ipc/param_traits_log_macros.h"
|
| +namespace IPC {
|
| +#include "chrome/common/viewer_messages.h"
|
| +} // namespace IPC
|
| +
|
| +//=============================================================================
|
| +
|
| typedef winfoundtn::ITypedEventHandler<
|
| winapp::Core::CoreApplicationView*,
|
| winapp::Activation::IActivatedEventArgs*> ActivatedHandler;
|
| @@ -272,6 +312,26 @@ void FlipFrameWindowsInternal() {
|
| }
|
| }
|
|
|
| +class ChromeChannelListener : public IPC::Listener {
|
| + public:
|
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
|
| + DVLOG(1) << "Received ipc message " << message.type();
|
| + return true;
|
| + }
|
| +
|
| + virtual void OnChannelError() OVERRIDE {
|
| + DVLOG(1) << "Channel error";
|
| + MessageLoop::current()->Quit();
|
| + }
|
| +
|
| + void Init(IPC::Sender* s) {
|
| + sender_ = s;
|
| + }
|
| +
|
| + private:
|
| + IPC::Sender* sender_;
|
| +};
|
| +
|
| } // namespace
|
|
|
| HRESULT ChromeAppView::TileRequestCreateDone(
|
| @@ -705,6 +765,10 @@ ChromeAppView::SetWindow(winui::Core::ICoreWindow* window) {
|
|
|
| DVLOG(1) << "Created appview instance.";
|
|
|
| + direct3d_helper_.Initialize(window);
|
| +
|
| + DVLOG(1) << "Initialized Direct3D.";
|
| +
|
| hr = devices_handler_.Initialize(window);
|
| // Don't check or return the failure here, we need to let the app
|
| // initialization succeed. Even if we won't be able to access devices
|
| @@ -774,19 +838,49 @@ void ChromeAppView::CheckForOSKActivation() {
|
| base::TimeDelta::FromMilliseconds(kCheckOSKDelayMs));
|
| }
|
|
|
| +void SendHwnd(base::Thread* thread, HWND hwnd) {
|
| + ChromeChannelListener channel_listener;
|
| + IPC::ChannelProxy chan("viewer", IPC::Channel::MODE_NAMED_CLIENT,
|
| + &channel_listener, thread->message_loop_proxy());
|
| + DVLOG(1) << __FUNCTION__ << ", wee6";
|
| + channel_listener.Init(&chan);
|
| + DVLOG(1) << __FUNCTION__ << ", wee7";
|
| + chan.Send(new ViewerHostMsg_SetTargetSurface(uint32(hwnd)));
|
| + DVLOG(1) << __FUNCTION__ << ", wee8";
|
| +
|
| + DVLOG(1) << "corewindow sent " << hwnd;
|
| +}
|
| +
|
| IFACEMETHODIMP
|
| ChromeAppView::Run() {
|
| DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(window_.Get());
|
| mswr::ComPtr<winui::Core::ICoreDispatcher> dispatcher;
|
| + DVLOG(1) << __FUNCTION__ << ", wee0";
|
| HRESULT hr = window_->get_Dispatcher(&dispatcher);
|
| + DVLOG(1) << __FUNCTION__ << ", wee1";
|
| CheckHR(hr, "Dispatcher failed.");
|
|
|
| hr = window_->Activate();
|
| + DVLOG(1) << __FUNCTION__ << ", wee2";
|
| if (SUCCEEDED(hr)) {
|
| // TODO(cpu): Draw something here.
|
| } else {
|
| DVLOG(1) << "Activate failed, hr=" << hr;
|
| }
|
| + DVLOG(1) << __FUNCTION__ << ", wee3";
|
| +
|
| + // The thread needs to out-live the ChannelProxy.
|
| + base::Thread thread("metro_IO_thread");
|
| + base::Thread::Options options;
|
| + DVLOG(1) << __FUNCTION__ << ", wee4";
|
| + options.message_loop_type = MessageLoop::TYPE_IO;
|
| + thread.StartWithOptions(options);
|
| + DVLOG(1) << __FUNCTION__ << ", wee5";
|
| + DVLOG(1) << __FUNCTION__ << "message_loop: " << thread.message_loop();
|
| +
|
| + thread.message_loop_proxy()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&SendHwnd, &thread, globals.core_window));
|
|
|
| // Create a message loop to allow message passing into this thread.
|
| MessageLoop msg_loop(MessageLoop::TYPE_UI);
|
| @@ -902,6 +996,7 @@ HRESULT ChromeAppView::OnActivate(winapp::Core::ICoreApplicationView*,
|
|
|
| DVLOG(1) << "CoreWindow found: " << std::hex << globals.core_window;
|
|
|
| +#if 0
|
| if (!globals.host_thread) {
|
| DWORD chrome_ui_thread_id = 0;
|
| globals.host_thread =
|
| @@ -915,6 +1010,7 @@ HRESULT ChromeAppView::OnActivate(winapp::Core::ICoreApplicationView*,
|
|
|
| ::AttachThreadInput(chrome_ui_thread_id, globals.main_thread_id, TRUE);
|
| }
|
| +#endif
|
|
|
| if (RegisterHotKey(globals.core_window, kFlipWindowsHotKeyId,
|
| MOD_CONTROL, VK_F12)) {
|
|
|