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

Side by Side Diff: sky/engine/web/WebLocalFrameImpl.cpp

Issue 958203002: Don't crash when we 404. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Works! Created 5 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // detached. Most embedders will invoke close() on the WebFrame at this point, 66 // detached. Most embedders will invoke close() on the WebFrame at this point,
67 // triggering its deletion unless something else is still retaining a reference. 67 // triggering its deletion unless something else is still retaining a reference.
68 // 68 //
69 // Thie client is expected to be set whenever the WebLocalFrameImpl is attached to 69 // Thie client is expected to be set whenever the WebLocalFrameImpl is attached to
70 // the DOM. 70 // the DOM.
71 71
72 #include "sky/engine/config.h" 72 #include "sky/engine/config.h"
73 #include "sky/engine/web/WebLocalFrameImpl.h" 73 #include "sky/engine/web/WebLocalFrameImpl.h"
74 74
75 #include <algorithm> 75 #include <algorithm>
76 #include "base/strings/stringprintf.h"
77 #include "mojo/common/data_pipe_utils.h"
76 #include "mojo/public/cpp/system/data_pipe.h" 78 #include "mojo/public/cpp/system/data_pipe.h"
77 #include "sky/engine/bindings/exception_state.h" 79 #include "sky/engine/bindings/exception_state.h"
78 #include "sky/engine/bindings/exception_state_placeholder.h" 80 #include "sky/engine/bindings/exception_state_placeholder.h"
79 #include "sky/engine/core/dom/Document.h" 81 #include "sky/engine/core/dom/Document.h"
80 #include "sky/engine/core/dom/Node.h" 82 #include "sky/engine/core/dom/Node.h"
81 #include "sky/engine/core/dom/NodeTraversal.h" 83 #include "sky/engine/core/dom/NodeTraversal.h"
82 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 84 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
83 #include "sky/engine/core/editing/Editor.h" 85 #include "sky/engine/core/editing/Editor.h"
84 #include "sky/engine/core/editing/FrameSelection.h" 86 #include "sky/engine/core/editing/FrameSelection.h"
87 #include "sky/engine/core/editing/htmlediting.h"
85 #include "sky/engine/core/editing/InputMethodController.h" 88 #include "sky/engine/core/editing/InputMethodController.h"
86 #include "sky/engine/core/editing/PlainTextRange.h" 89 #include "sky/engine/core/editing/PlainTextRange.h"
87 #include "sky/engine/core/editing/SpellChecker.h" 90 #include "sky/engine/core/editing/SpellChecker.h"
88 #include "sky/engine/core/editing/TextAffinity.h" 91 #include "sky/engine/core/editing/TextAffinity.h"
89 #include "sky/engine/core/editing/TextIterator.h" 92 #include "sky/engine/core/editing/TextIterator.h"
90 #include "sky/engine/core/editing/htmlediting.h"
91 #include "sky/engine/core/frame/FrameHost.h" 93 #include "sky/engine/core/frame/FrameHost.h"
92 #include "sky/engine/core/frame/FrameView.h" 94 #include "sky/engine/core/frame/FrameView.h"
93 #include "sky/engine/core/frame/LocalDOMWindow.h" 95 #include "sky/engine/core/frame/LocalDOMWindow.h"
94 #include "sky/engine/core/frame/Settings.h" 96 #include "sky/engine/core/frame/Settings.h"
95 #include "sky/engine/core/html/HTMLAnchorElement.h" 97 #include "sky/engine/core/html/HTMLAnchorElement.h"
96 #include "sky/engine/core/inspector/ConsoleMessage.h" 98 #include "sky/engine/core/inspector/ConsoleMessage.h"
97 #include "sky/engine/core/loader/MojoLoader.h" 99 #include "sky/engine/core/loader/MojoLoader.h"
98 #include "sky/engine/core/page/EventHandler.h" 100 #include "sky/engine/core/page/EventHandler.h"
99 #include "sky/engine/core/page/FocusController.h" 101 #include "sky/engine/core/page/FocusController.h"
100 #include "sky/engine/core/page/Page.h" 102 #include "sky/engine/core/page/Page.h"
101 #include "sky/engine/core/rendering/HitTestResult.h" 103 #include "sky/engine/core/rendering/HitTestResult.h"
102 #include "sky/engine/core/rendering/RenderBox.h" 104 #include "sky/engine/core/rendering/RenderBox.h"
103 #include "sky/engine/core/rendering/RenderLayer.h" 105 #include "sky/engine/core/rendering/RenderLayer.h"
104 #include "sky/engine/core/rendering/RenderObject.h" 106 #include "sky/engine/core/rendering/RenderObject.h"
105 #include "sky/engine/core/rendering/RenderTreeAsText.h" 107 #include "sky/engine/core/rendering/RenderTreeAsText.h"
106 #include "sky/engine/core/rendering/RenderView.h" 108 #include "sky/engine/core/rendering/RenderView.h"
107 #include "sky/engine/core/rendering/style/StyleInheritedData.h" 109 #include "sky/engine/core/rendering/style/StyleInheritedData.h"
108 #include "sky/engine/platform/TraceEvent.h"
109 #include "sky/engine/platform/clipboard/ClipboardUtilities.h" 110 #include "sky/engine/platform/clipboard/ClipboardUtilities.h"
110 #include "sky/engine/platform/fonts/FontCache.h" 111 #include "sky/engine/platform/fonts/FontCache.h"
111 #include "sky/engine/platform/graphics/GraphicsContext.h" 112 #include "sky/engine/platform/graphics/GraphicsContext.h"
112 #include "sky/engine/platform/graphics/skia/SkiaUtils.h" 113 #include "sky/engine/platform/graphics/skia/SkiaUtils.h"
113 #include "sky/engine/platform/heap/Handle.h" 114 #include "sky/engine/platform/heap/Handle.h"
114 #include "sky/engine/platform/network/ResourceRequest.h" 115 #include "sky/engine/platform/network/ResourceRequest.h"
116 #include "sky/engine/platform/TraceEvent.h"
115 #include "sky/engine/platform/weborigin/KURL.h" 117 #include "sky/engine/platform/weborigin/KURL.h"
116 #include "sky/engine/platform/weborigin/SecurityPolicy.h" 118 #include "sky/engine/platform/weborigin/SecurityPolicy.h"
117 #include "sky/engine/public/platform/Platform.h" 119 #include "sky/engine/public/platform/Platform.h"
118 #include "sky/engine/public/platform/WebFloatPoint.h" 120 #include "sky/engine/public/platform/WebFloatPoint.h"
119 #include "sky/engine/public/platform/WebFloatRect.h" 121 #include "sky/engine/public/platform/WebFloatRect.h"
120 #include "sky/engine/public/platform/WebLayer.h" 122 #include "sky/engine/public/platform/WebLayer.h"
121 #include "sky/engine/public/platform/WebPoint.h" 123 #include "sky/engine/public/platform/WebPoint.h"
122 #include "sky/engine/public/platform/WebRect.h" 124 #include "sky/engine/public/platform/WebRect.h"
123 #include "sky/engine/public/platform/WebSize.h" 125 #include "sky/engine/public/platform/WebSize.h"
124 #include "sky/engine/public/platform/WebURLError.h" 126 #include "sky/engine/public/platform/WebURLError.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 267
266 void WebLocalFrameImpl::load(const WebURL& url) 268 void WebLocalFrameImpl::load(const WebURL& url)
267 { 269 {
268 frame()->mojoLoader().init(url); 270 frame()->mojoLoader().init(url);
269 m_fetcher = adoptPtr(new MojoFetcher(this, url)); 271 m_fetcher = adoptPtr(new MojoFetcher(this, url));
270 } 272 }
271 273
272 void WebLocalFrameImpl::OnReceivedResponse(mojo::URLResponsePtr response) 274 void WebLocalFrameImpl::OnReceivedResponse(mojo::URLResponsePtr response)
273 { 275 {
274 m_fetcher.clear(); 276 m_fetcher.clear();
275 if (!response->body.is_valid()) 277 if (response->body.is_valid()) {
276 LOG(FATAL) << "Response has no body."; 278 frame()->mojoLoader().parse(response->body.Pass());
277 frame()->mojoLoader().parse(response->body.Pass()); 279 return;
280 }
281 LOG(ERROR) << "Response for " << response->url
282 << " (status " << response->status_code << ") has no body.";
283
284 // TODO(eseidel): This is a hack, but makes debugging way easier.
285 mojo::DataPipe pipe;
286 frame()->mojoLoader().parse(pipe.consumer_handle.Pass());
287 std::string error_response = base::StringPrintf(
288 "<error><h>Empty Body</h><l>%d %s</l><m>%s</m></t></error>",
289 response->status_code, response->status_line.get().c_str(),
290 response->error->description.get().c_str());
291
292 uint32_t length = error_response.length();
293 MojoWriteData(pipe.producer_handle.get().value(),
294 error_response.data(),
295 &length,
296 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE);
278 } 297 }
279 298
280 void WebLocalFrameImpl::replaceSelection(const WebString& text) 299 void WebLocalFrameImpl::replaceSelection(const WebString& text)
281 { 300 {
282 bool selectReplacement = false; 301 bool selectReplacement = false;
283 bool smartReplace = true; 302 bool smartReplace = true;
284 frame()->editor().replaceSelectionWithText(text, selectReplacement, smartRep lace); 303 frame()->editor().replaceSelectionWithText(text, selectReplacement, smartRep lace);
285 } 304 }
286 305
287 void WebLocalFrameImpl::insertText(const WebString& text) 306 void WebLocalFrameImpl::insertText(const WebString& text)
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 608
590 void WebLocalFrameImpl::setInputEventsTransformForEmulation(const IntSize& offse t, float contentScaleFactor) 609 void WebLocalFrameImpl::setInputEventsTransformForEmulation(const IntSize& offse t, float contentScaleFactor)
591 { 610 {
592 m_inputEventsOffsetForEmulation = offset; 611 m_inputEventsOffsetForEmulation = offset;
593 m_inputEventsScaleFactorForEmulation = contentScaleFactor; 612 m_inputEventsScaleFactorForEmulation = contentScaleFactor;
594 if (frame()->view()) 613 if (frame()->view())
595 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffset ForEmulation, m_inputEventsScaleFactorForEmulation); 614 frame()->view()->setInputEventsTransformForEmulation(m_inputEventsOffset ForEmulation, m_inputEventsScaleFactorForEmulation);
596 } 615 }
597 616
598 } // namespace blink 617 } // namespace blink
OLDNEW
« no previous file with comments | « sky/apk/demo/org/domokit/sky/demo/SkyDemoActivity.java ('k') | sky/services/oknet/src/org/domokit/oknet/UrlLoaderImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698