| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef ANDROID_WEBVIEW_NATIVE_PERMISSION_PERMISSION_REQUEST_HANDLER_H | 5 #ifndef ANDROID_WEBVIEW_NATIVE_PERMISSION_PERMISSION_REQUEST_HANDLER_H |
| 6 #define ANDROID_WEBVIEW_NATIVE_PERMISSION_PERMISSION_REQUEST_HANDLER_H | 6 #define ANDROID_WEBVIEW_NATIVE_PERMISSION_PERMISSION_REQUEST_HANDLER_H |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace android_webview { | 16 namespace android_webview { |
| 17 | 17 |
| 18 class AwPermissionRequest; | 18 class AwPermissionRequest; |
| 19 class AwPermissionRequestDelegate; | 19 class AwPermissionRequestDelegate; |
| 20 class PermissionRequestHandlerClient; | 20 class PermissionRequestHandlerClient; |
| 21 | 21 |
| 22 // This class is used to send the permission requests, or cancel ongoing | 22 // This class is used to send the permission requests, or cancel ongoing |
| 23 // requests. | 23 // requests. |
| 24 // It is owned by AwContents and has 1x1 mapping to AwContents. All methods | 24 // It is owned by AwContents and has 1x1 mapping to AwContents. All methods |
| 25 // are running on UI thread. | 25 // are running on UI thread. |
| 26 class PermissionRequestHandler : public content::WebContentsObserver { | 26 class PermissionRequestHandler : public content::WebContentsObserver { |
| 27 public: | 27 public: |
| 28 PermissionRequestHandler(PermissionRequestHandlerClient* client, | 28 PermissionRequestHandler(PermissionRequestHandlerClient* client, |
| 29 content::WebContents* aw_contents); | 29 content::WebContents* aw_contents); |
| 30 virtual ~PermissionRequestHandler(); | 30 ~PermissionRequestHandler() override; |
| 31 | 31 |
| 32 // Send the given |request| to PermissionRequestHandlerClient. | 32 // Send the given |request| to PermissionRequestHandlerClient. |
| 33 void SendRequest(scoped_ptr<AwPermissionRequestDelegate> request); | 33 void SendRequest(scoped_ptr<AwPermissionRequestDelegate> request); |
| 34 | 34 |
| 35 // Cancel the ongoing request initiated by |origin| for accessing |resources|. | 35 // Cancel the ongoing request initiated by |origin| for accessing |resources|. |
| 36 void CancelRequest(const GURL& origin, int64 resources); | 36 void CancelRequest(const GURL& origin, int64 resources); |
| 37 | 37 |
| 38 // Allow |origin| to access the |resources|. | 38 // Allow |origin| to access the |resources|. |
| 39 void PreauthorizePermission(const GURL& origin, int64 resources); | 39 void PreauthorizePermission(const GURL& origin, int64 resources); |
| 40 | 40 |
| 41 // WebContentsObserver | 41 // WebContentsObserver |
| 42 virtual void NavigationEntryCommitted( | 42 void NavigationEntryCommitted( |
| 43 const content::LoadCommittedDetails& load_details) override; | 43 const content::LoadCommittedDetails& load_details) override; |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 friend class TestPermissionRequestHandler; | 46 friend class TestPermissionRequestHandler; |
| 47 | 47 |
| 48 typedef std::vector<base::WeakPtr<AwPermissionRequest> >::iterator | 48 typedef std::vector<base::WeakPtr<AwPermissionRequest> >::iterator |
| 49 RequestIterator; | 49 RequestIterator; |
| 50 | 50 |
| 51 // Return the request initiated by |origin| for accessing |resources|. | 51 // Return the request initiated by |origin| for accessing |resources|. |
| 52 RequestIterator FindRequest(const GURL& origin, int64 resources); | 52 RequestIterator FindRequest(const GURL& origin, int64 resources); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 72 // The unique id of the active NavigationEntry of the WebContents that we were | 72 // The unique id of the active NavigationEntry of the WebContents that we were |
| 73 // opened for. Used to help expire on requests. | 73 // opened for. Used to help expire on requests. |
| 74 int contents_unique_id_; | 74 int contents_unique_id_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(PermissionRequestHandler); | 76 DISALLOW_COPY_AND_ASSIGN(PermissionRequestHandler); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace android_webivew | 79 } // namespace android_webivew |
| 80 | 80 |
| 81 #endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_PERMISSION_REQUEST_HANDLER_H | 81 #endif // ANDROID_WEBVIEW_NATIVE_PERMISSION_PERMISSION_REQUEST_HANDLER_H |
| OLD | NEW |