| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/idle_timer.h" | 8 #include "base/idle_timer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 case IDC_NEW_WINDOW: NewWindow(); break; | 1082 case IDC_NEW_WINDOW: NewWindow(); break; |
| 1083 case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; | 1083 case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; |
| 1084 case IDC_NEW_WINDOW_PROFILE_0: | 1084 case IDC_NEW_WINDOW_PROFILE_0: |
| 1085 case IDC_NEW_WINDOW_PROFILE_1: | 1085 case IDC_NEW_WINDOW_PROFILE_1: |
| 1086 case IDC_NEW_WINDOW_PROFILE_2: | 1086 case IDC_NEW_WINDOW_PROFILE_2: |
| 1087 case IDC_NEW_WINDOW_PROFILE_3: | 1087 case IDC_NEW_WINDOW_PROFILE_3: |
| 1088 case IDC_NEW_WINDOW_PROFILE_4: | 1088 case IDC_NEW_WINDOW_PROFILE_4: |
| 1089 case IDC_NEW_WINDOW_PROFILE_5: | 1089 case IDC_NEW_WINDOW_PROFILE_5: |
| 1090 case IDC_NEW_WINDOW_PROFILE_6: | 1090 case IDC_NEW_WINDOW_PROFILE_6: |
| 1091 case IDC_NEW_WINDOW_PROFILE_7: | 1091 case IDC_NEW_WINDOW_PROFILE_7: |
| 1092 case IDC_NEW_WINDOW_PROFILE_8: | 1092 case IDC_NEW_WINDOW_PROFILE_8: |
| 1093 NewProfileWindowByIndex(id - IDC_NEW_WINDOW_PROFILE_0); break; | 1093 NewProfileWindowByIndex(id - IDC_NEW_WINDOW_PROFILE_0); break; |
| 1094 #if defined(OS_WIN) | 1094 #if defined(OS_WIN) |
| 1095 case IDC_CLOSE_WINDOW: CloseWindow(); break; | 1095 case IDC_CLOSE_WINDOW: CloseWindow(); break; |
| 1096 #endif | 1096 #endif |
| 1097 case IDC_NEW_TAB: NewTab(); break; | 1097 case IDC_NEW_TAB: NewTab(); break; |
| 1098 case IDC_CLOSE_TAB: CloseTab(); break; | 1098 case IDC_CLOSE_TAB: CloseTab(); break; |
| 1099 case IDC_SELECT_NEXT_TAB: SelectNextTab(); break; | 1099 case IDC_SELECT_NEXT_TAB: SelectNextTab(); break; |
| 1100 case IDC_SELECT_PREVIOUS_TAB: SelectPreviousTab(); break; | 1100 case IDC_SELECT_PREVIOUS_TAB: SelectPreviousTab(); break; |
| 1101 case IDC_SELECT_TAB_0: | 1101 case IDC_SELECT_TAB_0: |
| 1102 case IDC_SELECT_TAB_1: | 1102 case IDC_SELECT_TAB_1: |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 profile()->GetTabRestoreService()->CreateHistoricalTab( | 1365 profile()->GetTabRestoreService()->CreateHistoricalTab( |
| 1366 contents->controller()); | 1366 contents->controller()); |
| 1367 } | 1367 } |
| 1368 } | 1368 } |
| 1369 | 1369 |
| 1370 bool Browser::RunUnloadListenerBeforeClosing(TabContents* contents) { | 1370 bool Browser::RunUnloadListenerBeforeClosing(TabContents* contents) { |
| 1371 WebContents* web_contents = contents->AsWebContents(); | 1371 WebContents* web_contents = contents->AsWebContents(); |
| 1372 if (web_contents) { | 1372 if (web_contents) { |
| 1373 // If the WebContents is not connected yet, then there's no unload | 1373 // If the WebContents is not connected yet, then there's no unload |
| 1374 // handler we can fire even if the WebContents has an unload listener. | 1374 // handler we can fire even if the WebContents has an unload listener. |
| 1375 // One case where we hit this is in a tab that has an infinite loop | 1375 // One case where we hit this is in a tab that has an infinite loop |
| 1376 // before load. | 1376 // before load. |
| 1377 if (TabHasUnloadListener(contents)) { | 1377 if (TabHasUnloadListener(contents)) { |
| 1378 // If the page has unload listeners, then we tell the renderer to fire | 1378 // If the page has unload listeners, then we tell the renderer to fire |
| 1379 // them. Once they have fired, we'll get a message back saying whether | 1379 // them. Once they have fired, we'll get a message back saying whether |
| 1380 // to proceed closing the page or not, which sends us back to this method | 1380 // to proceed closing the page or not, which sends us back to this method |
| 1381 // with the HasUnloadListener bit cleared. | 1381 // with the HasUnloadListener bit cleared. |
| 1382 web_contents->render_view_host()->FirePageBeforeUnload(); | 1382 web_contents->render_view_host()->FirePageBeforeUnload(); |
| 1383 return true; | 1383 return true; |
| 1384 } | 1384 } |
| 1385 } | 1385 } |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 // We want to handle firing the unload event ourselves since we want to | 1867 // We want to handle firing the unload event ourselves since we want to |
| 1868 // fire all the beforeunload events before attempting to fire the unload | 1868 // fire all the beforeunload events before attempting to fire the unload |
| 1869 // events should the user cancel closing the browser. | 1869 // events should the user cancel closing the browser. |
| 1870 *proceed_to_fire_unload = false; | 1870 *proceed_to_fire_unload = false; |
| 1871 return; | 1871 return; |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 *proceed_to_fire_unload = true; | 1874 *proceed_to_fire_unload = true; |
| 1875 } | 1875 } |
| 1876 | 1876 |
| 1877 gfx::Rect Browser::GetRootWindowResizerRect() const { |
| 1878 return window_->GetRootWindowResizerRect(); |
| 1879 } |
| 1880 |
| 1877 void Browser::ShowHtmlDialog(HtmlDialogContentsDelegate* delegate, | 1881 void Browser::ShowHtmlDialog(HtmlDialogContentsDelegate* delegate, |
| 1878 void* parent_window) { | 1882 void* parent_window) { |
| 1879 window_->ShowHTMLDialog(delegate, parent_window); | 1883 window_->ShowHTMLDialog(delegate, parent_window); |
| 1880 } | 1884 } |
| 1881 | 1885 |
| 1882 void Browser::SetFocusToLocationBar() { | 1886 void Browser::SetFocusToLocationBar() { |
| 1883 // This is the same as FocusLocationBar above but doesn't record the user | 1887 // This is the same as FocusLocationBar above but doesn't record the user |
| 1884 // metrics. This TabContentsDelegate version is called internally, so | 1888 // metrics. This TabContentsDelegate version is called internally, so |
| 1885 // shouldn't get recorded in user commands. | 1889 // shouldn't get recorded in user commands. |
| 1886 window_->GetLocationBar()->FocusLocation(); | 1890 window_->GetLocationBar()->FocusLocation(); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 | 2458 |
| 2455 // We need to register the window position pref. | 2459 // We need to register the window position pref. |
| 2456 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2460 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2457 window_pref.append(L"_"); | 2461 window_pref.append(L"_"); |
| 2458 window_pref.append(app_name); | 2462 window_pref.append(app_name); |
| 2459 PrefService* prefs = g_browser_process->local_state(); | 2463 PrefService* prefs = g_browser_process->local_state(); |
| 2460 DCHECK(prefs); | 2464 DCHECK(prefs); |
| 2461 | 2465 |
| 2462 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2466 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2463 } | 2467 } |
| OLD | NEW |