OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "chrome/browser/ui/browser_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 | 1139 |
1140 void ViewSource(Browser* browser, WebContents* contents) { | 1140 void ViewSource(Browser* browser, WebContents* contents) { |
1141 DCHECK(contents); | 1141 DCHECK(contents); |
1142 | 1142 |
1143 // Use the last committed entry, since the pending entry hasn't loaded yet and | 1143 // Use the last committed entry, since the pending entry hasn't loaded yet and |
1144 // won't be copied into the cloned tab. | 1144 // won't be copied into the cloned tab. |
1145 NavigationEntry* entry = contents->GetController().GetLastCommittedEntry(); | 1145 NavigationEntry* entry = contents->GetController().GetLastCommittedEntry(); |
1146 if (!entry) | 1146 if (!entry) |
1147 return; | 1147 return; |
1148 | 1148 |
1149 // If blink sent us to its blocked-page URL, show the source of the previous | |
brettw
2014/06/18 21:51:41
Can this explain in more detail what happens when
Tom Sepez
2014/06/18 22:13:22
Done.
| |
1150 // page (which generated the block) instead. | |
1151 if (entry->GetURL() == GURL("data:,")) { | |
1152 NavigationEntry* previous = contents->GetController().GetEntryAtOffset(-1); | |
1153 if (previous && previous->GetXssDetected()) | |
1154 entry = previous; | |
1155 } | |
1156 | |
1149 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState()); | 1157 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState()); |
1150 } | 1158 } |
1151 | 1159 |
1152 void ViewSource(Browser* browser, | 1160 void ViewSource(Browser* browser, |
1153 WebContents* contents, | 1161 WebContents* contents, |
1154 const GURL& url, | 1162 const GURL& url, |
1155 const content::PageState& page_state) { | 1163 const content::PageState& page_state) { |
1156 content::RecordAction(UserMetricsAction("ViewSource")); | 1164 content::RecordAction(UserMetricsAction("ViewSource")); |
1157 DCHECK(contents); | 1165 DCHECK(contents); |
1158 | 1166 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1264 browser->profile(), | 1272 browser->profile(), |
1265 browser->host_desktop_type())); | 1273 browser->host_desktop_type())); |
1266 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1274 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1267 | 1275 |
1268 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1276 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1269 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1277 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1270 app_browser->window()->Show(); | 1278 app_browser->window()->Show(); |
1271 } | 1279 } |
1272 | 1280 |
1273 } // namespace chrome | 1281 } // namespace chrome |
OLD | NEW |