| 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 <windows.foundation.h> | 9 #include <windows.foundation.h> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 app_view_(app_view) { | 74 app_view_(app_view) { |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 77 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
| 78 IPC_BEGIN_MESSAGE_MAP(ChromeChannelListener, message) | 78 IPC_BEGIN_MESSAGE_MAP(ChromeChannelListener, message) |
| 79 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursor, OnSetCursor) | 79 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursor, OnSetCursor) |
| 80 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileOpen, | 80 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileOpen, |
| 81 OnDisplayFileOpenDialog) | 81 OnDisplayFileOpenDialog) |
| 82 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileSaveAs, | 82 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplayFileSaveAs, |
| 83 OnDisplayFileSaveAsDialog) | 83 OnDisplayFileSaveAsDialog) |
| 84 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_DisplaySelectFolder, |
| 85 OnDisplayFolderPicker) |
| 84 IPC_MESSAGE_UNHANDLED(__debugbreak()) | 86 IPC_MESSAGE_UNHANDLED(__debugbreak()) |
| 85 IPC_END_MESSAGE_MAP() | 87 IPC_END_MESSAGE_MAP() |
| 86 return true; | 88 return true; |
| 87 } | 89 } |
| 88 | 90 |
| 89 virtual void OnChannelError() OVERRIDE { | 91 virtual void OnChannelError() OVERRIDE { |
| 90 DVLOG(1) << "Channel error"; | 92 DVLOG(1) << "Channel error"; |
| 91 MetroExit(); | 93 MetroExit(); |
| 92 } | 94 } |
| 93 | 95 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 114 | 116 |
| 115 void OnDisplayFileSaveAsDialog( | 117 void OnDisplayFileSaveAsDialog( |
| 116 const MetroViewerHostMsg_SaveAsDialogParams& params) { | 118 const MetroViewerHostMsg_SaveAsDialogParams& params) { |
| 117 ui_proxy_->PostTask( | 119 ui_proxy_->PostTask( |
| 118 FROM_HERE, | 120 FROM_HERE, |
| 119 base::Bind(&ChromeAppViewAsh::OnDisplayFileSaveAsDialog, | 121 base::Bind(&ChromeAppViewAsh::OnDisplayFileSaveAsDialog, |
| 120 base::Unretained(app_view_), | 122 base::Unretained(app_view_), |
| 121 params)); | 123 params)); |
| 122 } | 124 } |
| 123 | 125 |
| 126 void OnDisplayFolderPicker(const string16& title) { |
| 127 ui_proxy_->PostTask( |
| 128 FROM_HERE, |
| 129 base::Bind(&ChromeAppViewAsh::OnDisplayFolderPicker, |
| 130 base::Unretained(app_view_), |
| 131 title)); |
| 132 } |
| 133 |
| 124 scoped_refptr<base::MessageLoopProxy> ui_proxy_; | 134 scoped_refptr<base::MessageLoopProxy> ui_proxy_; |
| 125 ChromeAppViewAsh* app_view_; | 135 ChromeAppViewAsh* app_view_; |
| 126 }; | 136 }; |
| 127 | 137 |
| 128 bool WaitForChromeIPCConnection(const std::string& channel_name) { | 138 bool WaitForChromeIPCConnection(const std::string& channel_name) { |
| 129 int ms_elapsed = 0; | 139 int ms_elapsed = 0; |
| 130 while (!IPC::Channel::IsNamedServerInitialized(channel_name) && | 140 while (!IPC::Channel::IsNamedServerInitialized(channel_name) && |
| 131 ms_elapsed < 10000) { | 141 ms_elapsed < 10000) { |
| 132 ms_elapsed += 500; | 142 ms_elapsed += 500; |
| 133 Sleep(500); | 143 Sleep(500); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 480 |
| 471 void ChromeAppViewAsh::OnDisplayFileOpenDialog(const string16& title, | 481 void ChromeAppViewAsh::OnDisplayFileOpenDialog(const string16& title, |
| 472 const string16& filter, | 482 const string16& filter, |
| 473 const string16& default_path, | 483 const string16& default_path, |
| 474 bool allow_multiple_files) { | 484 bool allow_multiple_files) { |
| 475 DVLOG(1) << __FUNCTION__; | 485 DVLOG(1) << __FUNCTION__; |
| 476 | 486 |
| 477 // The OpenFilePickerSession instance is deleted when we receive a | 487 // The OpenFilePickerSession instance is deleted when we receive a |
| 478 // callback from the OpenFilePickerSession class about the completion of the | 488 // callback from the OpenFilePickerSession class about the completion of the |
| 479 // operation. | 489 // operation. |
| 480 OpenFilePickerSession* open_file_picker = | 490 FilePickerSessionBase* file_picker_ = |
| 481 new OpenFilePickerSession(this, | 491 new OpenFilePickerSession(this, |
| 482 title, | 492 title, |
| 483 filter, | 493 filter, |
| 484 default_path, | 494 default_path, |
| 485 allow_multiple_files); | 495 allow_multiple_files); |
| 486 open_file_picker->Run(); | 496 file_picker_->Run(); |
| 487 } | 497 } |
| 488 | 498 |
| 489 void ChromeAppViewAsh::OnDisplayFileSaveAsDialog( | 499 void ChromeAppViewAsh::OnDisplayFileSaveAsDialog( |
| 490 const MetroViewerHostMsg_SaveAsDialogParams& params) { | 500 const MetroViewerHostMsg_SaveAsDialogParams& params) { |
| 491 DVLOG(1) << __FUNCTION__; | 501 DVLOG(1) << __FUNCTION__; |
| 492 | 502 |
| 493 // The SaveFilePickerSession instance is deleted when we receive a | 503 // The SaveFilePickerSession instance is deleted when we receive a |
| 494 // callback from the OpenFilePickerSession class about the completion of the | 504 // callback from the SaveFilePickerSession class about the completion of the |
| 495 // operation. | 505 // operation. |
| 496 SaveFilePickerSession* save_file_picker = | 506 FilePickerSessionBase* file_picker_ = |
| 497 new SaveFilePickerSession(this, params); | 507 new SaveFilePickerSession(this, params); |
| 498 save_file_picker->Run(); | 508 file_picker_->Run(); |
| 509 } |
| 510 |
| 511 void ChromeAppViewAsh::OnDisplayFolderPicker(const string16& title) { |
| 512 DVLOG(1) << __FUNCTION__; |
| 513 // The FolderPickerSession instance is deleted when we receive a |
| 514 // callback from the FolderPickerSession class about the completion of the |
| 515 // operation. |
| 516 FilePickerSessionBase* file_picker_ = new FolderPickerSession(this, title); |
| 517 file_picker_->Run(); |
| 499 } | 518 } |
| 500 | 519 |
| 501 void ChromeAppViewAsh::OnOpenFileCompleted( | 520 void ChromeAppViewAsh::OnOpenFileCompleted( |
| 502 OpenFilePickerSession* open_file_picker, | 521 OpenFilePickerSession* open_file_picker, |
| 503 bool success) { | 522 bool success) { |
| 504 DVLOG(1) << __FUNCTION__; | 523 DVLOG(1) << __FUNCTION__; |
| 505 DVLOG(1) << "Success: " << success; | 524 DVLOG(1) << "Success: " << success; |
| 506 if (ui_channel_) { | 525 if (ui_channel_) { |
| 507 if (open_file_picker->allow_multi_select()) { | 526 if (open_file_picker->allow_multi_select()) { |
| 508 ui_channel_->Send(new MetroViewerHostMsg_MultiFileOpenDone( | 527 ui_channel_->Send(new MetroViewerHostMsg_MultiFileOpenDone( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 522 DVLOG(1) << "Success: " << success; | 541 DVLOG(1) << "Success: " << success; |
| 523 if (ui_channel_) { | 542 if (ui_channel_) { |
| 524 ui_channel_->Send(new MetroViewerHostMsg_FileSaveAsDone( | 543 ui_channel_->Send(new MetroViewerHostMsg_FileSaveAsDone( |
| 525 success, | 544 success, |
| 526 save_file_picker->result(), | 545 save_file_picker->result(), |
| 527 save_file_picker->filter_index())); | 546 save_file_picker->filter_index())); |
| 528 } | 547 } |
| 529 delete save_file_picker; | 548 delete save_file_picker; |
| 530 } | 549 } |
| 531 | 550 |
| 551 void ChromeAppViewAsh::OnFolderPickerCompleted( |
| 552 FolderPickerSession* folder_picker, |
| 553 bool success) { |
| 554 DVLOG(1) << __FUNCTION__; |
| 555 DVLOG(1) << "Success: " << success; |
| 556 if (ui_channel_) { |
| 557 ui_channel_->Send(new MetroViewerHostMsg_SelectFolderDone( |
| 558 success, |
| 559 folder_picker->result())); |
| 560 } |
| 561 delete folder_picker; |
| 562 } |
| 563 |
| 532 HRESULT ChromeAppViewAsh::OnActivate( | 564 HRESULT ChromeAppViewAsh::OnActivate( |
| 533 winapp::Core::ICoreApplicationView*, | 565 winapp::Core::ICoreApplicationView*, |
| 534 winapp::Activation::IActivatedEventArgs* args) { | 566 winapp::Activation::IActivatedEventArgs* args) { |
| 535 DVLOG(1) << __FUNCTION__; | 567 DVLOG(1) << __FUNCTION__; |
| 536 // Note: If doing more work in this function, you migth need to call | 568 // Note: If doing more work in this function, you migth need to call |
| 537 // get_PreviousExecutionState() and skip the work if the result is | 569 // get_PreviousExecutionState() and skip the work if the result is |
| 538 // ApplicationExecutionState_Running and globals.previous_state is too. | 570 // ApplicationExecutionState_Running and globals.previous_state is too. |
| 539 args->get_PreviousExecutionState(&globals.previous_state); | 571 args->get_PreviousExecutionState(&globals.previous_state); |
| 540 DVLOG(1) << "Previous Execution State: " << globals.previous_state; | 572 DVLOG(1) << "Previous Execution State: " << globals.previous_state; |
| 541 | 573 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; | 796 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; |
| 765 CheckHR(core_app.As(&app_exit)); | 797 CheckHR(core_app.As(&app_exit)); |
| 766 globals.app_exit = app_exit.Detach(); | 798 globals.app_exit = app_exit.Detach(); |
| 767 } | 799 } |
| 768 | 800 |
| 769 IFACEMETHODIMP | 801 IFACEMETHODIMP |
| 770 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { | 802 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { |
| 771 *view = mswr::Make<ChromeAppViewAsh>().Detach(); | 803 *view = mswr::Make<ChromeAppViewAsh>().Detach(); |
| 772 return (*view) ? S_OK : E_OUTOFMEMORY; | 804 return (*view) ? S_OK : E_OUTOFMEMORY; |
| 773 } | 805 } |
| OLD | NEW |