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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // Otherwise we don't know if we're the right app to handle this request. Ask | 74 // Otherwise we don't know if we're the right app to handle this request. Ask |
75 // host to do the navigation for us. | 75 // host to do the navigation for us. |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 } // namespace | 79 } // namespace |
80 | 80 |
81 HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider, | 81 HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider, |
82 ViewManager* view_manager) | 82 ViewManager* view_manager) |
83 : view_manager_(view_manager), | 83 : view_manager_(view_manager), |
| 84 navigator_host_(service_provider), |
84 web_view_(NULL), | 85 web_view_(NULL), |
85 root_(NULL), | 86 root_(NULL), |
86 repaint_pending_(false), | 87 repaint_pending_(false), |
87 navigator_host_(service_provider), | |
88 weak_factory_(this) { | 88 weak_factory_(this) { |
89 } | 89 } |
90 | 90 |
91 HTMLDocumentView::~HTMLDocumentView() { | 91 HTMLDocumentView::~HTMLDocumentView() { |
92 if (web_view_) | 92 if (web_view_) |
93 web_view_->close(); | 93 web_view_->close(); |
94 if (root_) | 94 if (root_) |
95 root_->RemoveObserver(this); | 95 root_->RemoveObserver(this); |
96 } | 96 } |
97 | 97 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 bool HTMLDocumentView::allowsBrokenNullLayerTreeView() const { | 139 bool HTMLDocumentView::allowsBrokenNullLayerTreeView() const { |
140 // TODO(darin): Switch to using compositor bindings. | 140 // TODO(darin): Switch to using compositor bindings. |
141 // | 141 // |
142 // NOTE: Note to Blink maintainers, feel free to break this code if it is the | 142 // NOTE: Note to Blink maintainers, feel free to break this code if it is the |
143 // last NOT using compositor bindings and you want to delete this code path. | 143 // last NOT using compositor bindings and you want to delete this code path. |
144 // | 144 // |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
| 148 blink::WebFrame* HTMLDocumentView::createChildFrame( |
| 149 blink::WebLocalFrame* parent, |
| 150 const blink::WebString& frameName) { |
| 151 blink::WebLocalFrame* web_frame = blink::WebLocalFrame::create(this); |
| 152 parent->appendChild(web_frame); |
| 153 return web_frame; |
| 154 } |
| 155 |
| 156 void HTMLDocumentView::frameDetached(blink::WebFrame* frame) { |
| 157 if (frame->parent()) |
| 158 frame->parent()->removeChild(frame); |
| 159 |
| 160 // |frame| is invalid after here. |
| 161 frame->close(); |
| 162 } |
| 163 |
148 blink::WebCookieJar* HTMLDocumentView::cookieJar(blink::WebLocalFrame* frame) { | 164 blink::WebCookieJar* HTMLDocumentView::cookieJar(blink::WebLocalFrame* frame) { |
149 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. | 165 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. |
150 // Either it should, as it once did, or we should find another solution here. | 166 // Either it should, as it once did, or we should find another solution here. |
151 return blink::Platform::current()->cookieJar(); | 167 return blink::Platform::current()->cookieJar(); |
152 } | 168 } |
153 | 169 |
154 blink::WebNavigationPolicy HTMLDocumentView::decidePolicyForNavigation( | 170 blink::WebNavigationPolicy HTMLDocumentView::decidePolicyForNavigation( |
155 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, | 171 blink::WebLocalFrame* frame, blink::WebDataSource::ExtraData* data, |
156 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, | 172 const blink::WebURLRequest& request, blink::WebNavigationType nav_type, |
157 blink::WebNavigationPolicy default_policy, bool is_redirect) { | 173 blink::WebNavigationPolicy default_policy, bool is_redirect) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 231 |
216 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( | 232 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( |
217 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); | 233 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); |
218 | 234 |
219 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); | 235 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); |
220 | 236 |
221 root_->SetContents(canvas->getDevice()->accessBitmap(false)); | 237 root_->SetContents(canvas->getDevice()->accessBitmap(false)); |
222 } | 238 } |
223 | 239 |
224 } // namespace mojo | 240 } // namespace mojo |
OLD | NEW |