plugin_url_fetcher.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
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 14namespace webkit_glue { 15class MultipartResponseDelegate; 16class ResourceLoaderBridge; 17} 18 19namespace content { 20class PluginStreamUrl; 21 22// Fetches URLS for a plugin using ResourceDispatcher. 23class 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 virtual ~PluginURLFetcher(); 38 39 // Cancels the current request. 40 void Cancel(); 41 42 // Called with the plugin's reply to NPP_URLRedirectNotify. 43 void URLRedirectResponse(bool allow); 44 45 bool pending_failure_notification() { return pending_failure_notification_; } 46 47 private: 48 // webkit_glue::ResourceLoaderBridge::Peer implementation: 49 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE; 50 virtual bool OnReceivedRedirect(const GURL& new_url, 51 const webkit_glue::ResourceResponseInfo& info, 52 bool* has_new_first_party_for_cookies, 53 GURL* new_first_party_for_cookies) OVERRIDE; 54 virtual void OnReceivedResponse( 55 const webkit_glue::ResourceResponseInfo& info) OVERRIDE; 56 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE; 57 virtual void OnReceivedData(const char* data, 58 int data_length, 59 int encoded_data_length) OVERRIDE; 60 virtual void OnCompletedRequest( 61 int error_code, 62 bool was_ignored_by_handler, 63 const std::string& security_info, 64 const base::TimeTicks& completion_time) OVERRIDE; 65 66 PluginStreamUrl* plugin_stream_; 67 GURL url_; 68 GURL first_party_for_cookies_; 69 std::string method_; 70 GURL referrer_; 71 bool notify_redirects_; 72 bool is_plugin_src_load_; 73 unsigned long resource_id_; 74 int64 data_offset_; 75 bool pending_failure_notification_; 76 77 scoped_ptr<webkit_glue::MultipartResponseDelegate> multipart_delegate_; 78 79 scoped_ptr<webkit_glue::ResourceLoaderBridge> bridge_; 80 81 DISALLOW_COPY_AND_ASSIGN(PluginURLFetcher); 82}; 83 84} // namespace content 85 86#endif // CONTENT_CHILD_NPAPI_URL_FETCHER_H_ 87