OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/layout_test/layout_test_bluetooth_chooser_factor
y.h" | 5 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 LayoutTestBluetoothChooserFactory::LayoutTestBluetoothChooserFactory() | 100 LayoutTestBluetoothChooserFactory::LayoutTestBluetoothChooserFactory() |
101 : weak_this_(this) {} | 101 : weak_this_(this) {} |
102 | 102 |
103 LayoutTestBluetoothChooserFactory::~LayoutTestBluetoothChooserFactory() { | 103 LayoutTestBluetoothChooserFactory::~LayoutTestBluetoothChooserFactory() { |
104 SendEvent(BluetoothChooser::Event::CANCELLED, ""); | 104 SendEvent(BluetoothChooser::Event::CANCELLED, ""); |
105 } | 105 } |
106 | 106 |
107 std::unique_ptr<BluetoothChooser> | 107 std::unique_ptr<BluetoothChooser> |
108 LayoutTestBluetoothChooserFactory::RunBluetoothChooser( | 108 LayoutTestBluetoothChooserFactory::RunBluetoothChooser( |
109 RenderFrameHost* frame, | 109 RenderFrameHost* frame, |
110 const BluetoothChooser::EventHandler& event_handler) { | 110 const BluetoothChooser::EventHandler& event_handler, |
| 111 bool accept_all_devices) { |
111 const url::Origin origin = frame->GetLastCommittedOrigin(); | 112 const url::Origin origin = frame->GetLastCommittedOrigin(); |
112 DCHECK(!origin.unique()); | 113 DCHECK(!origin.unique()); |
113 std::string event = "chooser-opened("; | 114 std::string event = "chooser-opened("; |
114 event += origin.Serialize(); | 115 event += origin.Serialize(); |
115 event += ")"; | 116 event += ")"; |
116 events_.push_back(event); | 117 events_.push_back(event); |
117 return base::MakeUnique<Chooser>(weak_this_.GetWeakPtr(), event_handler); | 118 return base::MakeUnique<Chooser>(weak_this_.GetWeakPtr(), event_handler); |
118 } | 119 } |
119 | 120 |
120 std::vector<std::string> | 121 std::vector<std::string> |
121 LayoutTestBluetoothChooserFactory::GetAndResetEvents() { | 122 LayoutTestBluetoothChooserFactory::GetAndResetEvents() { |
122 std::vector<std::string> result; | 123 std::vector<std::string> result; |
123 result.swap(events_); | 124 result.swap(events_); |
124 return result; | 125 return result; |
125 } | 126 } |
126 | 127 |
127 void LayoutTestBluetoothChooserFactory::SendEvent( | 128 void LayoutTestBluetoothChooserFactory::SendEvent( |
128 BluetoothChooser::Event event, | 129 BluetoothChooser::Event event, |
129 const std::string& device_id) { | 130 const std::string& device_id) { |
130 // Copy |choosers_| to make sure event handler executions that modify | 131 // Copy |choosers_| to make sure event handler executions that modify |
131 // |choosers_| don't invalidate iterators. | 132 // |choosers_| don't invalidate iterators. |
132 std::vector<Chooser*> choosers_copy(choosers_.begin(), choosers_.end()); | 133 std::vector<Chooser*> choosers_copy(choosers_.begin(), choosers_.end()); |
133 for (Chooser* chooser : choosers_copy) { | 134 for (Chooser* chooser : choosers_copy) { |
134 chooser->event_handler.Run(event, device_id); | 135 chooser->event_handler.Run(event, device_id); |
135 } | 136 } |
136 } | 137 } |
137 | 138 |
138 } // namespace content | 139 } // namespace content |
OLD | NEW |