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

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: Add Unit Test. 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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 1135
1136 void ViewSource(Browser* browser, WebContents* contents) { 1136 void ViewSource(Browser* browser, WebContents* contents) {
1137 DCHECK(contents); 1137 DCHECK(contents);
1138 1138
1139 // Use the last committed entry, since the pending entry hasn't loaded yet and 1139 // Use the last committed entry, since the pending entry hasn't loaded yet and
1140 // won't be copied into the cloned tab. 1140 // won't be copied into the cloned tab.
1141 NavigationEntry* entry = contents->GetController().GetLastCommittedEntry(); 1141 NavigationEntry* entry = contents->GetController().GetLastCommittedEntry();
1142 if (!entry) 1142 if (!entry)
1143 return; 1143 return;
1144 1144
1145 // A "data:," URL may represent blink's blocked-page URL, and blink may have
1146 // saved state prior to the block. Show that page instead when present.
1147 if (entry->GetURL() == GURL("data:,")) {
1148 NavigationEntry* blocked = contents->GetController().GetBlockedPageEntry();
1149 if (blocked)
1150 entry = blocked;
1151 }
1152
1145 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState()); 1153 ViewSource(browser, contents, entry->GetURL(), entry->GetPageState());
1146 } 1154 }
1147 1155
1148 void ViewSource(Browser* browser, 1156 void ViewSource(Browser* browser,
1149 WebContents* contents, 1157 WebContents* contents,
1150 const GURL& url, 1158 const GURL& url,
1151 const content::PageState& page_state) { 1159 const content::PageState& page_state) {
1152 content::RecordAction(UserMetricsAction("ViewSource")); 1160 content::RecordAction(UserMetricsAction("ViewSource"));
1153 DCHECK(contents); 1161 DCHECK(contents);
1154 1162
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 browser->profile(), 1268 browser->profile(),
1261 browser->host_desktop_type())); 1269 browser->host_desktop_type()));
1262 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1270 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1263 1271
1264 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1272 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1265 contents->GetRenderViewHost()->SyncRendererPrefs(); 1273 contents->GetRenderViewHost()->SyncRendererPrefs();
1266 app_browser->window()->Show(); 1274 app_browser->window()->Show();
1267 } 1275 }
1268 1276
1269 } // namespace chrome 1277 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698