OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/blink_test_controller.h" | 5 #include "content/shell/browser/blink_test_controller.h" |
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
25 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/render_widget_host_view.h" | 26 #include "content/public/browser/render_widget_host_view.h" |
27 #include "content/public/browser/storage_partition.h" | 27 #include "content/public/browser/storage_partition.h" |
28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
29 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
30 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
| 31 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" |
31 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" | 32 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" |
32 #include "content/shell/browser/shell.h" | 33 #include "content/shell/browser/shell.h" |
33 #include "content/shell/browser/shell_browser_context.h" | 34 #include "content/shell/browser/shell_browser_context.h" |
34 #include "content/shell/browser/shell_content_browser_client.h" | 35 #include "content/shell/browser/shell_content_browser_client.h" |
35 #include "content/shell/browser/shell_devtools_frontend.h" | 36 #include "content/shell/browser/shell_devtools_frontend.h" |
36 #include "content/shell/common/shell_messages.h" | 37 #include "content/shell/common/shell_messages.h" |
37 #include "content/shell/common/shell_switches.h" | 38 #include "content/shell/common/shell_switches.h" |
38 #include "content/shell/renderer/layout_test/blink_test_helpers.h" | 39 #include "content/shell/renderer/layout_test/blink_test_helpers.h" |
39 #include "ui/gfx/codec/png_codec.h" | 40 #include "ui/gfx/codec/png_codec.h" |
40 | 41 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 RenderViewHost* render_view_host = | 355 RenderViewHost* render_view_host = |
355 main_window_->web_contents()->GetRenderViewHost(); | 356 main_window_->web_contents()->GetRenderViewHost(); |
356 render_view_host->Send( | 357 render_view_host->Send( |
357 new ShellViewMsg_NotifyDone(render_view_host->GetRoutingID())); | 358 new ShellViewMsg_NotifyDone(render_view_host->GetRoutingID())); |
358 } | 359 } |
359 | 360 |
360 bool BlinkTestController::IsMainWindow(WebContents* web_contents) const { | 361 bool BlinkTestController::IsMainWindow(WebContents* web_contents) const { |
361 return main_window_ && web_contents == main_window_->web_contents(); | 362 return main_window_ && web_contents == main_window_->web_contents(); |
362 } | 363 } |
363 | 364 |
| 365 scoped_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser( |
| 366 WebContents* web_contents, |
| 367 const BluetoothChooser::EventHandler& event_handler, |
| 368 const GURL& origin) { |
| 369 if (bluetooth_chooser_factory_) { |
| 370 return bluetooth_chooser_factory_->RunBluetoothChooser( |
| 371 web_contents, event_handler, origin); |
| 372 } |
| 373 return nullptr; |
| 374 } |
| 375 |
364 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { | 376 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { |
365 DCHECK(CalledOnValidThread()); | 377 DCHECK(CalledOnValidThread()); |
366 bool handled = true; | 378 bool handled = true; |
367 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message) | 379 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message) |
368 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) | 380 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) |
369 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) | 381 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) |
370 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) | 382 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) |
371 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump) | 383 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump) |
372 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences, | 384 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences, |
373 OnOverridePreferences) | 385 OnOverridePreferences) |
374 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished) | 386 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished) |
375 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage, | 387 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage, |
376 OnClearDevToolsLocalStorage) | 388 OnClearDevToolsLocalStorage) |
377 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools) | 389 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools) |
378 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools) | 390 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools) |
379 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset) | 391 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset) |
380 IPC_MESSAGE_HANDLER(ShellViewHostMsg_Reload, OnReload) | 392 IPC_MESSAGE_HANDLER(ShellViewHostMsg_Reload, OnReload) |
381 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LoadURLForFrame, OnLoadURLForFrame) | 393 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LoadURLForFrame, OnLoadURLForFrame) |
382 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CaptureSessionHistory, | 394 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CaptureSessionHistory, |
383 OnCaptureSessionHistory) | 395 OnCaptureSessionHistory) |
384 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows, | 396 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseRemainingWindows, |
385 OnCloseRemainingWindows) | 397 OnCloseRemainingWindows) |
386 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone) | 398 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone) |
387 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone) | 399 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone) |
| 400 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetBluetoothManualChooser, |
| 401 OnSetBluetoothManualChooser) |
| 402 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GetBluetoothManualChooserEvents, |
| 403 OnGetBluetoothManualChooserEvents) |
| 404 IPC_MESSAGE_HANDLER(ShellViewHostMsg_SendBluetoothManualChooserEvent, |
| 405 OnSendBluetoothManualChooserEvent) |
388 IPC_MESSAGE_UNHANDLED(handled = false) | 406 IPC_MESSAGE_UNHANDLED(handled = false) |
389 IPC_END_MESSAGE_MAP() | 407 IPC_END_MESSAGE_MAP() |
390 | 408 |
391 return handled; | 409 return handled; |
392 } | 410 } |
393 | 411 |
394 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, | 412 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, |
395 base::ProcessId plugin_pid) { | 413 base::ProcessId plugin_pid) { |
396 DCHECK(CalledOnValidThread()); | 414 DCHECK(CalledOnValidThread()); |
397 printer_->AddErrorMessage( | 415 printer_->AddErrorMessage( |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 707 } |
690 | 708 |
691 printer_->AddErrorMessage( | 709 printer_->AddErrorMessage( |
692 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, | 710 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, |
693 result.detail.c_str())); | 711 result.detail.c_str())); |
694 CHECK(!crash_when_leak_found_); | 712 CHECK(!crash_when_leak_found_); |
695 | 713 |
696 DiscardMainWindow(); | 714 DiscardMainWindow(); |
697 } | 715 } |
698 | 716 |
| 717 void BlinkTestController::OnSetBluetoothManualChooser(bool enable) { |
| 718 bluetooth_chooser_factory_.reset(); |
| 719 if (enable) { |
| 720 bluetooth_chooser_factory_.reset(new LayoutTestBluetoothChooserFactory()); |
| 721 } |
| 722 } |
| 723 |
| 724 void BlinkTestController::OnGetBluetoothManualChooserEvents( |
| 725 std::vector<std::string>* events) { |
| 726 if (!bluetooth_chooser_factory_) { |
| 727 printer_->AddErrorMessage( |
| 728 "FAIL: Must call setBluetoothManualChooser before " |
| 729 "getBluetoothManualChooserEvents."); |
| 730 return; |
| 731 } |
| 732 *events = bluetooth_chooser_factory_->GetAndResetEvents(); |
| 733 } |
| 734 |
| 735 void BlinkTestController::OnSendBluetoothManualChooserEvent( |
| 736 const std::string& event_name, |
| 737 const std::string& argument) { |
| 738 if (!bluetooth_chooser_factory_) { |
| 739 printer_->AddErrorMessage( |
| 740 "FAIL: Must call setBluetoothManualChooser before " |
| 741 "sendBluetoothManualChooserEvent."); |
| 742 return; |
| 743 } |
| 744 BluetoothChooser::Event event; |
| 745 if (event_name == "cancelled") { |
| 746 event = BluetoothChooser::Event::CANCELLED; |
| 747 } else if (event_name == "selected") { |
| 748 event = BluetoothChooser::Event::SELECTED; |
| 749 } else { |
| 750 printer_->AddErrorMessage(base::StringPrintf( |
| 751 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", |
| 752 event_name.c_str())); |
| 753 return; |
| 754 } |
| 755 bluetooth_chooser_factory_->SendEvent(event, argument); |
| 756 } |
| 757 |
699 } // namespace content | 758 } // namespace content |
OLD | NEW |