Update broken references to image assets
[chromium-blink-merge.git] / content / public / browser / navigator_connect_service_factory.h
blob4a71f27b80133114c245afda557e86ff81389711
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_SERVICE_FACTORY_H_
6 #define CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_SERVICE_FACTORY_H_
8 #include "base/callback.h"
10 class GURL;
12 namespace content {
14 struct NavigatorConnectClient;
15 class MessagePortDelegate;
17 // Implement this interface to provide a new kind of navigator.connect
18 // accessible service.
19 // Instances of this class are owned by NavigatorConnectContext. Register new
20 // factories by calling NavigatorConnectContext::AddFactory.
21 class NavigatorConnectServiceFactory {
22 public:
23 // Call with nullptr to indicate connection failure. Ownership of the delegate
24 // remains with the factory. It is assumed that for the passed
25 // MessagePortDelegate implementation the route_id and message_port_id of a
26 // connection are the same.
27 // Pass true to |data_as_values| if the delegate expects to receive messages
28 // from the client encoded as base::Value instead of the normal serialization
29 // format.
30 using ConnectCallback =
31 base::Callback<void(MessagePortDelegate*, bool data_as_values)>;
33 virtual ~NavigatorConnectServiceFactory() {}
35 // Return true if this factory is responsible for handling connections to the
36 // |target_url|. The most recently added factory that returns true for a
37 // particular url is picked to handle the connection attempt.
38 virtual bool HandlesUrl(const GURL& target_url) = 0;
40 // Called to try to establish a connection. Only called if this factory was
41 // the most recently added factory that returned true from |HandlesUrl| for
42 // the url being connected to.
43 virtual void Connect(const NavigatorConnectClient& client,
44 const ConnectCallback& callback) = 0;
47 } // namespace content
49 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_SERVICE_FACTORY_H_