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

Side by Side Diff: content/shell/browser/layout_test/layout_test_bluetooth_chooser_factory.cc

Issue 1601323002: Use GetLastCommittedOrigin instead of GetLastCommittedURL in bluetooth chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed bluetooth test at: requestDevice.html Created 4 years, 10 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
OLDNEW
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/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "url/gurl.h" 9 #include "url/origin.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 class WebContents; 13 class WebContents;
14 14
15 // Implements a Bluetooth chooser that records events it's sent, instead of 15 // Implements a Bluetooth chooser that records events it's sent, instead of
16 // showing a dialog. It allows tests to control how the chooser responds. 16 // showing a dialog. It allows tests to control how the chooser responds.
17 class LayoutTestBluetoothChooserFactory::Chooser : public BluetoothChooser { 17 class LayoutTestBluetoothChooserFactory::Chooser : public BluetoothChooser {
18 public: 18 public:
19 Chooser(const base::WeakPtr<LayoutTestBluetoothChooserFactory>& factory, 19 Chooser(const base::WeakPtr<LayoutTestBluetoothChooserFactory>& factory,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 : weak_this_(this) {} 95 : weak_this_(this) {}
96 96
97 LayoutTestBluetoothChooserFactory::~LayoutTestBluetoothChooserFactory() { 97 LayoutTestBluetoothChooserFactory::~LayoutTestBluetoothChooserFactory() {
98 SendEvent(BluetoothChooser::Event::CANCELLED, ""); 98 SendEvent(BluetoothChooser::Event::CANCELLED, "");
99 } 99 }
100 100
101 scoped_ptr<BluetoothChooser> 101 scoped_ptr<BluetoothChooser>
102 LayoutTestBluetoothChooserFactory::RunBluetoothChooser( 102 LayoutTestBluetoothChooserFactory::RunBluetoothChooser(
103 WebContents* web_contents, 103 WebContents* web_contents,
104 const BluetoothChooser::EventHandler& event_handler, 104 const BluetoothChooser::EventHandler& event_handler,
105 const GURL& origin) { 105 const url::Origin& origin) {
106 DCHECK(!origin.unique());
106 std::string event = "chooser-opened("; 107 std::string event = "chooser-opened(";
107 event += origin.spec(); 108 event += origin.Serialize();
108 event += ")"; 109 event += ")";
109 events_.push_back(event); 110 events_.push_back(event);
110 return make_scoped_ptr(new Chooser(weak_this_.GetWeakPtr(), event_handler)); 111 return make_scoped_ptr(new Chooser(weak_this_.GetWeakPtr(), event_handler));
111 } 112 }
112 113
113 std::vector<std::string> 114 std::vector<std::string>
114 LayoutTestBluetoothChooserFactory::GetAndResetEvents() { 115 LayoutTestBluetoothChooserFactory::GetAndResetEvents() {
115 std::vector<std::string> result; 116 std::vector<std::string> result;
116 result.swap(events_); 117 result.swap(events_);
117 return result; 118 return result;
118 } 119 }
119 120
120 void LayoutTestBluetoothChooserFactory::SendEvent( 121 void LayoutTestBluetoothChooserFactory::SendEvent(
121 BluetoothChooser::Event event, 122 BluetoothChooser::Event event,
122 const std::string& device_id) { 123 const std::string& device_id) {
123 // Copy |choosers_| to make sure event handler executions that modify 124 // Copy |choosers_| to make sure event handler executions that modify
124 // |choosers_| don't invalidate iterators. 125 // |choosers_| don't invalidate iterators.
125 std::vector<Chooser*> choosers_copy(choosers_.begin(), choosers_.end()); 126 std::vector<Chooser*> choosers_copy(choosers_.begin(), choosers_.end());
126 for (Chooser* chooser : choosers_copy) { 127 for (Chooser* chooser : choosers_copy) {
127 chooser->event_handler.Run(event, device_id); 128 chooser->event_handler.Run(event, device_id);
128 } 129 }
129 } 130 }
130 131
131 } // namespace content 132 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/layout_test_bluetooth_chooser_factory.h ('k') | content/shell/browser/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698