OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); | 1045 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); |
1046 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); | 1046 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); |
1047 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); | 1047 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); |
1048 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); | 1048 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); |
1049 command_updater_.UpdateCommandEnabled(IDC_SHOW_PAGE_MENU, show_main_ui); | 1049 command_updater_.UpdateCommandEnabled(IDC_SHOW_PAGE_MENU, show_main_ui); |
1050 } | 1050 } |
1051 | 1051 |
1052 bool Browser::OpenAppsPanelAsNewTab() { | 1052 bool Browser::OpenAppsPanelAsNewTab() { |
1053 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 1053 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
1054 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1054 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1055 if (command_line->HasSwitch(switches::kDisableAppsPanel) || | 1055 if (command_line->HasSwitch(switches::kAppsPanel)) { |
1056 (!browser_defaults::kShowAppsPanelForNewTab && | 1056 AppLauncher::ShowForNewTab(this, std::string()); |
1057 !command_line->HasSwitch(switches::kAppsPanel))) { | 1057 return true; |
1058 return false; | |
1059 } | 1058 } |
1060 AppLauncher::ShowForNewTab(this, std::string()); | 1059 #endif |
1061 return true; | |
1062 #endif // OS_CHROMEOS || OS_WIN | |
1063 | |
1064 return false; | 1060 return false; |
1065 } | 1061 } |
1066 | 1062 |
1067 /////////////////////////////////////////////////////////////////////////////// | 1063 /////////////////////////////////////////////////////////////////////////////// |
1068 // Browser, Assorted browser commands: | 1064 // Browser, Assorted browser commands: |
1069 | 1065 |
1070 bool Browser::ShouldOpenNewTabForWindowDisposition( | 1066 bool Browser::ShouldOpenNewTabForWindowDisposition( |
1071 WindowOpenDisposition disposition) { | 1067 WindowOpenDisposition disposition) { |
1072 return (disposition == NEW_FOREGROUND_TAB || | 1068 return (disposition == NEW_FOREGROUND_TAB || |
1073 disposition == NEW_BACKGROUND_TAB); | 1069 disposition == NEW_BACKGROUND_TAB); |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: | 2071 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: |
2076 | 2072 |
2077 void Browser::ExecuteCommand(int id) { | 2073 void Browser::ExecuteCommand(int id) { |
2078 ExecuteCommandWithDisposition(id, CURRENT_TAB); | 2074 ExecuteCommandWithDisposition(id, CURRENT_TAB); |
2079 } | 2075 } |
2080 | 2076 |
2081 /////////////////////////////////////////////////////////////////////////////// | 2077 /////////////////////////////////////////////////////////////////////////////// |
2082 // Browser, TabStripModelDelegate implementation: | 2078 // Browser, TabStripModelDelegate implementation: |
2083 | 2079 |
2084 TabContents* Browser::AddBlankTab(bool foreground) { | 2080 TabContents* Browser::AddBlankTab(bool foreground) { |
2085 // To make a more "launchy" experience, try to reuse an existing NTP if there | |
2086 // is one. | |
2087 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps)) { | |
2088 for (int i = tabstrip_model_.count() - 1; i >= 0; --i) { | |
2089 TabContents* contents = tabstrip_model_.GetTabContentsAt(i); | |
2090 if (StartsWithASCII(contents->GetURL().spec(), | |
2091 chrome::kChromeUINewTabURL, true)) { | |
2092 if (foreground) | |
2093 SelectTabContentsAt(i, true); | |
2094 | |
2095 return contents; | |
2096 } | |
2097 } | |
2098 } | |
2099 | |
2100 return AddBlankTabAt(-1, foreground); | 2081 return AddBlankTabAt(-1, foreground); |
2101 } | 2082 } |
2102 | 2083 |
2103 TabContents* Browser::AddBlankTabAt(int index, bool foreground) { | 2084 TabContents* Browser::AddBlankTabAt(int index, bool foreground) { |
2104 // Time new tab page creation time. We keep track of the timing data in | 2085 // Time new tab page creation time. We keep track of the timing data in |
2105 // TabContents, but we want to include the time it takes to create the | 2086 // TabContents, but we want to include the time it takes to create the |
2106 // TabContents object too. | 2087 // TabContents object too. |
2107 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); | 2088 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); |
2108 TabContents* tab_contents = AddTabWithURL( | 2089 TabContents* tab_contents = AddTabWithURL( |
2109 GURL(chrome::kChromeUINewTabURL), GURL(), PageTransition::TYPED, index, | 2090 GURL(chrome::kChromeUINewTabURL), GURL(), PageTransition::TYPED, index, |
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3868 if (TabHasUnloadListener(contents)) { | 3849 if (TabHasUnloadListener(contents)) { |
3869 // If the page has unload listeners, then we tell the renderer to fire | 3850 // If the page has unload listeners, then we tell the renderer to fire |
3870 // them. Once they have fired, we'll get a message back saying whether | 3851 // them. Once they have fired, we'll get a message back saying whether |
3871 // to proceed closing the page or not, which sends us back to this method | 3852 // to proceed closing the page or not, which sends us back to this method |
3872 // with the HasUnloadListener bit cleared. | 3853 // with the HasUnloadListener bit cleared. |
3873 contents->render_view_host()->FirePageBeforeUnload(false); | 3854 contents->render_view_host()->FirePageBeforeUnload(false); |
3874 return true; | 3855 return true; |
3875 } | 3856 } |
3876 return false; | 3857 return false; |
3877 } | 3858 } |
OLD | NEW |