blob: 3c29c738a156457178df56cae4a08039d9255433 [file] [log] [blame]
[email protected]f7817822009-09-24 05:11:581// Copyright (c) 2009 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 CHROME_FRAME_NPAPI_URL_REQUEST_H_
6#define CHROME_FRAME_NPAPI_URL_REQUEST_H_
7
[email protected]3eb07da2010-02-01 19:48:368#include <map>
[email protected]7ae80742010-03-25 22:02:279#include <string>
[email protected]3eb07da2010-02-01 19:48:3610
[email protected]f7817822009-09-24 05:11:5811#include "base/platform_thread.h"
12#include "chrome_frame/plugin_url_request.h"
[email protected]c96c3c92010-05-01 02:08:3813#include "third_party/npapi/bindings/npapi.h"
[email protected]f7817822009-09-24 05:11:5814
[email protected]3eb07da2010-02-01 19:48:3615class NPAPIUrlRequest;
16class NPAPIUrlRequestManager : public PluginUrlRequestManager,
17 public PluginUrlRequestDelegate {
[email protected]f7817822009-09-24 05:11:5818 public:
[email protected]3eb07da2010-02-01 19:48:3619 NPAPIUrlRequestManager();
20 ~NPAPIUrlRequestManager();
[email protected]f7817822009-09-24 05:11:5821
[email protected]3eb07da2010-02-01 19:48:3622 void set_NPPInstance(NPP instance) {
23 instance_ = instance;
24 }
[email protected]f7817822009-09-24 05:11:5825
[email protected]3eb07da2010-02-01 19:48:3626 // Notifications from the browser. We find the appropriate NPAPIUrlRequest
27 // and forward the call.
[email protected]0d9d45132010-02-02 00:04:2828 NPError NewStream(NPMIMEType type, NPStream* stream,
29 NPBool seekable, uint16* stream_type);
[email protected]3eb07da2010-02-01 19:48:3630 int32 WriteReady(NPStream* stream);
31 int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer);
32 NPError DestroyStream(NPStream* stream, NPReason reason);
33 void UrlNotify(const char* url, NPReason reason, void* notify_data);
[email protected]f7817822009-09-24 05:11:5834
35 private:
[email protected]3eb07da2010-02-01 19:48:3636 // PluginUrlRequestManager implementation. Called from AutomationClient.
[email protected]27ad98352010-04-13 17:10:5137 virtual PluginUrlRequestManager::ThreadSafeFlags GetThreadSafeFlags();
[email protected]3eb07da2010-02-01 19:48:3638 virtual void StartRequest(int request_id,
[email protected]0ce46402010-04-08 16:53:5739 const IPC::AutomationURLRequest& request_info);
[email protected]3eb07da2010-02-01 19:48:3640 virtual void ReadRequest(int request_id, int bytes_to_read);
41 virtual void EndRequest(int request_id);
[email protected]7ae80742010-03-25 22:02:2742 virtual void DownloadRequestInHost(int request_id) {
43 // Not yet implemented.
44 }
[email protected]3eb07da2010-02-01 19:48:3645 virtual void StopAll();
[email protected]27ad98352010-04-13 17:10:5146 virtual void SetCookiesForUrl(const GURL& url, const std::string& cookie);
47 virtual void GetCookiesForUrl(const GURL& url, int cookie_id);
[email protected]f7817822009-09-24 05:11:5848
[email protected]3eb07da2010-02-01 19:48:3649 // Outstanding requests map.
50 typedef std::map<int, scoped_refptr<NPAPIUrlRequest> > RequestMap;
51 RequestMap request_map_;
52
[email protected]0d9d45132010-02-02 00:04:2853 scoped_refptr<NPAPIUrlRequest> LookupRequest(int request_id);
54
[email protected]3eb07da2010-02-01 19:48:3655 // PluginUrlRequestDelegate implementation. Forwards back to delegate.
56 virtual void OnResponseStarted(int request_id, const char* mime_type,
[email protected]70daf0b2010-03-02 19:13:0057 const char* headers, int size, base::Time last_modified,
[email protected]3eb07da2010-02-01 19:48:3658 const std::string& redirect_url, int redirect_status);
[email protected]0ce46402010-04-08 16:53:5759 virtual void OnReadComplete(int request_id, const std::string& data);
[email protected]3eb07da2010-02-01 19:48:3660 virtual void OnResponseEnd(int request_id, const URLRequestStatus& status);
[email protected]27ad98352010-04-13 17:10:5161 virtual void OnCookiesRetrieved(bool success, const GURL& url,
62 const std::string& cookie_string, int cookie_id);
[email protected]3eb07da2010-02-01 19:48:3663
64 static inline NPAPIUrlRequest* RequestFromNotifyData(void* notify_data) {
65 return reinterpret_cast<NPAPIUrlRequest*>(notify_data);
66 }
67
68 NPP instance_;
[email protected]f7817822009-09-24 05:11:5869};
70
71#endif // CHROME_FRAME_NPAPI_URL_REQUEST_H_
72