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

Side by Side Diff: third_party/WebKit/Source/core/page/CreateWindow.cpp

Issue 2716153003: Removed FrameHost::chromeClient() (Closed)
Patch Set: Small feedback Created 3 years, 9 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) 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
(...skipping 10 matching lines...) Expand all
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 "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/frame/FrameClient.h" 30 #include "core/frame/FrameClient.h"
31 #include "core/frame/FrameHost.h"
32 #include "core/frame/LocalFrame.h" 31 #include "core/frame/LocalFrame.h"
33 #include "core/frame/Settings.h" 32 #include "core/frame/Settings.h"
34 #include "core/inspector/ConsoleMessage.h" 33 #include "core/inspector/ConsoleMessage.h"
35 #include "core/inspector/InspectorInstrumentation.h" 34 #include "core/inspector/InspectorInstrumentation.h"
36 #include "core/loader/FrameLoadRequest.h" 35 #include "core/loader/FrameLoadRequest.h"
37 #include "core/page/ChromeClient.h" 36 #include "core/page/ChromeClient.h"
38 #include "core/page/FocusController.h" 37 #include "core/page/FocusController.h"
39 #include "core/page/Page.h" 38 #include "core/page/Page.h"
40 #include "core/page/WindowFeatures.h" 39 #include "core/page/WindowFeatures.h"
41 #include "platform/UserGestureIndicator.h" 40 #include "platform/UserGestureIndicator.h"
42 #include "platform/network/ResourceRequest.h" 41 #include "platform/network/ResourceRequest.h"
43 #include "platform/weborigin/KURL.h" 42 #include "platform/weborigin/KURL.h"
44 #include "platform/weborigin/SecurityOrigin.h" 43 #include "platform/weborigin/SecurityOrigin.h"
45 #include "platform/weborigin/SecurityPolicy.h" 44 #include "platform/weborigin/SecurityPolicy.h"
46 #include "public/platform/WebURLRequest.h" 45 #include "public/platform/WebURLRequest.h"
47 46
48 namespace blink { 47 namespace blink {
49 48
50 static Frame* reuseExistingWindow(LocalFrame& activeFrame, 49 static Frame* reuseExistingWindow(LocalFrame& activeFrame,
51 LocalFrame& lookupFrame, 50 LocalFrame& lookupFrame,
52 const AtomicString& frameName, 51 const AtomicString& frameName,
53 NavigationPolicy policy) { 52 NavigationPolicy policy) {
54 if (!frameName.isEmpty() && frameName != "_blank" && 53 if (!frameName.isEmpty() && frameName != "_blank" &&
55 policy == NavigationPolicyIgnore) { 54 policy == NavigationPolicyIgnore) {
56 if (Frame* frame = 55 if (Frame* frame =
57 lookupFrame.findFrameForNavigation(frameName, activeFrame)) { 56 lookupFrame.findFrameForNavigation(frameName, activeFrame)) {
58 if (frameName != "_self") { 57 if (frameName != "_self") {
59 if (FrameHost* host = frame->host()) { 58 if (Page* page = frame->page()) {
60 if (host == activeFrame.host()) 59 if (page == activeFrame.page())
61 frame->page()->focusController().setFocusedFrame(frame); 60 page->focusController().setFocusedFrame(frame);
62 else 61 else
63 host->chromeClient().focus(); 62 page->chromeClient().focus();
64 } 63 }
65 } 64 }
66 return frame; 65 return frame;
67 } 66 }
68 } 67 }
69 return nullptr; 68 return nullptr;
70 } 69 }
71 70
72 static Frame* createNewWindow(LocalFrame& openerFrame, 71 static Frame* createNewWindow(LocalFrame& openerFrame,
73 const FrameLoadRequest& request, 72 const FrameLoadRequest& request,
74 const WindowFeatures& features, 73 const WindowFeatures& features,
75 NavigationPolicy policy, 74 NavigationPolicy policy,
76 bool& created) { 75 bool& created) {
77 FrameHost* oldHost = openerFrame.host(); 76 Page* oldPage = openerFrame.page();
78 if (!oldHost) 77 if (!oldPage)
79 return nullptr; 78 return nullptr;
80 79
81 Page* page = oldHost->chromeClient().createWindow(&openerFrame, request, 80 Page* page = oldPage->chromeClient().createWindow(&openerFrame, request,
82 features, policy); 81 features, policy);
83 if (!page) 82 if (!page)
84 return nullptr; 83 return nullptr;
85 FrameHost* host = &page->frameHost();
86 84
87 ASSERT(page->mainFrame()); 85 ASSERT(page->mainFrame());
88 LocalFrame& frame = *toLocalFrame(page->mainFrame()); 86 LocalFrame& frame = *toLocalFrame(page->mainFrame());
89 87
90 if (request.frameName() != "_blank") 88 if (request.frameName() != "_blank")
91 frame.tree().setName(request.frameName()); 89 frame.tree().setName(request.frameName());
92 90
93 host->chromeClient().setWindowFeatures(features); 91 page->chromeClient().setWindowFeatures(features);
94 92
95 // 'x' and 'y' specify the location of the window, while 'width' and 'height' 93 // 'x' and 'y' specify the location of the window, while 'width' and 'height'
96 // specify the size of the viewport. We can only resize the window, so adjust 94 // specify the size of the viewport. We can only resize the window, so adjust
97 // for the difference between the window size and the viewport size. 95 // for the difference between the window size and the viewport size.
98 96
99 IntRect windowRect = host->chromeClient().rootWindowRect(); 97 IntRect windowRect = page->chromeClient().rootWindowRect();
100 IntSize viewportSize = host->chromeClient().pageRect().size(); 98 IntSize viewportSize = page->chromeClient().pageRect().size();
101 99
102 if (features.xSet) 100 if (features.xSet)
103 windowRect.setX(features.x); 101 windowRect.setX(features.x);
104 if (features.ySet) 102 if (features.ySet)
105 windowRect.setY(features.y); 103 windowRect.setY(features.y);
106 if (features.widthSet) 104 if (features.widthSet)
107 windowRect.setWidth(features.width + 105 windowRect.setWidth(features.width +
108 (windowRect.width() - viewportSize.width())); 106 (windowRect.width() - viewportSize.width()));
109 if (features.heightSet) 107 if (features.heightSet)
110 windowRect.setHeight(features.height + 108 windowRect.setHeight(features.height +
111 (windowRect.height() - viewportSize.height())); 109 (windowRect.height() - viewportSize.height()));
112 110
113 host->chromeClient().setWindowRectWithAdjustment(windowRect, frame); 111 page->chromeClient().setWindowRectWithAdjustment(windowRect, frame);
114 host->chromeClient().show(policy); 112 page->chromeClient().show(policy);
115 113
116 if (openerFrame.document()->isSandboxed( 114 if (openerFrame.document()->isSandboxed(
117 SandboxPropagatesToAuxiliaryBrowsingContexts)) 115 SandboxPropagatesToAuxiliaryBrowsingContexts))
118 frame.loader().forceSandboxFlags( 116 frame.loader().forceSandboxFlags(
119 openerFrame.securityContext()->getSandboxFlags()); 117 openerFrame.securityContext()->getSandboxFlags());
120 118
121 // This call may suspend the execution by running nested message loop. 119 // This call may suspend the execution by running nested message loop.
122 InspectorInstrumentation::windowCreated(&openerFrame, &frame); 120 InspectorInstrumentation::windowCreated(&openerFrame, &frame);
123 created = true; 121 created = true;
124 return &frame; 122 return &frame;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 287 }
290 288
291 // TODO(japhet): Form submissions on RemoteFrames don't work yet. 289 // TODO(japhet): Form submissions on RemoteFrames don't work yet.
292 FrameLoadRequest newRequest(0, request.resourceRequest()); 290 FrameLoadRequest newRequest(0, request.resourceRequest());
293 newRequest.setForm(request.form()); 291 newRequest.setForm(request.form());
294 if (newFrame->isLocalFrame()) 292 if (newFrame->isLocalFrame())
295 toLocalFrame(newFrame)->loader().load(newRequest); 293 toLocalFrame(newFrame)->loader().load(newRequest);
296 } 294 }
297 295
298 } // namespace blink 296 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/TextFieldInputType.cpp ('k') | third_party/WebKit/Source/core/page/Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698