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