OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/services/html_viewer/html_document_view.h" | 5 #include "mojo/services/html_viewer/html_document_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 HeaderFlattener() : has_accept_header_(false) {} | 40 HeaderFlattener() : has_accept_header_(false) {} |
41 | 41 |
42 virtual void visitHeader(const blink::WebString& name, | 42 virtual void visitHeader(const blink::WebString& name, |
43 const blink::WebString& value) { | 43 const blink::WebString& value) { |
44 // Headers are latin1. | 44 // Headers are latin1. |
45 const std::string& name_latin1 = name.latin1(); | 45 const std::string& name_latin1 = name.latin1(); |
46 const std::string& value_latin1 = value.latin1(); | 46 const std::string& value_latin1 = value.latin1(); |
47 | 47 |
48 // Skip over referrer headers found in the header map because we already | 48 // Skip over referrer headers found in the header map because we already |
49 // pulled it out as a separate parameter. | 49 // pulled it out as a separate parameter. |
50 if (LowerCaseEqualsASCII(name_latin1, "referer")) | 50 if (base::LowerCaseEqualsASCII(name_latin1, "referer")) |
51 return; | 51 return; |
52 | 52 |
53 if (LowerCaseEqualsASCII(name_latin1, "accept")) | 53 if (base::LowerCaseEqualsASCII(name_latin1, "accept")) |
54 has_accept_header_ = true; | 54 has_accept_header_ = true; |
55 | 55 |
56 buffer_.push_back(name_latin1 + ": " + value_latin1); | 56 buffer_.push_back(name_latin1 + ": " + value_latin1); |
57 } | 57 } |
58 | 58 |
59 Array<String> GetBuffer() { | 59 Array<String> GetBuffer() { |
60 // In some cases, WebKit doesn't add an Accept header, but not having the | 60 // In some cases, WebKit doesn't add an Accept header, but not having the |
61 // header confuses some web servers. See bug 808613. | 61 // header confuses some web servers. See bug 808613. |
62 if (!has_accept_header_) { | 62 if (!has_accept_header_) { |
63 buffer_.push_back("Accept: */*"); | 63 buffer_.push_back("Accept: */*"); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( | 306 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( |
307 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); | 307 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); |
308 | 308 |
309 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); | 309 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); |
310 | 310 |
311 view_->SetContents(canvas->getDevice()->accessBitmap(false)); | 311 view_->SetContents(canvas->getDevice()->accessBitmap(false)); |
312 } | 312 } |
313 | 313 |
314 } // namespace mojo | 314 } // namespace mojo |
OLD | NEW |