| Index: content/shell/browser/blink_test_controller.cc
|
| diff --git a/content/shell/browser/blink_test_controller.cc b/content/shell/browser/blink_test_controller.cc
|
| index b43a1ea01a33568315159eb0ed0e5ec5f4dea277..ce60164dc09148ade63ab93c71a65c25f661ff52 100644
|
| --- a/content/shell/browser/blink_test_controller.cc
|
| +++ b/content/shell/browser/blink_test_controller.cc
|
| @@ -28,6 +28,7 @@
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/common/url_constants.h"
|
| +#include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factory.h"
|
| #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h"
|
| #include "content/shell/browser/shell.h"
|
| #include "content/shell/browser/shell_browser_context.h"
|
| @@ -361,6 +362,17 @@ bool BlinkTestController::IsMainWindow(WebContents* web_contents) const {
|
| return main_window_ && web_contents == main_window_->web_contents();
|
| }
|
|
|
| +scoped_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser(
|
| + WebContents* web_contents,
|
| + const BluetoothChooser::EventHandler& event_handler,
|
| + const GURL& origin) {
|
| + if (bluetooth_chooser_factory_) {
|
| + return bluetooth_chooser_factory_->RunBluetoothChooser(
|
| + web_contents, event_handler, origin);
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
|
| DCHECK(CalledOnValidThread());
|
| bool handled = true;
|
| @@ -385,6 +397,12 @@ bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
|
| OnCloseRemainingWindows)
|
| IPC_MESSAGE_HANDLER(ShellViewHostMsg_ResetDone, OnResetDone)
|
| IPC_MESSAGE_HANDLER(ShellViewHostMsg_LeakDetectionDone, OnLeakDetectionDone)
|
| + IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetBluetoothManualChooser,
|
| + OnSetBluetoothManualChooser)
|
| + IPC_MESSAGE_HANDLER(ShellViewHostMsg_GetBluetoothManualChooserEvents,
|
| + OnGetBluetoothManualChooserEvents)
|
| + IPC_MESSAGE_HANDLER(ShellViewHostMsg_SendBluetoothManualChooserEvent,
|
| + OnSendBluetoothManualChooserEvent)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
|
|
| @@ -696,4 +714,45 @@ void BlinkTestController::OnLeakDetectionDone(
|
| DiscardMainWindow();
|
| }
|
|
|
| +void BlinkTestController::OnSetBluetoothManualChooser(bool enable) {
|
| + bluetooth_chooser_factory_.reset();
|
| + if (enable) {
|
| + bluetooth_chooser_factory_.reset(new LayoutTestBluetoothChooserFactory());
|
| + }
|
| +}
|
| +
|
| +void BlinkTestController::OnGetBluetoothManualChooserEvents(
|
| + std::vector<std::string>* events) {
|
| + if (!bluetooth_chooser_factory_) {
|
| + printer_->AddErrorMessage(
|
| + "FAIL: Must call setBluetoothManualChooser before "
|
| + "getBluetoothManualChooserEvents.");
|
| + return;
|
| + }
|
| + *events = bluetooth_chooser_factory_->GetAndResetEvents();
|
| +}
|
| +
|
| +void BlinkTestController::OnSendBluetoothManualChooserEvent(
|
| + const std::string& event_name,
|
| + const std::string& argument) {
|
| + if (!bluetooth_chooser_factory_) {
|
| + printer_->AddErrorMessage(
|
| + "FAIL: Must call setBluetoothManualChooser before "
|
| + "sendBluetoothManualChooserEvent.");
|
| + return;
|
| + }
|
| + BluetoothChooser::Event event;
|
| + if (event_name == "cancelled") {
|
| + event = BluetoothChooser::Event::CANCELLED;
|
| + } else if (event_name == "selected") {
|
| + event = BluetoothChooser::Event::SELECTED;
|
| + } else {
|
| + printer_->AddErrorMessage(base::StringPrintf(
|
| + "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.",
|
| + event_name.c_str()));
|
| + return;
|
| + }
|
| + bluetooth_chooser_factory_->SendEvent(event, argument);
|
| +}
|
| +
|
| } // namespace content
|
|
|