Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h

Issue 11348075: [Android WebView] AwContentsClient.shouldCreate window callback part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H _ 5 #ifndef ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H _
6 #define ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H _ 6 #define ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H _
7 7
8 #include <map>
9
10 #include "android_webview/browser/aw_contents_io_thread_client.h"
11 #include "base/lazy_instance.h"
12 #include "base/memory/ref_counted.h"
8 #include "content/public/browser/resource_dispatcher_host_delegate.h" 13 #include "content/public/browser/resource_dispatcher_host_delegate.h"
9 14 #include "content/public/browser/resource_throttle.h"
10 #include "base/lazy_instance.h"
11 15
12 namespace content { 16 namespace content {
13 class ResourceDispatcherHostLoginDelegate; 17 class ResourceDispatcherHostLoginDelegate;
14 } 18 }
15 19
16 namespace android_webview { 20 namespace android_webview {
17 21
22 // Calls through the IoThreadClient to check the embedders settings to determine
23 // if the request should be cancelled. There may not always be an IoThreadClient
24 // available for the |child_id|, |route_id| pair (in the case of newly created
25 // pop up windows, for example) and in that case the request and the client
26 // callbacks will be deferred the request until a client is ready.
27 class IoThreadClientThrottle
joth 2012/11/29 21:02:33 I think you can just forward declare this class he
benm (inactive) 2012/11/30 12:54:18 Done.
28 : public content::ResourceThrottle {
29 public:
30 IoThreadClientThrottle(int child_id,
31 int route_id,
32 net::URLRequest* request);
33 virtual ~IoThreadClientThrottle();
34
35 // From content::ResourceThrottle
36 virtual void WillStartRequest(bool* defer) OVERRIDE;
37 virtual void WillRedirectRequest(const GURL& new_url, bool* defer) OVERRIDE;
38
39 bool MaybeDeferRequest(bool* defer);
40 void OnIoThreadClientReady(int new_child_id, int new_route_id);
41 bool MaybeBlockRequest();
42 bool ShouldBlockRequest();
43 scoped_ptr<AwContentsIoThreadClient> GetIoThreadClient();
44
45 private:
46 int child_id_;
47 int route_id_;
48 net::URLRequest* request_;
49 };
50
18 class AwResourceDispatcherHostDelegate 51 class AwResourceDispatcherHostDelegate
19 : public content::ResourceDispatcherHostDelegate { 52 : public content::ResourceDispatcherHostDelegate {
20 public: 53 public:
21 static void ResourceDispatcherHostCreated(); 54 static void ResourceDispatcherHostCreated();
22 55
23 // Overriden methods from ResourceDispatcherHostDelegate. 56 // Overriden methods from ResourceDispatcherHostDelegate.
24 virtual void RequestBeginning( 57 virtual void RequestBeginning(
25 net::URLRequest* request, 58 net::URLRequest* request,
26 content::ResourceContext* resource_context, 59 content::ResourceContext* resource_context,
27 appcache::AppCacheService* appcache_service, 60 appcache::AppCacheService* appcache_service,
28 ResourceType::Type resource_type, 61 ResourceType::Type resource_type,
29 int child_id, 62 int child_id,
30 int route_id, 63 int route_id,
31 bool is_continuation_of_transferred_request, 64 bool is_continuation_of_transferred_request,
32 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE; 65 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
33 66
34 virtual bool AcceptAuthRequest(net::URLRequest* request, 67 virtual bool AcceptAuthRequest(net::URLRequest* request,
35 net::AuthChallengeInfo* auth_info) OVERRIDE; 68 net::AuthChallengeInfo* auth_info) OVERRIDE;
36 69
37 virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( 70 virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
38 net::AuthChallengeInfo* auth_info, 71 net::AuthChallengeInfo* auth_info,
39 net::URLRequest* request) OVERRIDE; 72 net::URLRequest* request) OVERRIDE;
40 73
41 virtual bool HandleExternalProtocol(const GURL& url, 74 virtual bool HandleExternalProtocol(const GURL& url,
42 int child_id, 75 int child_id,
43 int route_id) OVERRIDE; 76 int route_id) OVERRIDE;
44 77
78 static void OnIoThreadClientReady(int new_child_id, int new_route_id);
79 static void AddPendingThrottle(int child_id,
80 int route_id,
81 IoThreadClientThrottle* pending_throttle);
82
45 private: 83 private:
46 friend struct base::DefaultLazyInstanceTraits< 84 friend struct base::DefaultLazyInstanceTraits<
47 AwResourceDispatcherHostDelegate>; 85 AwResourceDispatcherHostDelegate>;
48 AwResourceDispatcherHostDelegate(); 86 AwResourceDispatcherHostDelegate();
49 virtual ~AwResourceDispatcherHostDelegate(); 87 virtual ~AwResourceDispatcherHostDelegate();
50 88
89 typedef std::pair<int, int> ChildRouteIDPair;
90 typedef std::map<ChildRouteIDPair, IoThreadClientThrottle*>
91 PendingThrottleMap;
92
93 static PendingThrottleMap* pending_throttles_;
joth 2012/11/29 21:02:33 no need for this to be static, make it a straight
benm (inactive) 2012/11/30 12:54:18 Done.
94
51 DISALLOW_COPY_AND_ASSIGN(AwResourceDispatcherHostDelegate); 95 DISALLOW_COPY_AND_ASSIGN(AwResourceDispatcherHostDelegate);
52 }; 96 };
53 97
54 } // namespace android_webview 98 } // namespace android_webview
55 99
56 #endif // ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_H_ 100 #endif // ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698