| 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 &replacement->controller()); | 975 &replacement->controller()); |
| 976 } | 976 } |
| 977 | 977 |
| 978 bool Browser::CanRestoreTab() { | 978 bool Browser::CanRestoreTab() { |
| 979 return command_updater_.IsCommandEnabled(IDC_RESTORE_TAB); | 979 return command_updater_.IsCommandEnabled(IDC_RESTORE_TAB); |
| 980 } | 980 } |
| 981 | 981 |
| 982 bool Browser::NavigateToIndexWithDisposition(int index, | 982 bool Browser::NavigateToIndexWithDisposition(int index, |
| 983 WindowOpenDisposition disp) { | 983 WindowOpenDisposition disp) { |
| 984 NavigationController& controller = | 984 NavigationController& controller = |
| 985 GetOrCloneNavigationControllerForDisposition(disp); | 985 GetOrCloneTabForDisposition(disp)->controller(); |
| 986 | 986 if (index < 0 || index >= controller.entry_count()) |
| 987 if (index >= 0 && index < controller.entry_count()) { | |
| 988 controller.GoToIndex(index); | |
| 989 return true; | |
| 990 } else { | |
| 991 return false; | 987 return false; |
| 992 } | 988 controller.GoToIndex(index); |
| 989 return true; |
| 993 } | 990 } |
| 994 | 991 |
| 995 void Browser::ShowSingletonTab(const GURL& url) { | 992 void Browser::ShowSingletonTab(const GURL& url) { |
| 996 // In case the URL was rewritten by the BrowserURLHandler we need to ensure | 993 // In case the URL was rewritten by the BrowserURLHandler we need to ensure |
| 997 // that we do not open another URL that will get redirected to the rewritten | 994 // that we do not open another URL that will get redirected to the rewritten |
| 998 // URL. | 995 // URL. |
| 999 GURL rewritten_url(url); | 996 GURL rewritten_url(url); |
| 1000 bool reverse_on_redirect = false; | 997 bool reverse_on_redirect = false; |
| 1001 BrowserURLHandler::RewriteURLIfNecessary(&rewritten_url, profile_, | 998 BrowserURLHandler::RewriteURLIfNecessary(&rewritten_url, profile_, |
| 1002 &reverse_on_redirect); | 999 &reverse_on_redirect); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 | 1066 |
| 1070 /////////////////////////////////////////////////////////////////////////////// | 1067 /////////////////////////////////////////////////////////////////////////////// |
| 1071 // Browser, Assorted browser commands: | 1068 // Browser, Assorted browser commands: |
| 1072 | 1069 |
| 1073 bool Browser::ShouldOpenNewTabForWindowDisposition( | 1070 bool Browser::ShouldOpenNewTabForWindowDisposition( |
| 1074 WindowOpenDisposition disposition) { | 1071 WindowOpenDisposition disposition) { |
| 1075 return (disposition == NEW_FOREGROUND_TAB || | 1072 return (disposition == NEW_FOREGROUND_TAB || |
| 1076 disposition == NEW_BACKGROUND_TAB); | 1073 disposition == NEW_BACKGROUND_TAB); |
| 1077 } | 1074 } |
| 1078 | 1075 |
| 1079 NavigationController& Browser::GetOrCloneNavigationControllerForDisposition( | 1076 TabContents* Browser::GetOrCloneTabForDisposition( |
| 1080 WindowOpenDisposition disposition) { | 1077 WindowOpenDisposition disposition) { |
| 1081 TabContents* current_tab = GetSelectedTabContents(); | 1078 TabContents* current_tab = GetSelectedTabContents(); |
| 1082 if (ShouldOpenNewTabForWindowDisposition(disposition)) { | 1079 if (ShouldOpenNewTabForWindowDisposition(disposition)) { |
| 1083 TabContents* cloned = current_tab->Clone(); | 1080 current_tab = current_tab->Clone(); |
| 1084 tabstrip_model_.AddTabContents(cloned, -1, false, | 1081 tabstrip_model_.AddTabContents(current_tab, -1, false, PageTransition::LINK, |
| 1085 PageTransition::LINK, | |
| 1086 disposition == NEW_FOREGROUND_TAB); | 1082 disposition == NEW_FOREGROUND_TAB); |
| 1087 return cloned->controller(); | |
| 1088 } else { | |
| 1089 // Default disposition is CURRENT_TAB. | |
| 1090 return current_tab->controller(); | |
| 1091 } | 1083 } |
| 1084 return current_tab; |
| 1092 } | 1085 } |
| 1093 | 1086 |
| 1094 void Browser::UpdateTabStripModelInsertionPolicy() { | 1087 void Browser::UpdateTabStripModelInsertionPolicy() { |
| 1095 tabstrip_model_.SetInsertionPolicy(UseVerticalTabs() ? | 1088 tabstrip_model_.SetInsertionPolicy(UseVerticalTabs() ? |
| 1096 TabStripModel::INSERT_BEFORE : TabStripModel::INSERT_AFTER); | 1089 TabStripModel::INSERT_BEFORE : TabStripModel::INSERT_AFTER); |
| 1097 } | 1090 } |
| 1098 | 1091 |
| 1099 void Browser::UseVerticalTabsChanged() { | 1092 void Browser::UseVerticalTabsChanged() { |
| 1100 UpdateTabStripModelInsertionPolicy(); | 1093 UpdateTabStripModelInsertionPolicy(); |
| 1101 window()->ToggleTabStripMode(); | 1094 window()->ToggleTabStripMode(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 features |= FEATURE_LOCATIONBAR; | 1134 features |= FEATURE_LOCATIONBAR; |
| 1142 } | 1135 } |
| 1143 return !!(features & feature); | 1136 return !!(features & feature); |
| 1144 } | 1137 } |
| 1145 | 1138 |
| 1146 void Browser::GoBack(WindowOpenDisposition disposition) { | 1139 void Browser::GoBack(WindowOpenDisposition disposition) { |
| 1147 UserMetrics::RecordAction(UserMetricsAction("Back"), profile_); | 1140 UserMetrics::RecordAction(UserMetricsAction("Back"), profile_); |
| 1148 | 1141 |
| 1149 TabContents* current_tab = GetSelectedTabContents(); | 1142 TabContents* current_tab = GetSelectedTabContents(); |
| 1150 if (current_tab->controller().CanGoBack()) { | 1143 if (current_tab->controller().CanGoBack()) { |
| 1151 NavigationController& controller = | 1144 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); |
| 1152 GetOrCloneNavigationControllerForDisposition(disposition); | |
| 1153 // If we are on an interstitial page and clone the tab, it won't be copied | 1145 // If we are on an interstitial page and clone the tab, it won't be copied |
| 1154 // to the new tab, so we don't need to go back. | 1146 // to the new tab, so we don't need to go back. |
| 1155 if (current_tab->interstitial_page() && | 1147 if (current_tab->showing_interstitial_page() && (new_tab != current_tab)) |
| 1156 ShouldOpenNewTabForWindowDisposition(disposition)) { | |
| 1157 return; | 1148 return; |
| 1158 } | 1149 new_tab->controller().GoBack(); |
| 1159 controller.GoBack(); | |
| 1160 } | 1150 } |
| 1161 } | 1151 } |
| 1162 | 1152 |
| 1163 void Browser::GoForward(WindowOpenDisposition disposition) { | 1153 void Browser::GoForward(WindowOpenDisposition disposition) { |
| 1164 UserMetrics::RecordAction(UserMetricsAction("Forward"), profile_); | 1154 UserMetrics::RecordAction(UserMetricsAction("Forward"), profile_); |
| 1165 if (GetSelectedTabContents()->controller().CanGoForward()) { | 1155 if (GetSelectedTabContents()->controller().CanGoForward()) |
| 1166 NavigationController& controller = | 1156 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); |
| 1167 GetOrCloneNavigationControllerForDisposition(disposition); | |
| 1168 controller.GoForward(); | |
| 1169 } | |
| 1170 } | 1157 } |
| 1171 | 1158 |
| 1172 void Browser::Reload() { | 1159 void Browser::Reload(WindowOpenDisposition disposition) { |
| 1173 UserMetrics::RecordAction(UserMetricsAction("Reload"), profile_); | 1160 UserMetrics::RecordAction(UserMetricsAction("Reload"), profile_); |
| 1174 ReloadInternal(false); | 1161 ReloadInternal(disposition, false); |
| 1175 } | 1162 } |
| 1176 | 1163 |
| 1177 void Browser::ReloadIgnoringCache() { | 1164 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { |
| 1178 UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache"), profile_); | 1165 UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache"), profile_); |
| 1179 ReloadInternal(true); | 1166 ReloadInternal(disposition, true); |
| 1180 } | 1167 } |
| 1181 | 1168 |
| 1182 void Browser::ReloadInternal(bool ignore_cache) { | 1169 void Browser::ReloadInternal(WindowOpenDisposition disposition, |
| 1170 bool ignore_cache) { |
| 1183 // If we are showing an interstitial, treat this as an OpenURL. | 1171 // If we are showing an interstitial, treat this as an OpenURL. |
| 1184 TabContents* current_tab = GetSelectedTabContents(); | 1172 TabContents* current_tab = GetSelectedTabContents(); |
| 1185 if (current_tab) { | 1173 if (current_tab && current_tab->showing_interstitial_page()) { |
| 1186 if (current_tab->showing_interstitial_page()) { | 1174 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); |
| 1187 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); | 1175 DCHECK(entry); // Should exist if interstitial is showing. |
| 1188 DCHECK(entry); // Should exist if interstitial is showing. | 1176 OpenURL(entry->url(), GURL(), disposition, PageTransition::RELOAD); |
| 1189 OpenURL(entry->url(), GURL(), CURRENT_TAB, PageTransition::RELOAD); | 1177 return; |
| 1190 return; | 1178 } |
| 1191 } | |
| 1192 | 1179 |
| 1193 // As this is caused by a user action, give the focus to the page. | 1180 // As this is caused by a user action, give the focus to the page. |
| 1194 if (!current_tab->FocusLocationBarByDefault()) | 1181 current_tab = GetOrCloneTabForDisposition(disposition); |
| 1195 current_tab->Focus(); | 1182 if (!current_tab->FocusLocationBarByDefault()) |
| 1196 if (ignore_cache) | 1183 current_tab->Focus(); |
| 1197 current_tab->controller().ReloadIgnoringCache(true); | 1184 if (ignore_cache) |
| 1198 else | 1185 current_tab->controller().ReloadIgnoringCache(true); |
| 1199 current_tab->controller().Reload(true); | 1186 else |
| 1200 } | 1187 current_tab->controller().Reload(true); |
| 1201 } | 1188 } |
| 1202 | 1189 |
| 1203 void Browser::Home(WindowOpenDisposition disposition) { | 1190 void Browser::Home(WindowOpenDisposition disposition) { |
| 1204 UserMetrics::RecordAction(UserMetricsAction("Home"), profile_); | 1191 UserMetrics::RecordAction(UserMetricsAction("Home"), profile_); |
| 1205 OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); | 1192 OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); |
| 1206 } | 1193 } |
| 1207 | 1194 |
| 1208 void Browser::OpenCurrentURL() { | 1195 void Browser::OpenCurrentURL() { |
| 1209 UserMetrics::RecordAction(UserMetricsAction("LoadURL"), profile_); | 1196 UserMetrics::RecordAction(UserMetricsAction("LoadURL"), profile_); |
| 1210 LocationBar* location_bar = window_->GetLocationBar(); | 1197 LocationBar* location_bar = window_->GetLocationBar(); |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 DCHECK_EQ(last_blocked_command_id_, -1); | 1900 DCHECK_EQ(last_blocked_command_id_, -1); |
| 1914 last_blocked_command_id_ = id; | 1901 last_blocked_command_id_ = id; |
| 1915 last_blocked_command_disposition_ = disposition; | 1902 last_blocked_command_disposition_ = disposition; |
| 1916 return; | 1903 return; |
| 1917 } | 1904 } |
| 1918 | 1905 |
| 1919 // The order of commands in this switch statement must match the function | 1906 // The order of commands in this switch statement must match the function |
| 1920 // declaration order in browser.h! | 1907 // declaration order in browser.h! |
| 1921 switch (id) { | 1908 switch (id) { |
| 1922 // Navigation commands | 1909 // Navigation commands |
| 1923 case IDC_BACK: GoBack(disposition); break; | 1910 case IDC_BACK: GoBack(disposition); break; |
| 1924 case IDC_FORWARD: GoForward(disposition); break; | 1911 case IDC_FORWARD: GoForward(disposition); break; |
| 1925 case IDC_RELOAD: Reload(); break; | 1912 case IDC_RELOAD: Reload(disposition); break; |
| 1926 case IDC_RELOAD_IGNORING_CACHE: ReloadIgnoringCache(); break; | 1913 case IDC_RELOAD_IGNORING_CACHE: ReloadIgnoringCache(disposition); break; |
| 1927 case IDC_HOME: Home(disposition); break; | 1914 case IDC_HOME: Home(disposition); break; |
| 1928 case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break; | 1915 case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break; |
| 1929 case IDC_GO: Go(disposition); break; | 1916 case IDC_GO: Go(disposition); break; |
| 1930 case IDC_STOP: Stop(); break; | 1917 case IDC_STOP: Stop(); break; |
| 1931 | 1918 |
| 1932 // Window management commands | 1919 // Window management commands |
| 1933 case IDC_NEW_WINDOW: NewWindow(); break; | 1920 case IDC_NEW_WINDOW: NewWindow(); break; |
| 1934 case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; | 1921 case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; |
| 1935 case IDC_NEW_WINDOW_PROFILE_0: | 1922 case IDC_NEW_WINDOW_PROFILE_0: |
| 1936 case IDC_NEW_WINDOW_PROFILE_1: | 1923 case IDC_NEW_WINDOW_PROFILE_1: |
| 1937 case IDC_NEW_WINDOW_PROFILE_2: | 1924 case IDC_NEW_WINDOW_PROFILE_2: |
| 1938 case IDC_NEW_WINDOW_PROFILE_3: | 1925 case IDC_NEW_WINDOW_PROFILE_3: |
| 1939 case IDC_NEW_WINDOW_PROFILE_4: | 1926 case IDC_NEW_WINDOW_PROFILE_4: |
| 1940 case IDC_NEW_WINDOW_PROFILE_5: | 1927 case IDC_NEW_WINDOW_PROFILE_5: |
| 1941 case IDC_NEW_WINDOW_PROFILE_6: | 1928 case IDC_NEW_WINDOW_PROFILE_6: |
| 1942 case IDC_NEW_WINDOW_PROFILE_7: | 1929 case IDC_NEW_WINDOW_PROFILE_7: |
| 1943 case IDC_NEW_WINDOW_PROFILE_8: | 1930 case IDC_NEW_WINDOW_PROFILE_8: |
| 1944 NewProfileWindowByIndex(id - IDC_NEW_WINDOW_PROFILE_0); | 1931 NewProfileWindowByIndex(id - IDC_NEW_WINDOW_PROFILE_0); |
| 1945 break; | 1932 break; |
| 1946 case IDC_CLOSE_WINDOW: CloseWindow(); break; | 1933 case IDC_CLOSE_WINDOW: CloseWindow(); break; |
| 1947 case IDC_NEW_TAB: NewTab(); break; | 1934 case IDC_NEW_TAB: NewTab(); break; |
| 1948 case IDC_CLOSE_TAB: CloseTab(); break; | 1935 case IDC_CLOSE_TAB: CloseTab(); break; |
| 1949 case IDC_SELECT_NEXT_TAB: SelectNextTab(); break; | 1936 case IDC_SELECT_NEXT_TAB: SelectNextTab(); break; |
| 1950 case IDC_SELECT_PREVIOUS_TAB: SelectPreviousTab(); break; | 1937 case IDC_SELECT_PREVIOUS_TAB: SelectPreviousTab(); break; |
| 1951 case IDC_MOVE_TAB_NEXT: MoveTabNext(); break; | 1938 case IDC_MOVE_TAB_NEXT: MoveTabNext(); break; |
| 1952 case IDC_MOVE_TAB_PREVIOUS: MoveTabPrevious(); break; | 1939 case IDC_MOVE_TAB_PREVIOUS: MoveTabPrevious(); break; |
| 1953 case IDC_SELECT_TAB_0: | 1940 case IDC_SELECT_TAB_0: |
| 1954 case IDC_SELECT_TAB_1: | 1941 case IDC_SELECT_TAB_1: |
| 1955 case IDC_SELECT_TAB_2: | 1942 case IDC_SELECT_TAB_2: |
| 1956 case IDC_SELECT_TAB_3: | 1943 case IDC_SELECT_TAB_3: |
| 1957 case IDC_SELECT_TAB_4: | 1944 case IDC_SELECT_TAB_4: |
| 1958 case IDC_SELECT_TAB_5: | 1945 case IDC_SELECT_TAB_5: |
| 1959 case IDC_SELECT_TAB_6: | 1946 case IDC_SELECT_TAB_6: |
| 1960 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); | 1947 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); |
| 1961 break; | 1948 break; |
| 1962 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; | 1949 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; |
| 1963 case IDC_DUPLICATE_TAB: DuplicateTab(); break; | 1950 case IDC_DUPLICATE_TAB: DuplicateTab(); break; |
| 1964 case IDC_RESTORE_TAB: RestoreTab(); break; | 1951 case IDC_RESTORE_TAB: RestoreTab(); break; |
| 1965 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; | 1952 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; |
| 1966 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; | 1953 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; |
| 1967 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; | 1954 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; |
| 1968 case IDC_EXIT: Exit(); break; | 1955 case IDC_EXIT: Exit(); break; |
| 1969 case IDC_TOGGLE_VERTICAL_TABS: ToggleUseVerticalTabs(); break; | 1956 case IDC_TOGGLE_VERTICAL_TABS: ToggleUseVerticalTabs(); break; |
| 1970 #if defined(OS_CHROMEOS) | 1957 #if defined(OS_CHROMEOS) |
| 1971 case IDC_COMPACT_NAVBAR: ToggleCompactNavigationBar(); break; | 1958 case IDC_COMPACT_NAVBAR: ToggleCompactNavigationBar(); break; |
| 1972 case IDC_SEARCH: Search(); break; | 1959 case IDC_SEARCH: Search(); break; |
| 1973 #endif | 1960 #endif |
| 1974 | 1961 |
| 1975 // Page-related commands | 1962 // Page-related commands |
| 1976 case IDC_SAVE_PAGE: SavePage(); break; | 1963 case IDC_SAVE_PAGE: SavePage(); break; |
| 1977 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; | 1964 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; |
| 1978 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; | 1965 case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; |
| 1979 case IDC_VIEW_SOURCE: ViewSource(); break; | 1966 case IDC_VIEW_SOURCE: ViewSource(); break; |
| 1980 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; | 1967 case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; |
| 1981 case IDC_PRINT: Print(); break; | 1968 case IDC_PRINT: Print(); break; |
| 1982 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; | 1969 case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; |
| 1983 case IDC_ENCODING_UTF8: | 1970 case IDC_ENCODING_UTF8: |
| 1984 case IDC_ENCODING_UTF16LE: | 1971 case IDC_ENCODING_UTF16LE: |
| 1985 case IDC_ENCODING_ISO88591: | 1972 case IDC_ENCODING_ISO88591: |
| 1986 case IDC_ENCODING_WINDOWS1252: | 1973 case IDC_ENCODING_WINDOWS1252: |
| 1987 case IDC_ENCODING_GBK: | 1974 case IDC_ENCODING_GBK: |
| 1988 case IDC_ENCODING_GB18030: | 1975 case IDC_ENCODING_GB18030: |
| 1989 case IDC_ENCODING_BIG5HKSCS: | 1976 case IDC_ENCODING_BIG5HKSCS: |
| 1990 case IDC_ENCODING_BIG5: | 1977 case IDC_ENCODING_BIG5: |
| 1991 case IDC_ENCODING_KOREAN: | 1978 case IDC_ENCODING_KOREAN: |
| 1992 case IDC_ENCODING_SHIFTJIS: | 1979 case IDC_ENCODING_SHIFTJIS: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2009 case IDC_ENCODING_ISO88593: | 1996 case IDC_ENCODING_ISO88593: |
| 2010 case IDC_ENCODING_ISO885910: | 1997 case IDC_ENCODING_ISO885910: |
| 2011 case IDC_ENCODING_ISO885914: | 1998 case IDC_ENCODING_ISO885914: |
| 2012 case IDC_ENCODING_ISO885916: | 1999 case IDC_ENCODING_ISO885916: |
| 2013 case IDC_ENCODING_WINDOWS1254: | 2000 case IDC_ENCODING_WINDOWS1254: |
| 2014 case IDC_ENCODING_ISO88596: | 2001 case IDC_ENCODING_ISO88596: |
| 2015 case IDC_ENCODING_WINDOWS1256: | 2002 case IDC_ENCODING_WINDOWS1256: |
| 2016 case IDC_ENCODING_ISO88598: | 2003 case IDC_ENCODING_ISO88598: |
| 2017 case IDC_ENCODING_ISO88598I: | 2004 case IDC_ENCODING_ISO88598I: |
| 2018 case IDC_ENCODING_WINDOWS1255: | 2005 case IDC_ENCODING_WINDOWS1255: |
| 2019 case IDC_ENCODING_WINDOWS1258: OverrideEncoding(id); break; | 2006 case IDC_ENCODING_WINDOWS1258: OverrideEncoding(id); break; |
| 2020 | 2007 |
| 2021 // Clipboard commands | 2008 // Clipboard commands |
| 2022 case IDC_CUT: Cut(); break; | 2009 case IDC_CUT: Cut(); break; |
| 2023 case IDC_COPY: Copy(); break; | 2010 case IDC_COPY: Copy(); break; |
| 2024 case IDC_PASTE: Paste(); break; | 2011 case IDC_PASTE: Paste(); break; |
| 2025 | 2012 |
| 2026 // Find-in-page | 2013 // Find-in-page |
| 2027 case IDC_FIND: Find(); break; | 2014 case IDC_FIND: Find(); break; |
| 2028 case IDC_FIND_NEXT: FindNext(); break; | 2015 case IDC_FIND_NEXT: FindNext(); break; |
| 2029 case IDC_FIND_PREVIOUS: FindPrevious(); break; | 2016 case IDC_FIND_PREVIOUS: FindPrevious(); break; |
| 2030 | 2017 |
| 2031 // Zoom | 2018 // Zoom |
| 2032 case IDC_ZOOM_PLUS: Zoom(PageZoom::ZOOM_IN); break; | 2019 case IDC_ZOOM_PLUS: Zoom(PageZoom::ZOOM_IN); break; |
| 2033 case IDC_ZOOM_NORMAL: Zoom(PageZoom::RESET); break; | 2020 case IDC_ZOOM_NORMAL: Zoom(PageZoom::RESET); break; |
| 2034 case IDC_ZOOM_MINUS: Zoom(PageZoom::ZOOM_OUT); break; | 2021 case IDC_ZOOM_MINUS: Zoom(PageZoom::ZOOM_OUT); break; |
| 2035 | 2022 |
| 2036 // Focus various bits of UI | 2023 // Focus various bits of UI |
| 2037 case IDC_FOCUS_TOOLBAR: FocusToolbar(); break; | 2024 case IDC_FOCUS_TOOLBAR: FocusToolbar(); break; |
| 2038 case IDC_FOCUS_LOCATION: FocusLocationBar(); break; | 2025 case IDC_FOCUS_LOCATION: FocusLocationBar(); break; |
| 2039 case IDC_FOCUS_SEARCH: FocusSearch(); break; | 2026 case IDC_FOCUS_SEARCH: FocusSearch(); break; |
| 2040 case IDC_FOCUS_MENU_BAR: FocusPageAndAppMenus(); break; | 2027 case IDC_FOCUS_MENU_BAR: FocusPageAndAppMenus(); break; |
| 2041 | 2028 |
| 2042 // Show various bits of UI | 2029 // Show various bits of UI |
| 2043 case IDC_OPEN_FILE: OpenFile(); break; | 2030 case IDC_OPEN_FILE: OpenFile(); break; |
| 2044 case IDC_CREATE_SHORTCUTS: OpenCreateShortcutsDialog(); break; | 2031 case IDC_CREATE_SHORTCUTS: OpenCreateShortcutsDialog(); break; |
| 2045 case IDC_DEV_TOOLS: ToggleDevToolsWindow(false); break; | 2032 case IDC_DEV_TOOLS: ToggleDevToolsWindow(false); break; |
| 2046 case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow(true); break; | 2033 case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow(true); break; |
| 2047 case IDC_TASK_MANAGER: OpenTaskManager(); break; | 2034 case IDC_TASK_MANAGER: OpenTaskManager(); break; |
| 2048 case IDC_SELECT_PROFILE: OpenSelectProfileDialog(); break; | 2035 case IDC_SELECT_PROFILE: OpenSelectProfileDialog(); break; |
| 2049 case IDC_NEW_PROFILE: OpenNewProfileDialog(); break; | 2036 case IDC_NEW_PROFILE: OpenNewProfileDialog(); break; |
| 2050 case IDC_REPORT_BUG: OpenBugReportDialog(); break; | 2037 case IDC_REPORT_BUG: OpenBugReportDialog(); break; |
| 2051 | 2038 |
| 2052 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; | 2039 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; |
| 2053 case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break; | 2040 case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break; |
| 2054 | 2041 |
| 2055 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; | 2042 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; |
| 2056 case IDC_SHOW_APP_MENU: ShowAppMenu(); break; | 2043 case IDC_SHOW_APP_MENU: ShowAppMenu(); break; |
| 2057 case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; | 2044 case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; |
| 2058 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; | 2045 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; |
| 2059 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; | 2046 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; |
| 2060 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; | 2047 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; |
| 2061 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; | 2048 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; |
| 2062 case IDC_OPTIONS: OpenOptionsDialog(); break; | 2049 case IDC_OPTIONS: OpenOptionsDialog(); break; |
| 2063 case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; | 2050 case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; |
| 2064 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; | 2051 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; |
| 2065 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; | 2052 case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; |
| 2066 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; | 2053 case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; |
| 2067 case IDC_ABOUT: | 2054 case IDC_ABOUT: |
| 2068 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) | 2055 if (Singleton<UpgradeDetector>::get()->notify_upgrade()) |
| 2069 OpenUpdateChromeDialog(); | 2056 OpenUpdateChromeDialog(); |
| 2070 else | 2057 else |
| 2071 OpenAboutChromeDialog(); | 2058 OpenAboutChromeDialog(); |
| 2072 break; | 2059 break; |
| 2073 case IDC_HELP_PAGE: OpenHelpTab(); break; | 2060 case IDC_HELP_PAGE: OpenHelpTab(); break; |
| 2074 #if defined(OS_CHROMEOS) | 2061 #if defined(OS_CHROMEOS) |
| 2075 case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; | 2062 case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; |
| 2076 case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; | 2063 case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; |
| 2077 #endif | 2064 #endif |
| 2078 | 2065 |
| 2079 // AutoFill | 2066 // AutoFill |
| 2080 case IDC_AUTOFILL_DEFAULT: AutoFillDefaultProfile(); break; | 2067 case IDC_AUTOFILL_DEFAULT: AutoFillDefaultProfile(); break; |
| 2081 | 2068 |
| 2082 default: | 2069 default: |
| 2083 LOG(WARNING) << "Received Unimplemented Command: " << id; | 2070 LOG(WARNING) << "Received Unimplemented Command: " << id; |
| 2084 break; | 2071 break; |
| 2085 } | 2072 } |
| 2086 } | 2073 } |
| 2087 | 2074 |
| 2088 bool Browser::IsReservedCommand(int command_id) { | 2075 bool Browser::IsReservedCommand(int command_id) { |
| 2089 return command_id == IDC_CLOSE_TAB || | 2076 return command_id == IDC_CLOSE_TAB || |
| 2090 command_id == IDC_CLOSE_WINDOW || | 2077 command_id == IDC_CLOSE_WINDOW || |
| (...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3928 } | 3915 } |
| 3929 | 3916 |
| 3930 bool Browser::IsPinned(TabContents* source) { | 3917 bool Browser::IsPinned(TabContents* source) { |
| 3931 int index = tabstrip_model_.GetIndexOfTabContents(source); | 3918 int index = tabstrip_model_.GetIndexOfTabContents(source); |
| 3932 if (index == TabStripModel::kNoTab) { | 3919 if (index == TabStripModel::kNoTab) { |
| 3933 NOTREACHED() << "IsPinned called for tab not in our strip"; | 3920 NOTREACHED() << "IsPinned called for tab not in our strip"; |
| 3934 return false; | 3921 return false; |
| 3935 } | 3922 } |
| 3936 return tabstrip_model_.IsTabPinned(index); | 3923 return tabstrip_model_.IsTabPinned(index); |
| 3937 } | 3924 } |
| OLD | NEW |