| 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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 } | 916 } |
| 916 | 917 |
| 917 void ViewSelectedSource(Browser* browser) { | 918 void ViewSelectedSource(Browser* browser) { |
| 918 ViewSource(browser, chrome::GetActiveTabContents(browser)); | 919 ViewSource(browser, chrome::GetActiveTabContents(browser)); |
| 919 } | 920 } |
| 920 | 921 |
| 921 bool CanViewSource(const Browser* browser) { | 922 bool CanViewSource(const Browser* browser) { |
| 922 return chrome::GetActiveWebContents(browser)->GetController().CanViewSource(); | 923 return chrome::GetActiveWebContents(browser)->GetController().CanViewSource(); |
| 923 } | 924 } |
| 924 | 925 |
| 926 void CreateApplicationShortcuts(Browser* browser) { |
| 927 content::RecordAction(UserMetricsAction("CreateShortcut")); |
| 928 chrome::GetActiveTabContents(browser)->extension_tab_helper()-> |
| 929 CreateApplicationShortcuts(); |
| 930 } |
| 931 |
| 925 bool CanCreateApplicationShortcuts(const Browser* browser) { | 932 bool CanCreateApplicationShortcuts(const Browser* browser) { |
| 926 return web_app::IsValidUrl(chrome::GetActiveWebContents(browser)->GetURL()); | 933 return chrome::GetActiveTabContents(browser)->extension_tab_helper()-> |
| 934 CanCreateApplicationShortcuts(); |
| 927 } | 935 } |
| 928 | 936 |
| 929 void ConvertTabToAppWindow(Browser* browser, | 937 void ConvertTabToAppWindow(Browser* browser, |
| 930 content::WebContents* contents) { | 938 content::WebContents* contents) { |
| 931 const GURL& url = contents->GetController().GetActiveEntry()->GetURL(); | 939 const GURL& url = contents->GetController().GetActiveEntry()->GetURL(); |
| 932 std::string app_name = web_app::GenerateApplicationNameFromURL(url); | 940 std::string app_name = web_app::GenerateApplicationNameFromURL(url); |
| 933 | 941 |
| 934 int index = browser->tab_strip_model()->GetIndexOfWebContents(contents); | 942 int index = browser->tab_strip_model()->GetIndexOfWebContents(contents); |
| 935 if (index >= 0) | 943 if (index >= 0) |
| 936 browser->tab_strip_model()->DetachTabContentsAt(index); | 944 browser->tab_strip_model()->DetachTabContentsAt(index); |
| 937 | 945 |
| 938 Browser* app_browser = Browser::CreateWithParams( | 946 Browser* app_browser = Browser::CreateWithParams( |
| 939 Browser::CreateParams::CreateForApp( | 947 Browser::CreateParams::CreateForApp( |
| 940 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); | 948 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile())); |
| 941 TabContents* tab_contents = TabContents::FromWebContents(contents); | 949 TabContents* tab_contents = TabContents::FromWebContents(contents); |
| 942 if (!tab_contents) | 950 if (!tab_contents) |
| 943 tab_contents = new TabContents(contents); | 951 tab_contents = new TabContents(contents); |
| 944 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); | 952 app_browser->tab_strip_model()->AppendTabContents(tab_contents, true); |
| 945 | 953 |
| 946 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 954 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 947 contents->GetRenderViewHost()->SyncRendererPrefs(); | 955 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 948 app_browser->window()->Show(); | 956 app_browser->window()->Show(); |
| 949 } | 957 } |
| 950 | 958 |
| 951 } // namespace chrome | 959 } // namespace chrome |
| OLD | NEW |