OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/render_view.h" | 5 #include "content/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2076 IsNonLocalTopLevelNavigation(url, frame, type)) { | 2076 IsNonLocalTopLevelNavigation(url, frame, type)) { |
2077 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2077 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
2078 // Reset these counters as the RenderView could be reused for the next | 2078 // Reset these counters as the RenderView could be reused for the next |
2079 // navigation. | 2079 // navigation. |
2080 page_id_ = -1; | 2080 page_id_ = -1; |
2081 last_page_id_sent_to_browser_ = -1; | 2081 last_page_id_sent_to_browser_ = -1; |
2082 OpenURL(url, referrer, default_policy); | 2082 OpenURL(url, referrer, default_policy); |
2083 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2083 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
2084 } | 2084 } |
2085 | 2085 |
2086 GURL old_url(frame->document().url()); | |
2087 | |
2088 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 2086 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
2089 // an extension or app origin, leaving a WebUI page, etc). We only care about | 2087 // an extension or app origin, leaving a WebUI page, etc). We only care about |
2090 // top-level navigations within the current tab (as opposed to, for example, | 2088 // top-level navigations within the current tab (as opposed to, for example, |
2091 // opening a new window). But we sometimes navigate to about:blank to clear a | 2089 // opening a new window). But we sometimes navigate to about:blank to clear a |
2092 // tab, and we want to still allow that. | 2090 // tab, and we want to still allow that. |
2093 // | 2091 // |
2094 // Note: we do this only for GET requests because our mechanism for switching | 2092 // Note: we do this only for GET requests because our mechanism for switching |
2095 // processes only issues GET requests. In particular, POST requests don't | 2093 // processes only issues GET requests. In particular, POST requests don't |
2096 // work, because this mechanism does not preserve form POST data. If it | 2094 // work, because this mechanism does not preserve form POST data. If it |
2097 // becomes necessary to support process switching for POST requests, we will | 2095 // becomes necessary to support process switching for POST requests, we will |
(...skipping 25 matching lines...) Expand all Loading... | |
2123 &send_referrer); | 2121 &send_referrer); |
2124 } | 2122 } |
2125 | 2123 |
2126 if (should_fork) { | 2124 if (should_fork) { |
2127 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2125 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
2128 OpenURL(url, send_referrer ? referrer : GURL(), default_policy); | 2126 OpenURL(url, send_referrer ? referrer : GURL(), default_policy); |
2129 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2127 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
2130 } | 2128 } |
2131 } | 2129 } |
2132 | 2130 |
2131 // Use the request's URL rather than the document's URL for this check. For | |
Matt Perry
2011/08/25 18:45:20
nit: say something like "the frame's original requ
Charlie Reis
2011/08/25 22:07:31
Done.
| |
2132 // a popup, the document's URL may become the opener window's URL if the | |
2133 // opener has called document.write. See http://crbug.com/93517. | |
2134 GURL old_url(frame->dataSource()->request().url()); | |
2135 | |
2133 // Detect when a page is "forking" a new tab that can be safely rendered in | 2136 // Detect when a page is "forking" a new tab that can be safely rendered in |
2134 // its own process. This is done by sites like Gmail that try to open links | 2137 // its own process. This is done by sites like Gmail that try to open links |
2135 // in new windows without script connections back to the original page. We | 2138 // in new windows without script connections back to the original page. We |
2136 // treat such cases as browser navigations (in which we will create a new | 2139 // treat such cases as browser navigations (in which we will create a new |
2137 // renderer for a cross-site navigation), rather than WebKit navigations. | 2140 // renderer for a cross-site navigation), rather than WebKit navigations. |
2138 // | 2141 // |
2139 // We use the following heuristic to decide whether to fork a new page in its | 2142 // We use the following heuristic to decide whether to fork a new page in its |
2140 // own process: | 2143 // own process: |
2141 // The parent page must open a new tab to about:blank, set the new tab's | 2144 // The parent page must open a new tab to about:blank, set the new tab's |
2142 // window.opener to null, and then redirect the tab to a cross-site URL using | 2145 // window.opener to null, and then redirect the tab to a cross-site URL using |
(...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4562 | 4565 |
4563 void RenderView::OnEnableViewSourceMode() { | 4566 void RenderView::OnEnableViewSourceMode() { |
4564 if (!webview()) | 4567 if (!webview()) |
4565 return; | 4568 return; |
4566 WebFrame* main_frame = webview()->mainFrame(); | 4569 WebFrame* main_frame = webview()->mainFrame(); |
4567 if (!main_frame) | 4570 if (!main_frame) |
4568 return; | 4571 return; |
4569 main_frame->enableViewSourceMode(true); | 4572 main_frame->enableViewSourceMode(true); |
4570 } | 4573 } |
4571 | 4574 |
OLD | NEW |