| 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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: | 2068 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: |
| 2073 | 2069 |
| 2074 void Browser::ExecuteCommand(int id) { | 2070 void Browser::ExecuteCommand(int id) { |
| 2075 ExecuteCommandWithDisposition(id, CURRENT_TAB); | 2071 ExecuteCommandWithDisposition(id, CURRENT_TAB); |
| 2076 } | 2072 } |
| 2077 | 2073 |
| 2078 /////////////////////////////////////////////////////////////////////////////// | 2074 /////////////////////////////////////////////////////////////////////////////// |
| 2079 // Browser, TabStripModelDelegate implementation: | 2075 // Browser, TabStripModelDelegate implementation: |
| 2080 | 2076 |
| 2081 TabContents* Browser::AddBlankTab(bool foreground) { | 2077 TabContents* Browser::AddBlankTab(bool foreground) { |
| 2082 // To make a more "launchy" experience, try to reuse an existing NTP if there | |
| 2083 // is one. | |
| 2084 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableApps)) { | |
| 2085 for (int i = tabstrip_model_.count() - 1; i >= 0; --i) { | |
| 2086 TabContents* contents = tabstrip_model_.GetTabContentsAt(i); | |
| 2087 if (StartsWithASCII(contents->GetURL().spec(), | |
| 2088 chrome::kChromeUINewTabURL, true)) { | |
| 2089 if (foreground) | |
| 2090 SelectTabContentsAt(i, true); | |
| 2091 | |
| 2092 return contents; | |
| 2093 } | |
| 2094 } | |
| 2095 } | |
| 2096 | |
| 2097 return AddBlankTabAt(-1, foreground); | 2078 return AddBlankTabAt(-1, foreground); |
| 2098 } | 2079 } |
| 2099 | 2080 |
| 2100 TabContents* Browser::AddBlankTabAt(int index, bool foreground) { | 2081 TabContents* Browser::AddBlankTabAt(int index, bool foreground) { |
| 2101 // Time new tab page creation time. We keep track of the timing data in | 2082 // Time new tab page creation time. We keep track of the timing data in |
| 2102 // TabContents, but we want to include the time it takes to create the | 2083 // TabContents, but we want to include the time it takes to create the |
| 2103 // TabContents object too. | 2084 // TabContents object too. |
| 2104 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); | 2085 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); |
| 2105 TabContents* tab_contents = AddTabWithURL( | 2086 TabContents* tab_contents = AddTabWithURL( |
| 2106 GURL(chrome::kChromeUINewTabURL), GURL(), PageTransition::TYPED, index, | 2087 GURL(chrome::kChromeUINewTabURL), GURL(), PageTransition::TYPED, index, |
| (...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3858 if (TabHasUnloadListener(contents)) { | 3839 if (TabHasUnloadListener(contents)) { |
| 3859 // If the page has unload listeners, then we tell the renderer to fire | 3840 // If the page has unload listeners, then we tell the renderer to fire |
| 3860 // them. Once they have fired, we'll get a message back saying whether | 3841 // them. Once they have fired, we'll get a message back saying whether |
| 3861 // to proceed closing the page or not, which sends us back to this method | 3842 // to proceed closing the page or not, which sends us back to this method |
| 3862 // with the HasUnloadListener bit cleared. | 3843 // with the HasUnloadListener bit cleared. |
| 3863 contents->render_view_host()->FirePageBeforeUnload(false); | 3844 contents->render_view_host()->FirePageBeforeUnload(false); |
| 3864 return true; | 3845 return true; |
| 3865 } | 3846 } |
| 3866 return false; | 3847 return false; |
| 3867 } | 3848 } |
| OLD | NEW |