Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: mojo/services/html_viewer/html_document_view.cc

Issue 418983002: Nukes view_manager namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolve merge Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return true; 70 return true;
71 71
72 // Otherwise we don't know if we're the right app to handle this request. Ask 72 // Otherwise we don't know if we're the right app to handle this request. Ask
73 // host to do the navigation for us. 73 // host to do the navigation for us.
74 return false; 74 return false;
75 } 75 }
76 76
77 } // namespace 77 } // namespace
78 78
79 HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider, 79 HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider,
80 view_manager::ViewManager* view_manager) 80 ViewManager* view_manager)
81 : view_manager_(view_manager), 81 : view_manager_(view_manager),
82 view_(view_manager::View::Create(view_manager_)), 82 view_(View::Create(view_manager_)),
83 web_view_(NULL), 83 web_view_(NULL),
84 root_(NULL), 84 root_(NULL),
85 repaint_pending_(false), 85 repaint_pending_(false),
86 navigator_host_(service_provider), 86 navigator_host_(service_provider),
87 weak_factory_(this) { 87 weak_factory_(this) {
88 view_->AddObserver(this); 88 view_->AddObserver(this);
89 } 89 }
90 90
91 HTMLDocumentView::~HTMLDocumentView() { 91 HTMLDocumentView::~HTMLDocumentView() {
92 view_->RemoveObserver(this); 92 view_->RemoveObserver(this);
93 if (web_view_) 93 if (web_view_)
94 web_view_->close(); 94 web_view_->close();
95 if (root_) 95 if (root_)
96 root_->RemoveObserver(this); 96 root_->RemoveObserver(this);
97 } 97 }
98 98
99 void HTMLDocumentView::AttachToNode(view_manager::Node* node) { 99 void HTMLDocumentView::AttachToNode(Node* node) {
100 root_ = node; 100 root_ = node;
101 root_->SetActiveView(view_); 101 root_->SetActiveView(view_);
102 view_->SetColor(SK_ColorCYAN); // Dummy background color. 102 view_->SetColor(SK_ColorCYAN); // Dummy background color.
103 103
104 web_view_ = blink::WebView::create(this); 104 web_view_ = blink::WebView::create(this);
105 ConfigureSettings(web_view_->settings()); 105 ConfigureSettings(web_view_->settings());
106 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); 106 web_view_->setMainFrame(blink::WebLocalFrame::create(this));
107 web_view_->resize(root_->bounds().size()); 107 web_view_->resize(root_->bounds().size());
108 108
109 root_->AddObserver(this); 109 root_->AddObserver(this);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 const blink::WebString& stack_trace) { 178 const blink::WebString& stack_trace) {
179 } 179 }
180 180
181 void HTMLDocumentView::didNavigateWithinPage( 181 void HTMLDocumentView::didNavigateWithinPage(
182 blink::WebLocalFrame* frame, const blink::WebHistoryItem& history_item, 182 blink::WebLocalFrame* frame, const blink::WebHistoryItem& history_item,
183 blink::WebHistoryCommitType commit_type) { 183 blink::WebHistoryCommitType commit_type) {
184 navigator_host_->DidNavigateLocally(view_->node()->id(), 184 navigator_host_->DidNavigateLocally(view_->node()->id(),
185 history_item.urlString().utf8()); 185 history_item.urlString().utf8());
186 } 186 }
187 187
188 void HTMLDocumentView::OnViewInputEvent(view_manager::View* view, 188 void HTMLDocumentView::OnViewInputEvent(View* view,
189 const EventPtr& event) { 189 const EventPtr& event) {
190 scoped_ptr<blink::WebInputEvent> web_event = 190 scoped_ptr<blink::WebInputEvent> web_event =
191 TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( 191 TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo(
192 event); 192 event);
193 if (web_event) 193 if (web_event)
194 web_view_->handleInputEvent(*web_event); 194 web_view_->handleInputEvent(*web_event);
195 } 195 }
196 196
197 void HTMLDocumentView::OnNodeBoundsChanged(view_manager::Node* node, 197 void HTMLDocumentView::OnNodeBoundsChanged(Node* node,
198 const gfx::Rect& old_bounds, 198 const gfx::Rect& old_bounds,
199 const gfx::Rect& new_bounds) { 199 const gfx::Rect& new_bounds) {
200 DCHECK_EQ(node, root_); 200 DCHECK_EQ(node, root_);
201 web_view_->resize(node->bounds().size()); 201 web_view_->resize(node->bounds().size());
202 } 202 }
203 203
204 void HTMLDocumentView::OnNodeDestroyed(view_manager::Node* node) { 204 void HTMLDocumentView::OnNodeDestroyed(Node* node) {
205 DCHECK_EQ(node, root_); 205 DCHECK_EQ(node, root_);
206 node->RemoveObserver(this); 206 node->RemoveObserver(this);
207 root_ = NULL; 207 root_ = NULL;
208 } 208 }
209 209
210 void HTMLDocumentView::Repaint() { 210 void HTMLDocumentView::Repaint() {
211 repaint_pending_ = false; 211 repaint_pending_ = false;
212 212
213 web_view_->animate(0.0); 213 web_view_->animate(0.0);
214 web_view_->layout(); 214 web_view_->layout();
215 215
216 int width = web_view_->size().width; 216 int width = web_view_->size().width;
217 int height = web_view_->size().height; 217 int height = web_view_->size().height;
218 218
219 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( 219 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster(
220 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); 220 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType)));
221 221
222 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); 222 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height));
223 223
224 view_->SetContents(canvas->getDevice()->accessBitmap(false)); 224 view_->SetContents(canvas->getDevice()->accessBitmap(false));
225 } 225 }
226 226
227 } // namespace mojo 227 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/html_document_view.h ('k') | mojo/services/html_viewer/html_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698