| 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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 void ViewSource(Browser* browser, | 1050 void ViewSource(Browser* browser, |
| 1051 WebContents* contents, | 1051 WebContents* contents, |
| 1052 const GURL& url, | 1052 const GURL& url, |
| 1053 const content::PageState& page_state) { | 1053 const content::PageState& page_state) { |
| 1054 content::RecordAction(UserMetricsAction("ViewSource")); | 1054 content::RecordAction(UserMetricsAction("ViewSource")); |
| 1055 DCHECK(contents); | 1055 DCHECK(contents); |
| 1056 | 1056 |
| 1057 // Note that Clone does not copy the pending or transient entries, so the | 1057 // Note that Clone does not copy the pending or transient entries, so the |
| 1058 // active entry in view_source_contents will be the last committed entry. | 1058 // active entry in view_source_contents will be the last committed entry. |
| 1059 WebContents* view_source_contents = contents->Clone(); | 1059 WebContents* view_source_contents = contents->Clone(); |
| 1060 DCHECK(view_source_contents->GetController().CanPruneAllButVisible()); | 1060 DCHECK(view_source_contents->GetController().CanPruneAllButLastCommitted()); |
| 1061 view_source_contents->GetController().PruneAllButVisible(); | 1061 view_source_contents->GetController().PruneAllButLastCommitted(); |
| 1062 NavigationEntry* active_entry = | 1062 NavigationEntry* active_entry = |
| 1063 view_source_contents->GetController().GetActiveEntry(); | 1063 view_source_contents->GetController().GetActiveEntry(); |
| 1064 if (!active_entry) | 1064 if (!active_entry) |
| 1065 return; | 1065 return; |
| 1066 | 1066 |
| 1067 GURL view_source_url = | 1067 GURL view_source_url = |
| 1068 GURL(content::kViewSourceScheme + std::string(":") + url.spec()); | 1068 GURL(content::kViewSourceScheme + std::string(":") + url.spec()); |
| 1069 active_entry->SetVirtualURL(view_source_url); | 1069 active_entry->SetVirtualURL(view_source_url); |
| 1070 | 1070 |
| 1071 // Do not restore scroller position. | 1071 // Do not restore scroller position. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(), | 1148 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(), |
| 1149 browser->host_desktop_type())); | 1149 browser->host_desktop_type())); |
| 1150 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1150 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1151 | 1151 |
| 1152 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1152 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1153 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1153 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1154 app_browser->window()->Show(); | 1154 app_browser->window()->Show(); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 } // namespace chrome | 1157 } // namespace chrome |
| OLD | NEW |