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/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 17 #include "base/win/metro.h" | 18 #include "base/win/metro.h" |
| 18 #include "base/win/win_util.h" | 19 #include "base/win/win_util.h" |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "ipc/ipc_channel.h" | 21 #include "ipc/ipc_channel.h" |
| 21 #include "ipc/ipc_channel_proxy.h" | 22 #include "ipc/ipc_channel_proxy.h" |
| 22 #include "ipc/ipc_sender.h" | 23 #include "ipc/ipc_sender.h" |
| 23 #include "ui/base/gestures/gesture_sequence.h" | 24 #include "ui/base/gestures/gesture_sequence.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 globals.app_exit->Exit(); | 77 globals.app_exit->Exit(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 class ChromeChannelListener : public IPC::Listener { | 80 class ChromeChannelListener : public IPC::Listener { |
| 80 public: | 81 public: |
| 81 ChromeChannelListener(base::MessageLoop* ui_loop, ChromeAppViewAsh* app_view) | 82 ChromeChannelListener(base::MessageLoop* ui_loop, ChromeAppViewAsh* app_view) |
| 82 : ui_proxy_(ui_loop->message_loop_proxy()), app_view_(app_view) {} | 83 : ui_proxy_(ui_loop->message_loop_proxy()), app_view_(app_view) {} |
| 83 | 84 |
| 84 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 85 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
| 85 IPC_BEGIN_MESSAGE_MAP(ChromeChannelListener, message) | 86 IPC_BEGIN_MESSAGE_MAP(ChromeChannelListener, message) |
| 87 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_OpenURLOnDesktop, | |
| 88 OnOpenURLOnDesktop) | |
| 86 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursor, OnSetCursor) | 89 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursor, OnSetCursor) |
| 87 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileOpen, | 90 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileOpen, |
| 88 OnDisplayFileOpenDialog) | 91 OnDisplayFileOpenDialog) |
| 89 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileSaveAs, | 92 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileSaveAs, |
| 90 OnDisplayFileSaveAsDialog) | 93 OnDisplayFileSaveAsDialog) |
| 91 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplaySelectFolder, | 94 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplaySelectFolder, |
| 92 OnDisplayFolderPicker) | 95 OnDisplayFolderPicker) |
| 93 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPos, OnSetCursorPos) | 96 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPos, OnSetCursorPos) |
| 94 IPC_MESSAGE_UNHANDLED(__debugbreak()) | 97 IPC_MESSAGE_UNHANDLED(__debugbreak()) |
| 95 IPC_END_MESSAGE_MAP() | 98 IPC_END_MESSAGE_MAP() |
| 96 return true; | 99 return true; |
| 97 } | 100 } |
| 98 | 101 |
| 99 virtual void OnChannelError() OVERRIDE { | 102 virtual void OnChannelError() OVERRIDE { |
| 100 DVLOG(1) << "Channel error"; | 103 DVLOG(1) << "Channel error"; |
| 101 MetroExit(); | 104 MetroExit(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 private: | 107 private: |
| 108 void OnOpenURLOnDesktop(const base::FilePath& shortcut, | |
| 109 const string16& url) { | |
| 110 ui_proxy_->PostTask(FROM_HERE, | |
| 111 base::Bind(&ChromeAppViewAsh::OnOpenURLOnDesktop, | |
| 112 base::Unretained(app_view_), | |
| 113 shortcut, url)); | |
| 114 } | |
| 115 | |
| 105 void OnSetCursor(int64 cursor) { | 116 void OnSetCursor(int64 cursor) { |
| 106 ui_proxy_->PostTask(FROM_HERE, | 117 ui_proxy_->PostTask(FROM_HERE, |
| 107 base::Bind(&ChromeAppViewAsh::OnSetCursor, | 118 base::Bind(&ChromeAppViewAsh::OnSetCursor, |
| 108 base::Unretained(app_view_), | 119 base::Unretained(app_view_), |
| 109 reinterpret_cast<HCURSOR>(cursor))); | 120 reinterpret_cast<HCURSOR>(cursor))); |
| 110 } | 121 } |
| 111 | 122 |
| 112 void OnDisplayFileOpenDialog(const string16& title, | 123 void OnDisplayFileOpenDialog(const string16& title, |
| 113 const string16& filter, | 124 const string16& filter, |
| 114 const base::FilePath& default_path, | 125 const base::FilePath& default_path, |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 if (FAILED(hr) || !success) { | 506 if (FAILED(hr) || !success) { |
| 496 LOG(ERROR) << "Failed to unsnap. Error 0x" << hr; | 507 LOG(ERROR) << "Failed to unsnap. Error 0x" << hr; |
| 497 if (SUCCEEDED(hr)) | 508 if (SUCCEEDED(hr)) |
| 498 hr = E_UNEXPECTED; | 509 hr = E_UNEXPECTED; |
| 499 } | 510 } |
| 500 } | 511 } |
| 501 return hr; | 512 return hr; |
| 502 } | 513 } |
| 503 | 514 |
| 504 | 515 |
| 516 void ChromeAppViewAsh::OnOpenURLOnDesktop(const base::FilePath& shortcut, | |
| 517 const string16& url) { | |
| 518 string16 file = shortcut.AsUTF16Unsafe(); | |
|
Bernhard Bauer
2013/08/31 10:15:05
You could probably use FilePath::StringType here.
| |
| 519 SHELLEXECUTEINFO sei = { sizeof(sei) }; | |
| 520 sei.fMask = SEE_MASK_FLAG_LOG_USAGE; | |
| 521 sei.nShow = SW_SHOWNORMAL; | |
| 522 sei.lpFile = file.c_str(); | |
| 523 sei.lpDirectory = L""; | |
| 524 sei.lpParameters = url.c_str(); | |
| 525 BOOL result = ShellExecuteEx(&sei); | |
|
cpu_(ooo_6.6-7.5)
2013/09/03 17:55:12
who knows what COM apartment this thread has... bu
| |
| 526 } | |
| 527 | |
| 505 void ChromeAppViewAsh::OnSetCursor(HCURSOR cursor) { | 528 void ChromeAppViewAsh::OnSetCursor(HCURSOR cursor) { |
| 506 ::SetCursor(HCURSOR(cursor)); | 529 ::SetCursor(HCURSOR(cursor)); |
| 507 } | 530 } |
| 508 | 531 |
| 509 void ChromeAppViewAsh::OnDisplayFileOpenDialog( | 532 void ChromeAppViewAsh::OnDisplayFileOpenDialog( |
| 510 const string16& title, | 533 const string16& title, |
| 511 const string16& filter, | 534 const string16& filter, |
| 512 const base::FilePath& default_path, | 535 const base::FilePath& default_path, |
| 513 bool allow_multiple_files) { | 536 bool allow_multiple_files) { |
| 514 DVLOG(1) << __FUNCTION__; | 537 DVLOG(1) << __FUNCTION__; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 953 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; | 976 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; |
| 954 CheckHR(core_app.As(&app_exit)); | 977 CheckHR(core_app.As(&app_exit)); |
| 955 globals.app_exit = app_exit.Detach(); | 978 globals.app_exit = app_exit.Detach(); |
| 956 } | 979 } |
| 957 | 980 |
| 958 IFACEMETHODIMP | 981 IFACEMETHODIMP |
| 959 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 982 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
| 960 *view = mswr::Make<ChromeAppViewAsh>().Detach(); | 983 *view = mswr::Make<ChromeAppViewAsh>().Detach(); |
| 961 return (*view) ? S_OK : E_OUTOFMEMORY; | 984 return (*view) ? S_OK : E_OUTOFMEMORY; |
| 962 } | 985 } |
| OLD | NEW |