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

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

Issue 14282002: Added support for displaying the select folder picker in Chrome ASH on Windows 8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 | « win8/metro_driver/chrome_app_view_ash.h ('k') | win8/metro_driver/file_picker_ash.h » ('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_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
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
94 private: 96 private:
95 void OnSetCursor(int64 cursor) { 97 void OnSetCursor(int64 cursor) {
96 ui_proxy_->PostTask(FROM_HERE, 98 ui_proxy_->PostTask(FROM_HERE,
97 base::Bind(&ChromeAppViewAsh::OnSetCursor, 99 base::Bind(&ChromeAppViewAsh::OnSetCursor,
98 base::Unretained(app_view_), 100 base::Unretained(app_view_),
99 reinterpret_cast<HCURSOR>(cursor))); 101 reinterpret_cast<HCURSOR>(cursor)));
100 } 102 }
101 103
102 void OnDisplayFileOpenDialog(const string16& title, 104 void OnDisplayFileOpenDialog(const string16& title,
103 const string16& filter, 105 const string16& filter,
104 const string16& default_path, 106 const base::FilePath& default_path,
105 bool allow_multiple_files) { 107 bool allow_multiple_files) {
106 ui_proxy_->PostTask(FROM_HERE, 108 ui_proxy_->PostTask(FROM_HERE,
107 base::Bind(&ChromeAppViewAsh::OnDisplayFileOpenDialog, 109 base::Bind(&ChromeAppViewAsh::OnDisplayFileOpenDialog,
108 base::Unretained(app_view_), 110 base::Unretained(app_view_),
109 title, 111 title,
110 filter, 112 filter,
111 default_path, 113 default_path,
112 allow_multiple_files)); 114 allow_multiple_files));
113 } 115 }
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 471 }
462 } 472 }
463 return hr; 473 return hr;
464 } 474 }
465 475
466 476
467 void ChromeAppViewAsh::OnSetCursor(HCURSOR cursor) { 477 void ChromeAppViewAsh::OnSetCursor(HCURSOR cursor) {
468 ::SetCursor(HCURSOR(cursor)); 478 ::SetCursor(HCURSOR(cursor));
469 } 479 }
470 480
471 void ChromeAppViewAsh::OnDisplayFileOpenDialog(const string16& title, 481 void ChromeAppViewAsh::OnDisplayFileOpenDialog(
472 const string16& filter, 482 const string16& title,
473 const string16& default_path, 483 const string16& filter,
474 bool allow_multiple_files) { 484 const base::FilePath& default_path,
485 bool allow_multiple_files) {
475 DVLOG(1) << __FUNCTION__; 486 DVLOG(1) << __FUNCTION__;
476 487
477 // The OpenFilePickerSession instance is deleted when we receive a 488 // The OpenFilePickerSession instance is deleted when we receive a
478 // callback from the OpenFilePickerSession class about the completion of the 489 // callback from the OpenFilePickerSession class about the completion of the
479 // operation. 490 // operation.
480 OpenFilePickerSession* open_file_picker = 491 FilePickerSessionBase* file_picker_ =
481 new OpenFilePickerSession(this, 492 new OpenFilePickerSession(this,
482 title, 493 title,
483 filter, 494 filter,
484 default_path, 495 default_path.value(),
485 allow_multiple_files); 496 allow_multiple_files);
486 open_file_picker->Run(); 497 file_picker_->Run();
487 } 498 }
488 499
489 void ChromeAppViewAsh::OnDisplayFileSaveAsDialog( 500 void ChromeAppViewAsh::OnDisplayFileSaveAsDialog(
490 const MetroViewerHostMsg_SaveAsDialogParams& params) { 501 const MetroViewerHostMsg_SaveAsDialogParams& params) {
491 DVLOG(1) << __FUNCTION__; 502 DVLOG(1) << __FUNCTION__;
492 503
493 // The SaveFilePickerSession instance is deleted when we receive a 504 // The SaveFilePickerSession instance is deleted when we receive a
494 // callback from the OpenFilePickerSession class about the completion of the 505 // callback from the SaveFilePickerSession class about the completion of the
495 // operation. 506 // operation.
496 SaveFilePickerSession* save_file_picker = 507 FilePickerSessionBase* file_picker_ =
497 new SaveFilePickerSession(this, params); 508 new SaveFilePickerSession(this, params);
498 save_file_picker->Run(); 509 file_picker_->Run();
510 }
511
512 void ChromeAppViewAsh::OnDisplayFolderPicker(const string16& title) {
513 DVLOG(1) << __FUNCTION__;
514 // The FolderPickerSession instance is deleted when we receive a
515 // callback from the FolderPickerSession class about the completion of the
516 // operation.
517 FilePickerSessionBase* file_picker_ = new FolderPickerSession(this, title);
518 file_picker_->Run();
499 } 519 }
500 520
501 void ChromeAppViewAsh::OnOpenFileCompleted( 521 void ChromeAppViewAsh::OnOpenFileCompleted(
502 OpenFilePickerSession* open_file_picker, 522 OpenFilePickerSession* open_file_picker,
503 bool success) { 523 bool success) {
504 DVLOG(1) << __FUNCTION__; 524 DVLOG(1) << __FUNCTION__;
505 DVLOG(1) << "Success: " << success; 525 DVLOG(1) << "Success: " << success;
506 if (ui_channel_) { 526 if (ui_channel_) {
507 if (open_file_picker->allow_multi_select()) { 527 if (open_file_picker->allow_multi_select()) {
508 ui_channel_->Send(new MetroViewerHostMsg_MultiFileOpenDone( 528 ui_channel_->Send(new MetroViewerHostMsg_MultiFileOpenDone(
509 success, open_file_picker->filenames())); 529 success, open_file_picker->filenames()));
510 } else { 530 } else {
511 ui_channel_->Send(new MetroViewerHostMsg_FileOpenDone( 531 ui_channel_->Send(new MetroViewerHostMsg_FileOpenDone(
512 success, open_file_picker->result())); 532 success, base::FilePath(open_file_picker->result())));
513 } 533 }
514 } 534 }
515 delete open_file_picker; 535 delete open_file_picker;
516 } 536 }
517 537
518 void ChromeAppViewAsh::OnSaveFileCompleted( 538 void ChromeAppViewAsh::OnSaveFileCompleted(
519 SaveFilePickerSession* save_file_picker, 539 SaveFilePickerSession* save_file_picker,
520 bool success) { 540 bool success) {
521 DVLOG(1) << __FUNCTION__; 541 DVLOG(1) << __FUNCTION__;
522 DVLOG(1) << "Success: " << success; 542 DVLOG(1) << "Success: " << success;
523 if (ui_channel_) { 543 if (ui_channel_) {
524 ui_channel_->Send(new MetroViewerHostMsg_FileSaveAsDone( 544 ui_channel_->Send(new MetroViewerHostMsg_FileSaveAsDone(
525 success, 545 success,
526 save_file_picker->result(), 546 base::FilePath(save_file_picker->result()),
527 save_file_picker->filter_index())); 547 save_file_picker->filter_index()));
528 } 548 }
529 delete save_file_picker; 549 delete save_file_picker;
530 } 550 }
531 551
552 void ChromeAppViewAsh::OnFolderPickerCompleted(
553 FolderPickerSession* folder_picker,
554 bool success) {
555 DVLOG(1) << __FUNCTION__;
556 DVLOG(1) << "Success: " << success;
557 if (ui_channel_) {
558 ui_channel_->Send(new MetroViewerHostMsg_SelectFolderDone(
559 success,
560 base::FilePath(folder_picker->result())));
561 }
562 delete folder_picker;
563 }
564
532 HRESULT ChromeAppViewAsh::OnActivate( 565 HRESULT ChromeAppViewAsh::OnActivate(
533 winapp::Core::ICoreApplicationView*, 566 winapp::Core::ICoreApplicationView*,
534 winapp::Activation::IActivatedEventArgs* args) { 567 winapp::Activation::IActivatedEventArgs* args) {
535 DVLOG(1) << __FUNCTION__; 568 DVLOG(1) << __FUNCTION__;
536 // Note: If doing more work in this function, you migth need to call 569 // Note: If doing more work in this function, you migth need to call
537 // get_PreviousExecutionState() and skip the work if the result is 570 // get_PreviousExecutionState() and skip the work if the result is
538 // ApplicationExecutionState_Running and globals.previous_state is too. 571 // ApplicationExecutionState_Running and globals.previous_state is too.
539 args->get_PreviousExecutionState(&globals.previous_state); 572 args->get_PreviousExecutionState(&globals.previous_state);
540 DVLOG(1) << "Previous Execution State: " << globals.previous_state; 573 DVLOG(1) << "Previous Execution State: " << globals.previous_state;
541 574
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit; 797 mswr::ComPtr<winapp::Core::ICoreApplicationExit> app_exit;
765 CheckHR(core_app.As(&app_exit)); 798 CheckHR(core_app.As(&app_exit));
766 globals.app_exit = app_exit.Detach(); 799 globals.app_exit = app_exit.Detach();
767 } 800 }
768 801
769 IFACEMETHODIMP 802 IFACEMETHODIMP
770 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { 803 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) {
771 *view = mswr::Make<ChromeAppViewAsh>().Detach(); 804 *view = mswr::Make<ChromeAppViewAsh>().Detach();
772 return (*view) ? S_OK : E_OUTOFMEMORY; 805 return (*view) ? S_OK : E_OUTOFMEMORY;
773 } 806 }
OLDNEW
« no previous file with comments | « win8/metro_driver/chrome_app_view_ash.h ('k') | win8/metro_driver/file_picker_ash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698