| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/page/CreateWindow.h" | 27 #include "core/page/CreateWindow.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/ExceptionState.h" |
| 29 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 30 #include "core/frame/FrameClient.h" | 31 #include "core/frame/FrameClient.h" |
| 31 #include "core/frame/LocalFrame.h" | 32 #include "core/frame/LocalFrame.h" |
| 32 #include "core/frame/Settings.h" | 33 #include "core/frame/Settings.h" |
| 33 #include "core/inspector/ConsoleMessage.h" | 34 #include "core/inspector/ConsoleMessage.h" |
| 34 #include "core/loader/FrameLoadRequest.h" | 35 #include "core/loader/FrameLoadRequest.h" |
| 35 #include "core/page/ChromeClient.h" | 36 #include "core/page/ChromeClient.h" |
| 36 #include "core/page/FocusController.h" | 37 #include "core/page/FocusController.h" |
| 37 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
| 38 #include "core/page/WindowFeatures.h" | 39 #include "core/page/WindowFeatures.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 173 } |
| 173 | 174 |
| 174 return CreateNewWindow(opener_frame, request, features, policy, created); | 175 return CreateNewWindow(opener_frame, request, features, policy, created); |
| 175 } | 176 } |
| 176 | 177 |
| 177 DOMWindow* CreateWindow(const String& url_string, | 178 DOMWindow* CreateWindow(const String& url_string, |
| 178 const AtomicString& frame_name, | 179 const AtomicString& frame_name, |
| 179 const WindowFeatures& window_features, | 180 const WindowFeatures& window_features, |
| 180 LocalDOMWindow& calling_window, | 181 LocalDOMWindow& calling_window, |
| 181 LocalFrame& first_frame, | 182 LocalFrame& first_frame, |
| 182 LocalFrame& opener_frame) { | 183 LocalFrame& opener_frame, |
| 184 ExceptionState& exception_state) { |
| 183 LocalFrame* active_frame = calling_window.GetFrame(); | 185 LocalFrame* active_frame = calling_window.GetFrame(); |
| 184 ASSERT(active_frame); | 186 ASSERT(active_frame); |
| 185 | 187 |
| 186 KURL completed_url = url_string.IsEmpty() | 188 KURL completed_url = url_string.IsEmpty() |
| 187 ? KURL(kParsedURLString, g_empty_string) | 189 ? KURL(kParsedURLString, g_empty_string) |
| 188 : first_frame.GetDocument()->CompleteURL(url_string); | 190 : first_frame.GetDocument()->CompleteURL(url_string); |
| 189 if (!completed_url.IsEmpty() && !completed_url.IsValid()) { | 191 if (!completed_url.IsEmpty() && !completed_url.IsValid()) { |
| 190 UseCounter::Count(active_frame, UseCounter::kWindowOpenWithInvalidURL); | 192 UseCounter::Count(active_frame, UseCounter::kWindowOpenWithInvalidURL); |
| 191 // Don't expose client code to invalid URLs. | 193 exception_state.ThrowDOMException( |
| 192 calling_window.PrintErrorMessage( | 194 kSyntaxError, "Unable to open a window with invalid URL '" + |
| 193 "Unable to open a window with invalid URL '" + | 195 completed_url.GetString() + "'.\n"); |
| 194 completed_url.GetString() + "'.\n"); | |
| 195 return nullptr; | 196 return nullptr; |
| 196 } | 197 } |
| 197 | 198 |
| 198 FrameLoadRequest frame_request(calling_window.document(), | 199 FrameLoadRequest frame_request(calling_window.document(), |
| 199 ResourceRequest(completed_url), frame_name); | 200 ResourceRequest(completed_url), frame_name); |
| 200 frame_request.SetShouldSetOpener(window_features.noopener ? kNeverSetOpener | 201 frame_request.SetShouldSetOpener(window_features.noopener ? kNeverSetOpener |
| 201 : kMaybeSetOpener); | 202 : kMaybeSetOpener); |
| 202 frame_request.GetResourceRequest().SetFrameType( | 203 frame_request.GetResourceRequest().SetFrameType( |
| 203 WebURLRequest::kFrameTypeAuxiliary); | 204 WebURLRequest::kFrameTypeAuxiliary); |
| 204 frame_request.GetResourceRequest().SetRequestorOrigin( | 205 frame_request.GetResourceRequest().SetRequestorOrigin( |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 293 } |
| 293 | 294 |
| 294 // TODO(japhet): Form submissions on RemoteFrames don't work yet. | 295 // TODO(japhet): Form submissions on RemoteFrames don't work yet. |
| 295 FrameLoadRequest new_request(0, request.GetResourceRequest()); | 296 FrameLoadRequest new_request(0, request.GetResourceRequest()); |
| 296 new_request.SetForm(request.Form()); | 297 new_request.SetForm(request.Form()); |
| 297 if (new_frame->IsLocalFrame()) | 298 if (new_frame->IsLocalFrame()) |
| 298 ToLocalFrame(new_frame)->Loader().Load(new_request); | 299 ToLocalFrame(new_frame)->Loader().Load(new_request); |
| 299 } | 300 } |
| 300 | 301 |
| 301 } // namespace blink | 302 } // namespace blink |
| OLD | NEW |