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 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 IsNonLocalTopLevelNavigation(url, frame, type)) { | 2085 IsNonLocalTopLevelNavigation(url, frame, type)) { |
2086 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2086 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
2087 // Reset these counters as the RenderView could be reused for the next | 2087 // Reset these counters as the RenderView could be reused for the next |
2088 // navigation. | 2088 // navigation. |
2089 page_id_ = -1; | 2089 page_id_ = -1; |
2090 last_page_id_sent_to_browser_ = -1; | 2090 last_page_id_sent_to_browser_ = -1; |
2091 OpenURL(url, referrer, default_policy); | 2091 OpenURL(url, referrer, default_policy); |
2092 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2092 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
2093 } | 2093 } |
2094 | 2094 |
2095 GURL old_url(frame->document().url()); | |
2096 | |
2097 // Detect when we're crossing a permission-based boundary (e.g. into or out of | 2095 // Detect when we're crossing a permission-based boundary (e.g. into or out of |
2098 // an extension or app origin, leaving a WebUI page, etc). We only care about | 2096 // an extension or app origin, leaving a WebUI page, etc). We only care about |
2099 // top-level navigations within the current tab (as opposed to, for example, | 2097 // top-level navigations within the current tab (as opposed to, for example, |
2100 // opening a new window). But we sometimes navigate to about:blank to clear a | 2098 // opening a new window). But we sometimes navigate to about:blank to clear a |
2101 // tab, and we want to still allow that. | 2099 // tab, and we want to still allow that. |
2102 // | 2100 // |
2103 // Note: we do this only for GET requests because our mechanism for switching | 2101 // Note: we do this only for GET requests because our mechanism for switching |
2104 // processes only issues GET requests. In particular, POST requests don't | 2102 // processes only issues GET requests. In particular, POST requests don't |
2105 // work, because this mechanism does not preserve form POST data. If it | 2103 // work, because this mechanism does not preserve form POST data. If it |
2106 // becomes necessary to support process switching for POST requests, we will | 2104 // becomes necessary to support process switching for POST requests, we will |
(...skipping 25 matching lines...) Expand all Loading... |
2132 &send_referrer); | 2130 &send_referrer); |
2133 } | 2131 } |
2134 | 2132 |
2135 if (should_fork) { | 2133 if (should_fork) { |
2136 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); | 2134 GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
2137 OpenURL(url, send_referrer ? referrer : GURL(), default_policy); | 2135 OpenURL(url, send_referrer ? referrer : GURL(), default_policy); |
2138 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. | 2136 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
2139 } | 2137 } |
2140 } | 2138 } |
2141 | 2139 |
| 2140 // Use the frame's original request's URL rather than the document's URL for |
| 2141 // this check. For a popup, the document's URL may become the opener window's |
| 2142 // URL if the opener has called document.write. See http://crbug.com/93517. |
| 2143 GURL old_url(frame->dataSource()->request().url()); |
| 2144 |
2142 // Detect when a page is "forking" a new tab that can be safely rendered in | 2145 // Detect when a page is "forking" a new tab that can be safely rendered in |
2143 // its own process. This is done by sites like Gmail that try to open links | 2146 // its own process. This is done by sites like Gmail that try to open links |
2144 // in new windows without script connections back to the original page. We | 2147 // in new windows without script connections back to the original page. We |
2145 // treat such cases as browser navigations (in which we will create a new | 2148 // treat such cases as browser navigations (in which we will create a new |
2146 // renderer for a cross-site navigation), rather than WebKit navigations. | 2149 // renderer for a cross-site navigation), rather than WebKit navigations. |
2147 // | 2150 // |
2148 // We use the following heuristic to decide whether to fork a new page in its | 2151 // We use the following heuristic to decide whether to fork a new page in its |
2149 // own process: | 2152 // own process: |
2150 // The parent page must open a new tab to about:blank, set the new tab's | 2153 // The parent page must open a new tab to about:blank, set the new tab's |
2151 // window.opener to null, and then redirect the tab to a cross-site URL using | 2154 // window.opener to null, and then redirect the tab to a cross-site URL using |
(...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4582 } | 4585 } |
4583 | 4586 |
4584 void RenderView::OnEnableViewSourceMode() { | 4587 void RenderView::OnEnableViewSourceMode() { |
4585 if (!webview()) | 4588 if (!webview()) |
4586 return; | 4589 return; |
4587 WebFrame* main_frame = webview()->mainFrame(); | 4590 WebFrame* main_frame = webview()->mainFrame(); |
4588 if (!main_frame) | 4591 if (!main_frame) |
4589 return; | 4592 return; |
4590 main_frame->enableViewSourceMode(true); | 4593 main_frame->enableViewSourceMode(true); |
4591 } | 4594 } |
OLD | NEW |