1f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch/*
2f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Copyright (C) 2010 Google Inc. All rights reserved.
3f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch *
4f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * Redistribution and use in source and binary forms, with or without
5f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * modification, are permitted provided that the following conditions
6f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * are met:
7f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch *
8f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 1.  Redistributions of source code must retain the above copyright
9f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch *     notice, this list of conditions and the following disclaimer.
10f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * 2.  Redistributions in binary form must reproduce the above copyright
11f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch *     notice, this list of conditions and the following disclaimer in the
12f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch *     documentation and/or other materials provided with the distribution.
13f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch *
14f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch */
25f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
26f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#ifndef WebGeolocationPermissionRequestManager_h
27f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#define WebGeolocationPermissionRequestManager_h
28f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
29f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "WebNonCopyable.h"
30f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#include "WebPrivateOwnPtr.h"
31f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
32f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochnamespace WebKit {
33f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
34f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochclass WebGeolocationPermissionRequest;
35f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochclass WebGeolocationPermissionRequestManagerPrivate;
36f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
37f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch// This class is used to map between integer identifiers and WebGeolocationPermissionRequest
38f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch// instances. The intended usage is that on WebGeolocationClient::requestPermission(),
39f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch// the implementer can call add() to associate an id with the WebGeolocationPermissionRequest object.
40f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch// Once the permission request has been decided, the second remove() method can be used to
41f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch// find the request. On WebGeolocationClient::cancelPermissionRequest, the first remove() method will
42f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch// remove the association with the id.
43f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochclass WebGeolocationPermissionRequestManager : public WebNonCopyable {
44f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochpublic:
45f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    WebGeolocationPermissionRequestManager() { init(); }
46f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    ~WebGeolocationPermissionRequestManager() { reset(); }
47f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
48f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    WEBKIT_API int add(const WebKit::WebGeolocationPermissionRequest&);
49f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    WEBKIT_API bool remove(const WebKit::WebGeolocationPermissionRequest&, int&);
50f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    WEBKIT_API bool remove(int, WebKit::WebGeolocationPermissionRequest&);
51f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
52f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochprivate:
53f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    WEBKIT_API void init();
54f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    WEBKIT_API void reset();
55f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
56f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    WebPrivateOwnPtr<WebGeolocationPermissionRequestManagerPrivate> m_private;
57f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch    int m_lastId;
58f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch};
59f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
60f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch}
61f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
62f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch#endif // WebGeolocationPermissionRequestManager_h
63f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch
64