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

Side by Side Diff: components/html_viewer/html_document.cc

Issue 1121783003: Move navigations with POST or referrer to the shell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 7 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
« no previous file with comments | « components/html_viewer/blink_platform_impl.cc ('k') | components/html_viewer/html_viewer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/html_viewer/html_document.h" 5 #include "components/html_viewer/html_document.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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 28 matching lines...) Expand all
39 #include "third_party/WebKit/public/web/WebScriptSource.h" 39 #include "third_party/WebKit/public/web/WebScriptSource.h"
40 #include "third_party/WebKit/public/web/WebSettings.h" 40 #include "third_party/WebKit/public/web/WebSettings.h"
41 #include "third_party/WebKit/public/web/WebView.h" 41 #include "third_party/WebKit/public/web/WebView.h"
42 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" 42 #include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h"
43 #include "third_party/skia/include/core/SkCanvas.h" 43 #include "third_party/skia/include/core/SkCanvas.h"
44 #include "third_party/skia/include/core/SkColor.h" 44 #include "third_party/skia/include/core/SkColor.h"
45 #include "third_party/skia/include/core/SkDevice.h" 45 #include "third_party/skia/include/core/SkDevice.h"
46 #include "ui/gfx/geometry/dip_util.h" 46 #include "ui/gfx/geometry/dip_util.h"
47 #include "ui/gfx/geometry/size.h" 47 #include "ui/gfx/geometry/size.h"
48 48
49 using blink::WebString;
49 using mojo::AxProvider; 50 using mojo::AxProvider;
50 using mojo::Rect; 51 using mojo::Rect;
51 using mojo::ServiceProviderPtr; 52 using mojo::ServiceProviderPtr;
52 using mojo::URLResponsePtr; 53 using mojo::URLResponsePtr;
53 using mojo::View; 54 using mojo::View;
54 using mojo::ViewManager; 55 using mojo::ViewManager;
55 using mojo::WeakBindToRequest; 56 using mojo::WeakBindToRequest;
56 57
57 namespace html_viewer { 58 namespace html_viewer {
58 namespace { 59 namespace {
(...skipping 28 matching lines...) Expand all
87 // different instance of Blink if the frame is cross-origin. 88 // different instance of Blink if the frame is cross-origin.
88 if (frame->parent()) 89 if (frame->parent())
89 return true; 90 return true;
90 91
91 // If we have extraData() it means we already have the url response 92 // If we have extraData() it means we already have the url response
92 // (presumably because we are being called via Navigate()). In that case we 93 // (presumably because we are being called via Navigate()). In that case we
93 // can go ahead and navigate locally. 94 // can go ahead and navigate locally.
94 if (request.extraData()) 95 if (request.extraData())
95 return true; 96 return true;
96 97
97 // mojo::NavigatorHost doesn't accept POSTs, so for now reuse this instance.
98 // TODO(jam): improve this (and copy logic from RenderFrameImpl's version)
99 // when we have multi-process.
100 if (EqualsASCII(request.httpMethod(), "POST"))
101 return true;
102
103 // Logging into Gmail fails when the referrer isn't sent with a request.
104 // TODO(jam): pass referrer and other HTTP data to NavigatorHost so we can
105 // use a new process in this case.
106 if (!request.httpHeaderField(blink::WebString::fromUTF8("Referer")).isEmpty())
107 return true;
108
109 // Otherwise we don't know if we're the right app to handle this request. Ask 98 // Otherwise we don't know if we're the right app to handle this request. Ask
110 // host to do the navigation for us. 99 // host to do the navigation for us.
111 return false; 100 return false;
112 } 101 }
113 102
114 bool AreSecureCodecsSupported() { 103 bool AreSecureCodecsSupported() {
115 // Hardware-secure codecs are not currently supported by HTML Viewer on any 104 // Hardware-secure codecs are not currently supported by HTML Viewer on any
116 // platform. 105 // platform.
117 return false; 106 return false;
118 } 107 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 216 }
228 217
229 void HTMLDocument::initializeLayerTreeView() { 218 void HTMLDocument::initializeLayerTreeView() {
230 if (setup_->is_headless()) { 219 if (setup_->is_headless()) {
231 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( 220 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl(
232 setup_->compositor_thread(), nullptr, nullptr)); 221 setup_->compositor_thread(), nullptr, nullptr));
233 return; 222 return;
234 } 223 }
235 224
236 ServiceProviderPtr surfaces_service_provider; 225 ServiceProviderPtr surfaces_service_provider;
237 shell_->ConnectToApplication("mojo:surfaces_service", 226 mojo::URLRequestPtr request(mojo::URLRequest::New());
227 request->url = mojo::String::From("mojo:surfaces_service");
228 shell_->ConnectToApplication(request.Pass(),
238 GetProxy(&surfaces_service_provider), nullptr); 229 GetProxy(&surfaces_service_provider), nullptr);
239 mojo::SurfacePtr surface; 230 mojo::SurfacePtr surface;
240 ConnectToService(surfaces_service_provider.get(), &surface); 231 ConnectToService(surfaces_service_provider.get(), &surface);
241 232
242 ServiceProviderPtr gpu_service_provider; 233 ServiceProviderPtr gpu_service_provider;
243 // TODO(jamesr): Should be mojo:gpu_service 234 // TODO(jamesr): Should be mojo:gpu_service
244 shell_->ConnectToApplication("mojo:native_viewport_service", 235 mojo::URLRequestPtr request2(mojo::URLRequest::New());
236 request2->url = mojo::String::From("mojo:native_viewport_service");
237 shell_->ConnectToApplication(request2.Pass(),
245 GetProxy(&gpu_service_provider), nullptr); 238 GetProxy(&gpu_service_provider), nullptr);
246 mojo::GpuPtr gpu_service; 239 mojo::GpuPtr gpu_service;
247 ConnectToService(gpu_service_provider.get(), &gpu_service); 240 ConnectToService(gpu_service_provider.get(), &gpu_service);
248 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( 241 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl(
249 setup_->compositor_thread(), surface.Pass(), gpu_service.Pass())); 242 setup_->compositor_thread(), surface.Pass(), gpu_service.Pass()));
250 } 243 }
251 244
252 blink::WebLayerTreeView* HTMLDocument::layerTreeView() { 245 blink::WebLayerTreeView* HTMLDocument::layerTreeView() {
253 return web_layer_tree_view_impl_.get(); 246 return web_layer_tree_view_impl_.get();
254 } 247 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 blink::WebLocalFrame* frame, 294 blink::WebLocalFrame* frame,
302 blink::WebDataSource::ExtraData* data, 295 blink::WebDataSource::ExtraData* data,
303 const blink::WebURLRequest& request, 296 const blink::WebURLRequest& request,
304 blink::WebNavigationType nav_type, 297 blink::WebNavigationType nav_type,
305 blink::WebNavigationPolicy default_policy, 298 blink::WebNavigationPolicy default_policy,
306 bool is_redirect) { 299 bool is_redirect) {
307 if (CanNavigateLocally(frame, request)) 300 if (CanNavigateLocally(frame, request))
308 return default_policy; 301 return default_policy;
309 302
310 if (navigator_host_.get()) { 303 if (navigator_host_.get()) {
304 mojo::URLRequestPtr url_request = mojo::URLRequest::From(request);
311 navigator_host_->RequestNavigate( 305 navigator_host_->RequestNavigate(
312 WebNavigationPolicyToNavigationTarget(default_policy), 306 WebNavigationPolicyToNavigationTarget(default_policy),
313 mojo::URLRequest::From(request).Pass()); 307 url_request.Pass());
314 } 308 }
315 309
316 return blink::WebNavigationPolicyIgnore; 310 return blink::WebNavigationPolicyIgnore;
317 } 311 }
318 312
319 void HTMLDocument::didAddMessageToConsole( 313 void HTMLDocument::didAddMessageToConsole(
320 const blink::WebConsoleMessage& message, 314 const blink::WebConsoleMessage& message,
321 const blink::WebString& source_name, 315 const blink::WebString& source_name,
322 unsigned source_line, 316 unsigned source_line,
323 const blink::WebString& stack_trace) { 317 const blink::WebString& stack_trace) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return media_permission_.get(); 395 return media_permission_.get();
402 } 396 }
403 397
404 media::CdmFactory* HTMLDocument::GetCdmFactory() { 398 media::CdmFactory* HTMLDocument::GetCdmFactory() {
405 if (!cdm_factory_) 399 if (!cdm_factory_)
406 cdm_factory_.reset(new media::DefaultCdmFactory()); 400 cdm_factory_.reset(new media::DefaultCdmFactory());
407 return cdm_factory_.get(); 401 return cdm_factory_.get();
408 } 402 }
409 403
410 } // namespace html_viewer 404 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/blink_platform_impl.cc ('k') | components/html_viewer/html_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698