summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_url_response_info.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-11-18 18:32:45 +0000
committerBen Murdoch <benm@google.com>2010-11-18 18:38:07 +0000
commit513209b27ff55e2841eac0e4120199c23acce758 (patch)
treeaeba30bb08c5f47c57003544e378a377c297eee6 /webkit/glue/plugins/pepper_url_response_info.cc
parent164f7496de0fbee436b385a79ead9e3cb81a50c1 (diff)
downloadexternal_chromium-513209b27ff55e2841eac0e4120199c23acce758.zip
external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.gz
external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.bz2
Merge Chromium at r65505: Initial merge by git.
Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45
Diffstat (limited to 'webkit/glue/plugins/pepper_url_response_info.cc')
-rw-r--r--webkit/glue/plugins/pepper_url_response_info.cc31
1 files changed, 25 insertions, 6 deletions
diff --git a/webkit/glue/plugins/pepper_url_response_info.cc b/webkit/glue/plugins/pepper_url_response_info.cc
index 8af3385..2e7202f 100644
--- a/webkit/glue/plugins/pepper_url_response_info.cc
+++ b/webkit/glue/plugins/pepper_url_response_info.cc
@@ -5,11 +5,12 @@
#include "webkit/glue/plugins/pepper_url_response_info.h"
#include "base/logging.h"
-#include "third_party/ppapi/c/pp_var.h"
+#include "ppapi/c/pp_var.h"
#include "third_party/WebKit/WebKit/chromium/public/WebHTTPHeaderVisitor.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
+#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_file_ref.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/glue/webkit_glue.h"
@@ -38,8 +39,8 @@ class HeaderFlattener : public WebHTTPHeaderVisitor {
std::string buffer_;
};
-bool IsURLResponseInfo(PP_Resource resource) {
- return !!Resource::GetAs<URLResponseInfo>(resource);
+PP_Bool IsURLResponseInfo(PP_Resource resource) {
+ return BoolToPPBool(!!Resource::GetAs<URLResponseInfo>(resource));
}
PP_Var GetProperty(PP_Resource response_id,
@@ -72,6 +73,10 @@ const PPB_URLResponseInfo_Dev ppb_urlresponseinfo = {
&GetBody
};
+bool IsRedirect(int32_t status) {
+ return status >= 300 && status <= 399;
+}
+
} // namespace
URLResponseInfo::URLResponseInfo(PluginModule* module)
@@ -91,19 +96,33 @@ PP_Var URLResponseInfo::GetProperty(PP_URLResponseProperty_Dev property) {
switch (property) {
case PP_URLRESPONSEPROPERTY_URL:
return StringVar::StringToPPVar(module(), url_);
+ case PP_URLRESPONSEPROPERTY_REDIRECTURL:
+ if (IsRedirect(status_code_))
+ return StringVar::StringToPPVar(module(), redirect_url_);
+ break;
+ case PP_URLRESPONSEPROPERTY_REDIRECTMETHOD:
+ if (IsRedirect(status_code_))
+ return StringVar::StringToPPVar(module(), status_text_);
+ break;
case PP_URLRESPONSEPROPERTY_STATUSCODE:
return PP_MakeInt32(status_code_);
+ case PP_URLRESPONSEPROPERTY_STATUSLINE:
+ return StringVar::StringToPPVar(module(), status_text_);
case PP_URLRESPONSEPROPERTY_HEADERS:
return StringVar::StringToPPVar(module(), headers_);
- default:
- NOTIMPLEMENTED(); // TODO(darin): Implement me!
- return PP_MakeUndefined();
}
+ // The default is to return an undefined PP_Var.
+ return PP_MakeUndefined();
}
bool URLResponseInfo::Initialize(const WebURLResponse& response) {
url_ = response.url().spec();
status_code_ = response.httpStatusCode();
+ status_text_ = response.httpStatusText().utf8();
+ if (IsRedirect(status_code_)) {
+ redirect_url_ = response.httpHeaderField(
+ WebString::fromUTF8("Location")).utf8();
+ }
HeaderFlattener flattener;
response.visitHTTPHeaderFields(&flattener);