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