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

Side by Side Diff: chrome/browser/ui/browser_commands.cc

Issue 304313003: Allow view-source of pages fully-blocked by Blink's XSS filter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove stray debugging include. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1137
1138 void ViewSource(Browser* browser, WebContents* contents) { 1138 void ViewSource(Browser* browser, WebContents* contents) {
1139 DCHECK(contents); 1139 DCHECK(contents);
1140 1140
1141 // Use the last committed entry, since the pending entry hasn't loaded yet and 1141 // Use the last committed entry, since the pending entry hasn't loaded yet and
1142 // won't be copied into the cloned tab. 1142 // won't be copied into the cloned tab.
1143 NavigationEntry* entry = contents->GetController().GetLastCommittedEntry(); 1143 NavigationEntry* entry = contents->GetController().GetLastCommittedEntry();
1144 if (!entry) 1144 if (!entry)
1145 return; 1145 return;
1146 1146
1147 // If blink sent us to its blocked-page URL, show the source of the previous
1148 // page (which generated the block) instead.
1149 if (entry->GetURL() == GURL("data:,Blocked")) {
1150 NavigationEntry* previous = contents->GetController().GetEntryAtOffset(-1);
1151 if (previous) {
1152 base::string16 value;
1153 if (previous->GetExtraData("XSSDetected", &value) &&
1154 value == base::ASCIIToUTF16("1")) {
1155 entry = previous;
1156 }
1157 }
1158 }
1159
1147 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState()); 1160 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState());
1148 } 1161 }
1149 1162
1150 void ViewSource(Browser* browser, 1163 void ViewSource(Browser* browser,
1151 WebContents* contents, 1164 WebContents* contents,
1152 const GURL& url, 1165 const GURL& url,
1153 const content::PageState& page_state) { 1166 const content::PageState& page_state) {
1154 content::RecordAction(UserMetricsAction("ViewSource")); 1167 content::RecordAction(UserMetricsAction("ViewSource"));
1155 DCHECK(contents); 1168 DCHECK(contents);
1156 1169
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 browser->profile(), 1277 browser->profile(),
1265 browser->host_desktop_type())); 1278 browser->host_desktop_type()));
1266 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1279 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1267 1280
1268 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1281 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1269 contents->GetRenderViewHost()->SyncRendererPrefs(); 1282 contents->GetRenderViewHost()->SyncRendererPrefs();
1270 app_browser->window()->Show(); 1283 app_browser->window()->Show();
1271 } 1284 }
1272 1285
1273 } // namespace chrome 1286 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.h » ('j') | content/browser/web_contents/web_contents_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698