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/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
11 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" | 11 #include "mojo/services/html_viewer/blink_input_events_type_converters.h" |
12 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" | 12 #include "mojo/services/html_viewer/webstoragenamespace_impl.h" |
13 #include "mojo/services/html_viewer/weburlloader_impl.h" | 13 #include "mojo/services/html_viewer/weburlloader_impl.h" |
14 #include "mojo/services/public/cpp/view_manager/node.h" | 14 #include "mojo/services/public/cpp/view_manager/node.h" |
15 #include "mojo/services/public/cpp/view_manager/view.h" | 15 #include "mojo/services/public/cpp/view_manager/view.h" |
16 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 16 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
17 #include "skia/ext/refptr.h" | 17 #include "skia/ext/refptr.h" |
| 18 #include "third_party/WebKit/public/platform/Platform.h" |
18 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 19 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
19 #include "third_party/WebKit/public/web/WebDocument.h" | 20 #include "third_party/WebKit/public/web/WebDocument.h" |
20 #include "third_party/WebKit/public/web/WebElement.h" | 21 #include "third_party/WebKit/public/web/WebElement.h" |
21 #include "third_party/WebKit/public/web/WebInputEvent.h" | 22 #include "third_party/WebKit/public/web/WebInputEvent.h" |
22 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 23 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
23 #include "third_party/WebKit/public/web/WebScriptSource.h" | 24 #include "third_party/WebKit/public/web/WebScriptSource.h" |
24 #include "third_party/WebKit/public/web/WebSettings.h" | 25 #include "third_party/WebKit/public/web/WebSettings.h" |
25 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
26 #include "third_party/skia/include/core/SkCanvas.h" | 27 #include "third_party/skia/include/core/SkCanvas.h" |
27 #include "third_party/skia/include/core/SkColor.h" | 28 #include "third_party/skia/include/core/SkColor.h" |
28 #include "third_party/skia/include/core/SkDevice.h" | 29 #include "third_party/skia/include/core/SkDevice.h" |
29 | 30 |
30 namespace mojo { | 31 namespace mojo { |
31 namespace { | 32 namespace { |
32 | 33 |
33 void ConfigureSettings(blink::WebSettings* settings) { | 34 void ConfigureSettings(blink::WebSettings* settings) { |
34 settings->setAcceleratedCompositingEnabled(false); | 35 settings->setAcceleratedCompositingEnabled(false); |
| 36 settings->setCookieEnabled(true); |
35 settings->setDefaultFixedFontSize(13); | 37 settings->setDefaultFixedFontSize(13); |
36 settings->setDefaultFontSize(16); | 38 settings->setDefaultFontSize(16); |
37 settings->setLoadsImagesAutomatically(true); | 39 settings->setLoadsImagesAutomatically(true); |
38 settings->setJavaScriptEnabled(true); | 40 settings->setJavaScriptEnabled(true); |
39 } | 41 } |
40 | 42 |
41 navigation::Target WebNavigationPolicyToNavigationTarget( | 43 navigation::Target WebNavigationPolicyToNavigationTarget( |
42 blink::WebNavigationPolicy policy) { | 44 blink::WebNavigationPolicy policy) { |
43 switch (policy) { | 45 switch (policy) { |
44 case blink::WebNavigationPolicyCurrentTab: | 46 case blink::WebNavigationPolicyCurrentTab: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 repaint_pending_ = true; | 134 repaint_pending_ = true; |
133 base::ThreadTaskRunnerHandle::Get()->PostTask( | 135 base::ThreadTaskRunnerHandle::Get()->PostTask( |
134 FROM_HERE, | 136 FROM_HERE, |
135 base::Bind(&HTMLDocumentView::Repaint, weak_factory_.GetWeakPtr())); | 137 base::Bind(&HTMLDocumentView::Repaint, weak_factory_.GetWeakPtr())); |
136 } | 138 } |
137 } | 139 } |
138 | 140 |
139 bool HTMLDocumentView::allowsBrokenNullLayerTreeView() const { | 141 bool HTMLDocumentView::allowsBrokenNullLayerTreeView() const { |
140 // TODO(darin): Switch to using compositor bindings. | 142 // TODO(darin): Switch to using compositor bindings. |
141 // | 143 // |
142 // NOTE: Note to Blink maintainers, feel free to just break this code if it | 144 // NOTE: Note to Blink maintainers, feel free to break this code if it is the |
143 // is the last using compositor bindings and you want to delete the old path. | 145 // last NOT using compositor bindings and you want to delete this code path. |
144 // | 146 // |
145 return true; | 147 return true; |
146 } | 148 } |
147 | 149 |
| 150 blink::WebCookieJar* HTMLDocumentView::cookieJar(blink::WebLocalFrame* frame) { |
| 151 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. |
| 152 // Either it should, as it once did, or we should find another solution here. |
| 153 return blink::Platform::current()->cookieJar(); |
| 154 } |
| 155 |
148 blink::WebNavigationPolicy HTMLDocumentView::decidePolicyForNavigation( | 156 blink::WebNavigationPolicy HTMLDocumentView::decidePolicyForNavigation( |
149 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, | 157 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, |
150 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, | 158 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, |
151 blink::WebNavigationPolicy default_policy, bool is_redirect) { | 159 blink::WebNavigationPolicy default_policy, bool is_redirect) { |
152 if (CanNavigateLocally(frame, request)) | 160 if (CanNavigateLocally(frame, request)) |
153 return default_policy; | 161 return default_policy; |
154 | 162 |
155 navigation::NavigationDetailsPtr nav_details( | 163 navigation::NavigationDetailsPtr nav_details( |
156 navigation::NavigationDetails::New()); | 164 navigation::NavigationDetails::New()); |
157 nav_details->url = request.url().string().utf8(); | 165 nav_details->url = request.url().string().utf8(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 218 |
211 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( | 219 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( |
212 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); | 220 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); |
213 | 221 |
214 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); | 222 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); |
215 | 223 |
216 view_->SetContents(canvas->getDevice()->accessBitmap(false)); | 224 view_->SetContents(canvas->getDevice()->accessBitmap(false)); |
217 } | 225 } |
218 | 226 |
219 } // namespace mojo | 227 } // namespace mojo |
OLD | NEW |