Index: content/public/browser/navigator_connect_service_factory.h |
diff --git a/content/browser/device_sensors/ambient_light_mac.h b/content/public/browser/navigator_connect_service_factory.h |
similarity index 14% |
copy from content/browser/device_sensors/ambient_light_mac.h |
copy to content/public/browser/navigator_connect_service_factory.h |
index 8d34e165b80bc6c26da60dec1084fd0872c69352..3c5851397a1a93deaa7d9891672fa45e7bad5f82 100644 |
--- a/content/browser/device_sensors/ambient_light_mac.h |
+++ b/content/public/browser/navigator_connect_service_factory.h |
@@ -2,39 +2,43 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_ |
-#define CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_ |
+#ifndef CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_SERVICE_FACTORY_H_ |
+#define CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_SERVICE_FACTORY_H_ |
-#include <IOKit/IOKitLib.h> |
+#include "base/callback.h" |
-#include "base/memory/scoped_ptr.h" |
+class GURL; |
namespace content { |
-// Provides an interface to retrieve ambient light data from MacBooks. |
-class AmbientLightSensor { |
- public: |
- // Create AmbientLightSensor object, return NULL if no valid is sensor found. |
- static scoped_ptr<AmbientLightSensor> Create(); |
- |
- ~AmbientLightSensor(); |
- |
- // Retrieve lux values from Ambient Light Sensor. |
- bool ReadSensorValue(uint64_t lux_value[2]); |
- |
- private: |
- AmbientLightSensor(); |
+struct NavigatorConnectClient; |
+class NavigatorConnectService; |
- // Probe the local hardware looking for Ambient Light sensor and |
- // initialize an I/O connection to it. |
- bool Init(); |
- |
- // IOKit connection to the local sensor. |
- io_connect_t io_connection_; |
- |
- DISALLOW_COPY_AND_ASSIGN(AmbientLightSensor); |
+// Implement this interface to provide a new kind of navigator.connect |
+// accessible service. |
+// Instances of this class are owned by NavigatorConnectContext. Register new |
+// factories by calling NavigatorConnectContext::AddFactory. |
+class NavigatorConnectServiceFactory { |
+ public: |
+ // Call with nullptr to indicate connection failure. Ownership of the service |
+ // passed to the callback is transfered. |
+ using ConnectCallback = |
+ base::Callback<void(scoped_ptr<NavigatorConnectService>)>; |
+ |
+ virtual ~NavigatorConnectServiceFactory() {} |
+ |
+ // Return true if this factory is responsible for handling connections to the |
+ // |target_url|. The most recently added factory that returns true for a |
+ // particular url is picked to handle the connection attempt. |
+ virtual bool HandlesUrl(const GURL& target_url) = 0; |
+ |
+ // Called to try to establish a connection. Only called if this factory was |
+ // the most recently added factory that returned true from |HandlesUrl| for |
+ // the url being connected to. |
+ virtual void Connect(const NavigatorConnectClient& client, |
+ const ConnectCallback& callback) = 0; |
}; |
} // namespace content |
-#endif // CONTENT_BROWSER_DEVICE_SENSORS_AMBIENT_LIGHT_MAC_H_ |
+#endif // CONTENT_PUBLIC_BROWSER_NAVIGATOR_CONNECT_SERVICE_FACTORY_H_ |