diff options
author | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 05:11:58 +0000 |
---|---|---|
committer | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 05:11:58 +0000 |
commit | f781782dd67077478e117c61dca4ea5eefce3544 (patch) | |
tree | 4801f724123cfdcbb69c4e7fe40a565b331723ae /chrome_frame/plugin_url_request.h | |
parent | 63cf4759efa2373e33436fb5df6849f930081226 (diff) | |
download | chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.zip chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.tar.gz chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.tar.bz2 |
Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming in a separate CL.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/218019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27042 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/plugin_url_request.h')
-rw-r--r-- | chrome_frame/plugin_url_request.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h new file mode 100644 index 0000000..fb28c77 --- /dev/null +++ b/chrome_frame/plugin_url_request.h @@ -0,0 +1,114 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_FRAME_PLUGIN_URL_REQUEST_H_ +#define CHROME_FRAME_PLUGIN_URL_REQUEST_H_ + +#include <string> +#include <vector> + +#include "base/time.h" +#include "ipc/ipc_message.h" +#include "net/base/upload_data.h" +#include "net/url_request/url_request_status.h" +#include "base/ref_counted.h" + +class PluginUrlRequest; + +// Interface for a class that keeps a collection of outstanding +// reqeusts and offers an outgoing channel. +class PluginRequestHandler : public IPC::Message::Sender { + public: + virtual bool AddRequest(PluginUrlRequest* request) = 0; + virtual void RemoveRequest(PluginUrlRequest* request) = 0; +}; + +// A reference counting solution that's compatible with COM IUnknown +class UrlRequestReference { + public: + virtual unsigned long API_CALL AddRef() = 0; + virtual unsigned long API_CALL Release() = 0; +}; + +class PluginUrlRequest : public UrlRequestReference { + public: + PluginUrlRequest(); + ~PluginUrlRequest(); + + bool Initialize(PluginRequestHandler* handler, int tab, + int remote_request_id, const std::string& url, + const std::string& method, const std::string& referrer, + const std::string& extra_headers, + net::UploadData* upload_data, + bool intercept_frame_options); + + // Called in response to automation IPCs + virtual bool Start() = 0; + virtual void Stop() = 0; + virtual bool Read(int bytes_to_read) = 0; + + // Persistent cookies are read from the host browser and passed off to Chrome + // These cookies are sent when we receive a response for every URL request + // initiated by Chrome. Ideally we should only send cookies for the top level + // URL and any subframes. However we don't receive information from Chrome + // about the context for a URL, i.e. whether it is a subframe, etc. + // Additionally cookies for a URL should be sent once for the page. This + // is not done now as it is difficult to track URLs, specifically if they + // are redirected, etc. + void OnResponseStarted(const char* mime_type, const char* headers, int size, + base::Time last_modified, const std::string& peristent_cookies, + const std::string& redirect_url, int redirect_status); + + void OnReadComplete(const void* buffer, int len); + void OnResponseEnd(const URLRequestStatus& status); + + PluginRequestHandler* request_handler() const { + return request_handler_; + } + int id() const { + return remote_request_id_; + } + const std::string& url() const { + return url_; + } + const std::string& method() const { + return method_; + } + const std::string& referrer() const { + return referrer_; + } + const std::string& extra_headers() const { + return extra_headers_; + } + scoped_refptr<net::UploadData> upload_data() { + return upload_data_; + } + + bool is_done() const { + return (URLRequestStatus::IO_PENDING != status_); + } + + void set_url(const std::string& url) { + url_ = url; + } + + protected: + void SendData(); + bool frame_busting_enabled_; + + private: + PluginRequestHandler* request_handler_; + int tab_; + int remote_request_id_; + std::string url_; + std::string method_; + std::string referrer_; + std::string extra_headers_; + scoped_refptr<net::UploadData> upload_data_; + URLRequestStatus::Status status_; +}; + + +#endif // CHROME_FRAME_PLUGIN_URL_REQUEST_H_ + |