| Index: webkit/chaos/GeolocationPowerbox.h
|
| ===================================================================
|
| --- webkit/chaos/GeolocationPowerbox.h (revision 0)
|
| +++ webkit/chaos/GeolocationPowerbox.h (revision 0)
|
| @@ -0,0 +1,79 @@
|
| +#ifndef GeolocationPowerbox_h
|
| +#define GeolocationPowerbox_h
|
| +
|
| +#include <functional>
|
| +#include <map>
|
| +#include <vector>
|
| +#include "googleurl/src/gurl.h"
|
| +
|
| +namespace WebCore {
|
| +class ChaosGeolocation;
|
| +class ChooseGeolocationProvider;
|
| +
|
| +// This class should only be used in the renderer process
|
| +class GeolocationPowerbox {
|
| + public:
|
| + static WebCore::ChooseGeolocationProvider *choose(
|
| + WebCore::ChaosGeolocation *geolocation);
|
| +
|
| + // FIXME(benl): probably should be a dynamic list some day.
|
| + // FIXME(benl): move out of this class, since it is shared across
|
| + // processes.
|
| + enum ProviderId {
|
| + NO_PROVIDER_FOUND, // only used to indicate failure
|
| + EXACT,
|
| + CITY,
|
| + NONE
|
| + };
|
| + // FIXME(benl): lazy lazy lazy
|
| + static const char *decisionAsString(GeolocationPowerbox::ProviderId id) {
|
| + switch(id) {
|
| + case EXACT: return "exact location";
|
| + case CITY: return "rough location";
|
| + case NONE: return "no location";
|
| + case NO_PROVIDER_FOUND: return "ARG YOU SHOULD NOT SEE THIS!";
|
| + }
|
| + return NULL;
|
| + }
|
| +};
|
| +
|
| +// This class should only be used in the browser process
|
| +class GeolocationBrowserPowerbox {
|
| + public:
|
| + typedef std::pair<GURL, GeolocationPowerbox::ProviderId> DecisionPair;
|
| +
|
| + void addDecision(const GURL &gurl,
|
| + GeolocationPowerbox::ProviderId provider_id) {
|
| + decisions_[gurl] = provider_id;
|
| + }
|
| + void deleteDecision(const GURL &gurl) {
|
| + decisions_.erase(gurl);
|
| + }
|
| + GeolocationPowerbox::ProviderId findDecision(const GURL &gurl) const {
|
| + GURLMap::const_iterator found = decisions_.find(gurl);
|
| + if (found == decisions_.end())
|
| + return GeolocationPowerbox::NO_PROVIDER_FOUND;
|
| + return found->second;
|
| + }
|
| + static const DecisionPair identity(const DecisionPair &pair) {
|
| + return pair;
|
| + }
|
| + std::vector<DecisionPair> decisions() const {
|
| + std::vector<DecisionPair> result;
|
| +
|
| + std::transform(decisions_.begin(), decisions_.end(),
|
| + std::back_inserter(result), identity);
|
| + return result;
|
| + }
|
| + static const char *decisionAsString(GeolocationPowerbox::ProviderId id) {
|
| + return GeolocationPowerbox::decisionAsString(id);
|
| + }
|
| + static GeolocationBrowserPowerbox powerbox;
|
| + private:
|
| + typedef std::map<GURL, GeolocationPowerbox::ProviderId> GURLMap;
|
| + GURLMap decisions_;
|
| +};
|
| +} // namespace WebCore
|
| +
|
| +
|
| +#endif // ndef GeolocationPowerbox_h
|
|
|
| Property changes on: webkit/chaos/GeolocationPowerbox.h
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|