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

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

Issue 1169923009: Remove remaining use of the deprecated MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo. Created 5 years, 6 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
« no previous file with comments | « win8/metro_driver/chrome_app_view.h ('k') | win8/metro_driver/chrome_app_view_ash.cc » ('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.h" 6 #include "win8/metro_driver/chrome_app_view.h"
7 7
8 #include <corewindow.h> 8 #include <corewindow.h>
9 #include <windows.applicationModel.datatransfer.h> 9 #include <windows.applicationModel.datatransfer.h>
10 #include <windows.foundation.h> 10 #include <windows.foundation.h>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // ensures that chrome exits. 150 // ensures that chrome exits.
151 void MetroExit(bool send_alt_f4_mnemonic) { 151 void MetroExit(bool send_alt_f4_mnemonic) {
152 if (send_alt_f4_mnemonic && globals.view && 152 if (send_alt_f4_mnemonic && globals.view &&
153 globals.view->core_window_hwnd() == ::GetForegroundWindow()) { 153 globals.view->core_window_hwnd() == ::GetForegroundWindow()) {
154 DVLOG(1) << "We are in the foreground. Exiting via Alt F4"; 154 DVLOG(1) << "We are in the foreground. Exiting via Alt F4";
155 SendMnemonic(VK_F4, ALT, false, false); 155 SendMnemonic(VK_F4, ALT, false, false);
156 DWORD core_window_process_id = 0; 156 DWORD core_window_process_id = 0;
157 DWORD core_window_thread_id = GetWindowThreadProcessId( 157 DWORD core_window_thread_id = GetWindowThreadProcessId(
158 globals.view->core_window_hwnd(), &core_window_process_id); 158 globals.view->core_window_hwnd(), &core_window_process_id);
159 if (core_window_thread_id != ::GetCurrentThreadId()) { 159 if (core_window_thread_id != ::GetCurrentThreadId()) {
160 globals.appview_msg_loop->PostDelayedTask( 160 globals.appview_task_runner->PostDelayedTask(
161 FROM_HERE, 161 FROM_HERE,
162 base::Bind(&MetroExit, false), 162 base::Bind(&MetroExit, false),
163 base::TimeDelta::FromMilliseconds(100)); 163 base::TimeDelta::FromMilliseconds(100));
164 } 164 }
165 } else { 165 } else {
166 globals.app_exit->Exit(); 166 globals.app_exit->Exit();
167 } 167 }
168 } 168 }
169 169
170 void AdjustToFitWindow(HWND hwnd, int flags) { 170 void AdjustToFitWindow(HWND hwnd, int flags) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 return view_state; 421 return view_state;
422 } 422 }
423 423
424 void UnsnapHelper() { 424 void UnsnapHelper() {
425 ChromeAppView::Unsnap(); 425 ChromeAppView::Unsnap();
426 } 426 }
427 427
428 extern "C" __declspec(dllexport) 428 extern "C" __declspec(dllexport)
429 void MetroUnsnap() { 429 void MetroUnsnap() {
430 DVLOG(1) << __FUNCTION__; 430 DVLOG(1) << __FUNCTION__;
431 globals.appview_msg_loop->PostTask( 431 globals.appview_task_runner->PostTask(
432 FROM_HERE, base::Bind(&UnsnapHelper)); 432 FROM_HERE, base::Bind(&UnsnapHelper));
433 } 433 }
434 434
435 extern "C" __declspec(dllexport) 435 extern "C" __declspec(dllexport)
436 HWND GetRootWindow() { 436 HWND GetRootWindow() {
437 DVLOG(1) << __FUNCTION__; 437 DVLOG(1) << __FUNCTION__;
438 return globals.view->core_window_hwnd(); 438 return globals.view->core_window_hwnd();
439 } 439 }
440 440
441 extern "C" __declspec(dllexport) 441 extern "C" __declspec(dllexport)
442 void SetFrameWindow(HWND hwnd) { 442 void SetFrameWindow(HWND hwnd) {
443 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd); 443 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd);
444 globals.appview_msg_loop->PostTask( 444 globals.appview_task_runner->PostTask(
445 FROM_HERE, base::Bind(&SetFrameWindowInternal, hwnd)); 445 FROM_HERE, base::Bind(&SetFrameWindowInternal, hwnd));
446 } 446 }
447 447
448 // TODO(ananta) 448 // TODO(ananta)
449 // Handle frame window close by deleting it from the window list and making the 449 // Handle frame window close by deleting it from the window list and making the
450 // next guy visible. 450 // next guy visible.
451 extern "C" __declspec(dllexport) 451 extern "C" __declspec(dllexport)
452 void CloseFrameWindow(HWND hwnd) { 452 void CloseFrameWindow(HWND hwnd) {
453 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd); 453 DVLOG(1) << __FUNCTION__ << ", hwnd=" << LONG_PTR(hwnd);
454 454
455 // This is a hack to ensure that the BrowserViewLayout code layout happens 455 // This is a hack to ensure that the BrowserViewLayout code layout happens
456 // just at the right time to hide the switcher button if it is visible. 456 // just at the right time to hide the switcher button if it is visible.
457 globals.appview_msg_loop->PostDelayedTask( 457 globals.appview_task_runner->PostDelayedTask(
458 FROM_HERE, base::Bind(&CloseFrameWindowInternal, hwnd), 458 FROM_HERE, base::Bind(&CloseFrameWindowInternal, hwnd),
459 base::TimeDelta::FromMilliseconds(50)); 459 base::TimeDelta::FromMilliseconds(50));
460 } 460 }
461 461
462 // Returns the initial url. This returns a valid url only if we were launched 462 // Returns the initial url. This returns a valid url only if we were launched
463 // into metro via a url navigation. 463 // into metro via a url navigation.
464 extern "C" __declspec(dllexport) 464 extern "C" __declspec(dllexport)
465 const wchar_t* GetInitialUrl() { 465 const wchar_t* GetInitialUrl() {
466 DVLOG(1) << __FUNCTION__; 466 DVLOG(1) << __FUNCTION__;
467 bool was_initial_activation = globals.is_initial_activation; 467 bool was_initial_activation = globals.is_initial_activation;
(...skipping 29 matching lines...) Expand all
497 *previous_state = static_cast<base::win::MetroPreviousExecutionState>( 497 *previous_state = static_cast<base::win::MetroPreviousExecutionState>(
498 globals.previous_state); 498 globals.previous_state);
499 } 499 }
500 return static_cast<base::win::MetroLaunchType>( 500 return static_cast<base::win::MetroLaunchType>(
501 globals.initial_activation_kind); 501 globals.initial_activation_kind);
502 } 502 }
503 503
504 extern "C" __declspec(dllexport) 504 extern "C" __declspec(dllexport)
505 void FlipFrameWindows() { 505 void FlipFrameWindows() {
506 DVLOG(1) << __FUNCTION__; 506 DVLOG(1) << __FUNCTION__;
507 globals.appview_msg_loop->PostTask( 507 globals.appview_task_runner->PostTask(
508 FROM_HERE, base::Bind(&FlipFrameWindowsInternal)); 508 FROM_HERE, base::Bind(&FlipFrameWindowsInternal));
509 } 509 }
510 510
511 extern "C" __declspec(dllexport) 511 extern "C" __declspec(dllexport)
512 void DisplayNotification(const char* origin_url, const char* icon_url, 512 void DisplayNotification(const char* origin_url, const char* icon_url,
513 const wchar_t* title, const wchar_t* body, 513 const wchar_t* title, const wchar_t* body,
514 const wchar_t* display_source, 514 const wchar_t* display_source,
515 const char* notification_id, 515 const char* notification_id,
516 base::win::MetroNotificationClickedHandler handler, 516 base::win::MetroNotificationClickedHandler handler,
517 const wchar_t* handler_context) { 517 const wchar_t* handler_context) {
518 // TODO(ananta) 518 // TODO(ananta)
519 // Needs implementation. 519 // Needs implementation.
520 DVLOG(1) << __FUNCTION__; 520 DVLOG(1) << __FUNCTION__;
521 521
522 ToastNotificationHandler::DesktopNotification notification(origin_url, 522 ToastNotificationHandler::DesktopNotification notification(origin_url,
523 icon_url, 523 icon_url,
524 title, 524 title,
525 body, 525 body,
526 display_source, 526 display_source,
527 notification_id, 527 notification_id,
528 handler, 528 handler,
529 handler_context); 529 handler_context);
530 globals.appview_msg_loop->PostTask( 530 globals.appview_task_runner->PostTask(
531 FROM_HERE, base::Bind(&ChromeAppView::DisplayNotification, 531 FROM_HERE, base::Bind(&ChromeAppView::DisplayNotification,
532 globals.view, notification)); 532 globals.view, notification));
533 } 533 }
534 534
535 extern "C" __declspec(dllexport) 535 extern "C" __declspec(dllexport)
536 bool CancelNotification(const char* notification_id) { 536 bool CancelNotification(const char* notification_id) {
537 // TODO(ananta) 537 // TODO(ananta)
538 // Needs implementation. 538 // Needs implementation.
539 DVLOG(1) << __FUNCTION__; 539 DVLOG(1) << __FUNCTION__;
540 540
541 if (!globals.view->IsValidNotification(notification_id)) { 541 if (!globals.view->IsValidNotification(notification_id)) {
542 NOTREACHED() << "Invalid notification id :" << notification_id; 542 NOTREACHED() << "Invalid notification id :" << notification_id;
543 return false; 543 return false;
544 } 544 }
545 545
546 globals.appview_msg_loop->PostTask( 546 globals.appview_task_runner->PostTask(
547 FROM_HERE, base::Bind(&ChromeAppView::CancelNotification, 547 FROM_HERE, base::Bind(&ChromeAppView::CancelNotification,
548 globals.view, std::string(notification_id))); 548 globals.view, std::string(notification_id)));
549 return true; 549 return true;
550 } 550 }
551 551
552 // Returns command line switches if any to be used by metro chrome. 552 // Returns command line switches if any to be used by metro chrome.
553 extern "C" __declspec(dllexport) 553 extern "C" __declspec(dllexport)
554 const wchar_t* GetMetroCommandLineSwitches() { 554 const wchar_t* GetMetroCommandLineSwitches() {
555 DVLOG(1) << __FUNCTION__; 555 DVLOG(1) << __FUNCTION__;
556 // The metro_command_line_switches field should be filled up once. 556 // The metro_command_line_switches field should be filled up once.
(...skipping 21 matching lines...) Expand all
578 DCHECK(button2_handler); 578 DCHECK(button2_handler);
579 579
580 MetroDialogBox::DialogBoxInfo dialog_box_info; 580 MetroDialogBox::DialogBoxInfo dialog_box_info;
581 dialog_box_info.title = title; 581 dialog_box_info.title = title;
582 dialog_box_info.content = content; 582 dialog_box_info.content = content;
583 dialog_box_info.button1_label = button1_label; 583 dialog_box_info.button1_label = button1_label;
584 dialog_box_info.button2_label = button2_label; 584 dialog_box_info.button2_label = button2_label;
585 dialog_box_info.button1_handler = button1_handler; 585 dialog_box_info.button1_handler = button1_handler;
586 dialog_box_info.button2_handler = button2_handler; 586 dialog_box_info.button2_handler = button2_handler;
587 587
588 globals.appview_msg_loop->PostTask( 588 globals.appview_task_runner->PostTask(
589 FROM_HERE, base::Bind( 589 FROM_HERE, base::Bind(
590 &ChromeAppView::ShowDialogBox, globals.view, dialog_box_info)); 590 &ChromeAppView::ShowDialogBox, globals.view, dialog_box_info));
591 } 591 }
592 592
593 // Provides functionality to dismiss the previously displayed metro style 593 // Provides functionality to dismiss the previously displayed metro style
594 // dialog box. 594 // dialog box.
595 extern "C" __declspec(dllexport) 595 extern "C" __declspec(dllexport)
596 void DismissDialogBox() { 596 void DismissDialogBox() {
597 VLOG(1) << __FUNCTION__; 597 VLOG(1) << __FUNCTION__;
598 598
599 globals.appview_msg_loop->PostTask( 599 globals.appview_task_runner->PostTask(
600 FROM_HERE, base::Bind( 600 FROM_HERE, base::Bind(
601 &ChromeAppView::DismissDialogBox, 601 &ChromeAppView::DismissDialogBox,
602 globals.view)); 602 globals.view));
603 } 603 }
604 604
605 extern "C" __declspec(dllexport) 605 extern "C" __declspec(dllexport)
606 void SetFullscreen(bool fullscreen) { 606 void SetFullscreen(bool fullscreen) {
607 VLOG(1) << __FUNCTION__; 607 VLOG(1) << __FUNCTION__;
608 608
609 globals.appview_msg_loop->PostTask( 609 globals.appview_task_runner->PostTask(
610 FROM_HERE, base::Bind( 610 FROM_HERE, base::Bind(
611 &ChromeAppView::SetFullscreen, 611 &ChromeAppView::SetFullscreen,
612 globals.view, fullscreen)); 612 globals.view, fullscreen));
613 } 613 }
614 614
615 template <typename ContainerT> 615 template <typename ContainerT>
616 void CloseSecondaryWindows(ContainerT& windows) { 616 void CloseSecondaryWindows(ContainerT& windows) {
617 DVLOG(1) << "Closing secondary windows", windows.size(); 617 DVLOG(1) << "Closing secondary windows", windows.size();
618 std::for_each(windows.begin(), windows.end(), [](HWND hwnd) { 618 std::for_each(windows.begin(), windows.end(), [](HWND hwnd) {
619 ::PostMessageW(hwnd, WM_CLOSE, 0, 0); 619 ::PostMessageW(hwnd, WM_CLOSE, 0, 0);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 hr = window_->Activate(); 814 hr = window_->Activate();
815 if (SUCCEEDED(hr)) { 815 if (SUCCEEDED(hr)) {
816 // TODO(cpu): Draw something here. 816 // TODO(cpu): Draw something here.
817 } else { 817 } else {
818 DVLOG(1) << "Activate failed, hr=" << hr; 818 DVLOG(1) << "Activate failed, hr=" << hr;
819 } 819 }
820 820
821 // Create a message loop to allow message passing into this thread. 821 // Create a message loop to allow message passing into this thread.
822 base::MessageLoopForUI msg_loop; 822 base::MessageLoopForUI msg_loop;
823 823
824 // Announce our message loop to the world. 824 // Announce our message loop task runner to the world.
825 globals.appview_msg_loop = msg_loop.message_loop_proxy(); 825 globals.appview_task_runner = msg_loop.task_runner();
826 826
827 // And post the task that'll do the inner Metro message pumping to it. 827 // And post the task that'll do the inner Metro message pumping to it.
828 msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get())); 828 msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get()));
829 829
830 // Post the recurring task which checks for OSK activation in metro chrome. 830 // Post the recurring task which checks for OSK activation in metro chrome.
831 // Please refer to the comments in the CheckForOSKActivation function for why 831 // Please refer to the comments in the CheckForOSKActivation function for why
832 // this is needed. 832 // this is needed.
833 // TODO(ananta) 833 // TODO(ananta)
834 // Take this out when the documented OSK notifications start working. 834 // Take this out when the documented OSK notifications start working.
835 msg_loop.PostDelayedTask( 835 msg_loop.PostDelayedTask(
836 FROM_HERE, 836 FROM_HERE,
837 base::Bind(&ChromeAppView::CheckForOSKActivation, 837 base::Bind(&ChromeAppView::CheckForOSKActivation,
838 base::Unretained(this)), 838 base::Unretained(this)),
839 base::TimeDelta::FromMilliseconds(kCheckOSKDelayMs)); 839 base::TimeDelta::FromMilliseconds(kCheckOSKDelayMs));
840 840
841 msg_loop.Run(); 841 msg_loop.Run();
842 842
843 globals.appview_msg_loop = NULL; 843 globals.appview_task_runner = NULL;
844 844
845 DVLOG(0) << "ProcessEvents done, hr=" << hr; 845 DVLOG(0) << "ProcessEvents done, hr=" << hr;
846 846
847 // We join here with chrome's main thread so that the chrome is not killed 847 // We join here with chrome's main thread so that the chrome is not killed
848 // while a critical operation is still in progress. Now, if there are host 848 // while a critical operation is still in progress. Now, if there are host
849 // windows active it is possible we end up stuck on the wait below therefore 849 // windows active it is possible we end up stuck on the wait below therefore
850 // we tell chrome to close its windows. 850 // we tell chrome to close its windows.
851 if (!globals.host_windows.empty()) { 851 if (!globals.host_windows.empty()) {
852 DVLOG(1) << "Chrome still has windows open!"; 852 DVLOG(1) << "Chrome still has windows open!";
853 EndChromeSession(); 853 EndChromeSession();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 CheckHR(core_app.As(&app_exit)); 1207 CheckHR(core_app.As(&app_exit));
1208 globals.app_exit = app_exit.Detach(); 1208 globals.app_exit = app_exit.Detach();
1209 } 1209 }
1210 1210
1211 IFACEMETHODIMP 1211 IFACEMETHODIMP
1212 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) { 1212 ChromeAppViewFactory::CreateView(winapp::Core::IFrameworkView** view) {
1213 globals.view = mswr::Make<ChromeAppView>().Detach(); 1213 globals.view = mswr::Make<ChromeAppView>().Detach();
1214 *view = globals.view; 1214 *view = globals.view;
1215 return (*view) ? S_OK : E_OUTOFMEMORY; 1215 return (*view) ? S_OK : E_OUTOFMEMORY;
1216 } 1216 }
OLDNEW
« no previous file with comments | « win8/metro_driver/chrome_app_view.h ('k') | win8/metro_driver/chrome_app_view_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698