1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_CHILD_NPAPI_URL_FETCHER_H_ 6 #define CONTENT_CHILD_NPAPI_URL_FETCHER_H_ 7 8 #include <string> 9 10 #include "base/memory/scoped_ptr.h" 11 #include "url/gurl.h" 12 #include "webkit/child/resource_loader_bridge.h" 13 14 namespace webkit_glue { 15 class MultipartResponseDelegate; 16 class ResourceLoaderBridge; 17 } 18 19 namespace content { 20 class PluginStreamUrl; 21 22 // Fetches URLS for a plugin using ResourceDispatcher. 23 class PluginURLFetcher : public webkit_glue::ResourceLoaderBridge::Peer { 24 public: 25 PluginURLFetcher(PluginStreamUrl* plugin_stream, 26 const GURL& url, 27 const GURL& first_party_for_cookies, 28 const std::string& method, 29 const char* buf, 30 unsigned int len, 31 const GURL& referrer, 32 bool notify_redirects, 33 bool is_plugin_src_load, 34 int origin_pid, 35 int render_view_id, 36 unsigned long resource_id, 37 bool copy_stream_data); 38 virtual ~PluginURLFetcher(); 39 40 // Cancels the current request. 41 void Cancel(); 42 43 // Called with the plugin's reply to NPP_URLRedirectNotify. 44 void URLRedirectResponse(bool allow); 45 46 bool pending_failure_notification() { return pending_failure_notification_; } 47 48 private: 49 // webkit_glue::ResourceLoaderBridge::Peer implementation: 50 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE; 51 virtual bool OnReceivedRedirect(const GURL& new_url, 52 const webkit_glue::ResourceResponseInfo& info, 53 bool* has_new_first_party_for_cookies, 54 GURL* new_first_party_for_cookies) OVERRIDE; 55 virtual void OnReceivedResponse( 56 const webkit_glue::ResourceResponseInfo& info) OVERRIDE; 57 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE; 58 virtual void OnReceivedData(const char* data, 59 int data_length, 60 int encoded_data_length) OVERRIDE; 61 virtual void OnCompletedRequest( 62 int error_code, 63 bool was_ignored_by_handler, 64 const std::string& security_info, 65 const base::TimeTicks& completion_time) OVERRIDE; 66 67 PluginStreamUrl* plugin_stream_; 68 GURL url_; 69 GURL first_party_for_cookies_; 70 std::string method_; 71 GURL referrer_; 72 bool notify_redirects_; 73 bool is_plugin_src_load_; 74 unsigned long resource_id_; 75 bool copy_stream_data_; 76 int64 data_offset_; 77 bool pending_failure_notification_; 78 79 scoped_ptr<webkit_glue::MultipartResponseDelegate> multipart_delegate_; 80 81 scoped_ptr<webkit_glue::ResourceLoaderBridge> bridge_; 82 83 DISALLOW_COPY_AND_ASSIGN(PluginURLFetcher); 84 }; 85 86 } // namespace content 87 88 #endif // CONTENT_CHILD_NPAPI_URL_FETCHER_H_ 89