| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_editor.h" | 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 void ViewSelectedSource(Browser* browser) { | 1008 void ViewSelectedSource(Browser* browser) { |
| 1009 ViewSource(browser, GetActiveTabContents(browser)); | 1009 ViewSource(browser, GetActiveTabContents(browser)); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 bool CanViewSource(const Browser* browser) { | 1012 bool CanViewSource(const Browser* browser) { |
| 1013 return GetActiveWebContents(browser)->GetController().CanViewSource(); | 1013 return GetActiveWebContents(browser)->GetController().CanViewSource(); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 void CreateApplicationShortcuts(Browser* browser) { | 1016 void CreateApplicationShortcuts(Browser* browser) { |
| 1017 content::RecordAction(UserMetricsAction("CreateShortcut")); | 1017 content::RecordAction(UserMetricsAction("CreateShortcut")); |
| 1018 GetActiveTabContents(browser)->extension_tab_helper()-> | 1018 extensions::TabHelper::FromWebContents(GetActiveWebContents(browser))-> |
| 1019 CreateApplicationShortcuts(); | 1019 CreateApplicationShortcuts(); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 bool CanCreateApplicationShortcuts(const Browser* browser) { | 1022 bool CanCreateApplicationShortcuts(const Browser* browser) { |
| 1023 return GetActiveTabContents(browser)->extension_tab_helper()-> | 1023 return extensions::TabHelper::FromWebContents(GetActiveWebContents(browser))-> |
| 1024 CanCreateApplicationShortcuts(); | 1024 CanCreateApplicationShortcuts(); |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 void ConvertTabToAppWindow(Browser* browser, | 1027 void ConvertTabToAppWindow(Browser* browser, |
| 1028 content::WebContents* contents) { | 1028 content::WebContents* contents) { |
| 1029 const GURL& url = contents->GetController().GetActiveEntry()->GetURL(); | 1029 const GURL& url = contents->GetController().GetActiveEntry()->GetURL(); |
| 1030 std::string app_name = web_app::GenerateApplicationNameFromURL(url); | 1030 std::string app_name = web_app::GenerateApplicationNameFromURL(url); |
| 1031 | 1031 |
| 1032 int index = browser->tab_strip_model()->GetIndexOfWebContents(contents); | 1032 int index = browser->tab_strip_model()->GetIndexOfWebContents(contents); |
| 1033 if (index >= 0) | 1033 if (index >= 0) |
| 1034 browser->tab_strip_model()->DetachTabContentsAt(index); | 1034 browser->tab_strip_model()->DetachTabContentsAt(index); |
| 1035 | 1035 |
| 1036 Browser* app_browser = new Browser( | 1036 Browser* app_browser = new Browser( |
| 1037 Browser::CreateParams::CreateForApp( | 1037 Browser::CreateParams::CreateForApp( |
| 1038 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); | 1038 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); |
| 1039 TabContents* tab_contents = TabContents::FromWebContents(contents); | 1039 TabContents* tab_contents = TabContents::FromWebContents(contents); |
| 1040 if (!tab_contents) { | 1040 if (!tab_contents) { |
| 1041 tab_contents = | 1041 tab_contents = |
| 1042 BrowserCommandsTabContentsCreator::CreateTabContents(contents); | 1042 BrowserCommandsTabContentsCreator::CreateTabContents(contents); |
| 1043 } | 1043 } |
| 1044 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 1044 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 1045 | 1045 |
| 1046 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1046 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1047 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1047 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1048 app_browser->window()->Show(); | 1048 app_browser->window()->Show(); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 } // namespace chrome | 1051 } // namespace chrome |
| OLD | NEW |