| 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" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_page_zoom.h" | 14 #include "chrome/browser/chrome_page_zoom.h" |
| 15 #include "chrome/browser/debugger/devtools_window.h" | 15 #include "chrome/browser/debugger/devtools_window.h" |
| 16 #include "chrome/browser/download/download_util.h" | 16 #include "chrome/browser/download/download_util.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 18 #include "chrome/browser/favicon/favicon_tab_helper.h" | 19 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 19 #include "chrome/browser/lifetime/application_lifetime.h" | 20 #include "chrome/browser/lifetime/application_lifetime.h" |
| 20 #include "chrome/browser/platform_util.h" | 21 #include "chrome/browser/platform_util.h" |
| 21 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 22 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 22 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
| 23 #include "chrome/browser/printing/print_preview_tab_controller.h" | 24 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 24 #include "chrome/browser/printing/print_view_manager.h" | 25 #include "chrome/browser/printing/print_view_manager.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/sessions/session_service_factory.h" | 27 #include "chrome/browser/sessions/session_service_factory.h" |
| 27 #include "chrome/browser/sessions/tab_restore_service.h" | 28 #include "chrome/browser/sessions/tab_restore_service.h" |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 } | 910 } |
| 910 | 911 |
| 911 void ViewSelectedSource(Browser* browser) { | 912 void ViewSelectedSource(Browser* browser) { |
| 912 ViewSource(browser, chrome::GetActiveTabContents(browser)); | 913 ViewSource(browser, chrome::GetActiveTabContents(browser)); |
| 913 } | 914 } |
| 914 | 915 |
| 915 bool CanViewSource(const Browser* browser) { | 916 bool CanViewSource(const Browser* browser) { |
| 916 return chrome::GetActiveWebContents(browser)->GetController().CanViewSource(); | 917 return chrome::GetActiveWebContents(browser)->GetController().CanViewSource(); |
| 917 } | 918 } |
| 918 | 919 |
| 920 void CreateApplicationShortcuts(Browser* browser) { |
| 921 content::RecordAction(UserMetricsAction("CreateShortcut")); |
| 922 chrome::GetActiveTabContents(browser)->extension_tab_helper()-> |
| 923 CreateApplicationShortcuts(); |
| 924 } |
| 925 |
| 919 bool CanCreateApplicationShortcuts(const Browser* browser) { | 926 bool CanCreateApplicationShortcuts(const Browser* browser) { |
| 920 return web_app::IsValidUrl(chrome::GetActiveWebContents(browser)->GetURL()); | 927 return chrome::GetActiveTabContents(browser)->extension_tab_helper()-> |
| 928 CanCreateApplicationShortcuts(); |
| 921 } | 929 } |
| 922 | 930 |
| 923 void ConvertTabToAppWindow(Browser* browser, | 931 void ConvertTabToAppWindow(Browser* browser, |
| 924 content::WebContents* contents) { | 932 content::WebContents* contents) { |
| 925 const GURL& url = contents->GetController().GetActiveEntry()->GetURL(); | 933 const GURL& url = contents->GetController().GetActiveEntry()->GetURL(); |
| 926 std::string app_name = web_app::GenerateApplicationNameFromURL(url); | 934 std::string app_name = web_app::GenerateApplicationNameFromURL(url); |
| 927 | 935 |
| 928 int index = browser->tab_strip_model()->GetIndexOfWebContents(contents); | 936 int index = browser->tab_strip_model()->GetIndexOfWebContents(contents); |
| 929 if (index >= 0) | 937 if (index >= 0) |
| 930 browser->tab_strip_model()->DetachTabContentsAt(index); | 938 browser->tab_strip_model()->DetachTabContentsAt(index); |
| 931 | 939 |
| 932 Browser* app_browser = Browser::CreateWithParams( | 940 Browser* app_browser = Browser::CreateWithParams( |
| 933 Browser::CreateParams::CreateForApp( | 941 Browser::CreateParams::CreateForApp( |
| 934 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); | 942 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); |
| 935 TabContents* tab_contents = TabContents::FromWebContents(contents); | 943 TabContents* tab_contents = TabContents::FromWebContents(contents); |
| 936 if (!tab_contents) | 944 if (!tab_contents) |
| 937 tab_contents = new TabContents(contents); | 945 tab_contents = new TabContents(contents); |
| 938 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 946 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 939 | 947 |
| 940 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 948 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 941 contents->GetRenderViewHost()->SyncRendererPrefs(); | 949 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 942 app_browser->window()->Show(); | 950 app_browser->window()->Show(); |
| 943 } | 951 } |
| 944 | 952 |
| 945 } // namespace chrome | 953 } // namespace chrome |
| OLD | NEW |