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

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

Issue 2501083004: Fix View Frame Source for iframe of a file:// URL shows main frame's filename (Closed)
Patch Set: Adding a browsertest Created 4 years, 1 month 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
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_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 DCHECK(view_source_contents->GetController().CanPruneAllButLastCommitted()); 1227 DCHECK(view_source_contents->GetController().CanPruneAllButLastCommitted());
1228 view_source_contents->GetController().PruneAllButLastCommitted(); 1228 view_source_contents->GetController().PruneAllButLastCommitted();
1229 NavigationEntry* last_committed_entry = 1229 NavigationEntry* last_committed_entry =
1230 view_source_contents->GetController().GetLastCommittedEntry(); 1230 view_source_contents->GetController().GetLastCommittedEntry();
1231 if (!last_committed_entry) 1231 if (!last_committed_entry)
1232 return; 1232 return;
1233 1233
1234 GURL view_source_url = 1234 GURL view_source_url =
1235 GURL(content::kViewSourceScheme + std::string(":") + url.spec()); 1235 GURL(content::kViewSourceScheme + std::string(":") + url.spec());
1236 last_committed_entry->SetVirtualURL(view_source_url); 1236 last_committed_entry->SetVirtualURL(view_source_url);
1237 last_committed_entry->SetURL(GURL());
Charlie Reis 2016/11/23 23:52:20 Maybe it would make more sense to set this to |url
afakhry 2016/11/24 01:21:09 Thanks for the suggestion! It works. Done.
1237 1238
1238 // Do not restore scroller position. 1239 // Do not restore scroller position.
1239 last_committed_entry->SetPageState(page_state.RemoveScrollOffset()); 1240 last_committed_entry->SetPageState(page_state.RemoveScrollOffset());
1240 1241
1241 // Do not restore title, derive it from the url. 1242 // Do not restore title, derive it from the url.
1242 view_source_contents->UpdateTitleForEntry(last_committed_entry, 1243 view_source_contents->UpdateTitleForEntry(last_committed_entry,
1243 base::string16()); 1244 base::string16());
1244 1245
1245 // Now show view-source entry. 1246 // Now show view-source entry.
1246 if (browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) { 1247 if (browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP)) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); 1330 app_name, true /* trusted_source */, gfx::Rect(), browser->profile()));
1330 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1331 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1331 1332
1332 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1333 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1333 contents->GetRenderViewHost()->SyncRendererPrefs(); 1334 contents->GetRenderViewHost()->SyncRendererPrefs();
1334 app_browser->window()->Show(); 1335 app_browser->window()->Show();
1335 } 1336 }
1336 #endif // BUILDFLAG(ENABLE_EXTENSIONS) 1337 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
1337 1338
1338 } // namespace chrome 1339 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698