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

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

Issue 15041004: Replace PruneAllButActive with PruneAllButVisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update tests, mark TODOs Created 7 years, 7 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/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 void ViewSource(Browser* browser, 996 void ViewSource(Browser* browser,
997 WebContents* contents, 997 WebContents* contents,
998 const GURL& url, 998 const GURL& url,
999 const std::string& content_state) { 999 const std::string& content_state) {
1000 content::RecordAction(UserMetricsAction("ViewSource")); 1000 content::RecordAction(UserMetricsAction("ViewSource"));
1001 DCHECK(contents); 1001 DCHECK(contents);
1002 1002
1003 // Note that Clone does not copy the pending or transient entries, so the 1003 // Note that Clone does not copy the pending or transient entries, so the
1004 // active entry in view_source_contents will be the last committed entry. 1004 // active entry in view_source_contents will be the last committed entry.
1005 WebContents* view_source_contents = contents->Clone(); 1005 WebContents* view_source_contents = contents->Clone();
1006 view_source_contents->GetController().PruneAllButActive(); 1006 DCHECK(view_source_contents->GetController().CanPruneAllButVisible());
1007 if (!view_source_contents->GetController().PruneAllButVisible())
1008 return;
1007 NavigationEntry* active_entry = 1009 NavigationEntry* active_entry =
1008 view_source_contents->GetController().GetActiveEntry(); 1010 view_source_contents->GetController().GetActiveEntry();
1009 if (!active_entry) 1011 if (!active_entry)
1010 return; 1012 return;
1011 1013
1012 GURL view_source_url = GURL(kViewSourceScheme + std::string(":") + 1014 GURL view_source_url = GURL(kViewSourceScheme + std::string(":") +
1013 url.spec()); 1015 url.spec());
1014 active_entry->SetVirtualURL(view_source_url); 1016 active_entry->SetVirtualURL(view_source_url);
1015 1017
1016 // Do not restore scroller position. 1018 // Do not restore scroller position.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(), 1096 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(),
1095 browser->host_desktop_type())); 1097 browser->host_desktop_type()));
1096 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1098 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1097 1099
1098 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1100 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1099 contents->GetRenderViewHost()->SyncRendererPrefs(); 1101 contents->GetRenderViewHost()->SyncRendererPrefs();
1100 app_browser->window()->Show(); 1102 app_browser->window()->Show();
1101 } 1103 }
1102 1104
1103 } // namespace chrome 1105 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698