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

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: Rebase 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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 void ViewSource(Browser* browser, 1002 void ViewSource(Browser* browser,
1003 WebContents* contents, 1003 WebContents* contents,
1004 const GURL& url, 1004 const GURL& url,
1005 const std::string& content_state) { 1005 const std::string& content_state) {
1006 content::RecordAction(UserMetricsAction("ViewSource")); 1006 content::RecordAction(UserMetricsAction("ViewSource"));
1007 DCHECK(contents); 1007 DCHECK(contents);
1008 1008
1009 // Note that Clone does not copy the pending or transient entries, so the 1009 // Note that Clone does not copy the pending or transient entries, so the
1010 // active entry in view_source_contents will be the last committed entry. 1010 // active entry in view_source_contents will be the last committed entry.
1011 WebContents* view_source_contents = contents->Clone(); 1011 WebContents* view_source_contents = contents->Clone();
1012 view_source_contents->GetController().PruneAllButActive(); 1012 DCHECK(view_source_contents->GetController().CanPruneAllButVisible());
1013 if (!view_source_contents->GetController().PruneAllButVisible())
1014 return;
1013 NavigationEntry* active_entry = 1015 NavigationEntry* active_entry =
1014 view_source_contents->GetController().GetActiveEntry(); 1016 view_source_contents->GetController().GetActiveEntry();
1015 if (!active_entry) 1017 if (!active_entry)
1016 return; 1018 return;
1017 1019
1018 GURL view_source_url = GURL(kViewSourceScheme + std::string(":") + 1020 GURL view_source_url = GURL(kViewSourceScheme + std::string(":") +
1019 url.spec()); 1021 url.spec());
1020 active_entry->SetVirtualURL(view_source_url); 1022 active_entry->SetVirtualURL(view_source_url);
1021 1023
1022 // Do not restore scroller position. 1024 // Do not restore scroller position.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(), 1102 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(),
1101 browser->host_desktop_type())); 1103 browser->host_desktop_type()));
1102 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1104 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1103 1105
1104 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1106 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1105 contents->GetRenderViewHost()->SyncRendererPrefs(); 1107 contents->GetRenderViewHost()->SyncRendererPrefs();
1106 app_browser->window()->Show(); 1108 app_browser->window()->Show();
1107 } 1109 }
1108 1110
1109 } // namespace chrome 1111 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698