| 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" |
| 11 #include "chrome/app/chrome_dll_resource.h" | 11 #include "chrome/app/chrome_dll_resource.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
| 14 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
| 15 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 15 #include "chrome/browser/location_bar.h" | 16 #include "chrome/browser/location_bar.h" |
| 16 #include "chrome/browser/metrics/user_metrics.h" | 17 #include "chrome/browser/metrics/user_metrics.h" |
| 17 #include "chrome/browser/net/url_fixer_upper.h" | 18 #include "chrome/browser/net/url_fixer_upper.h" |
| 18 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 19 #include "chrome/browser/sessions/session_service.h" | 20 #include "chrome/browser/sessions/session_service.h" |
| 20 #include "chrome/browser/sessions/session_types.h" | 21 #include "chrome/browser/sessions/session_types.h" |
| 21 #include "chrome/browser/sessions/tab_restore_service.h" | 22 #include "chrome/browser/sessions/tab_restore_service.h" |
| 22 #include "chrome/browser/tab_contents/interstitial_page.h" | 23 #include "chrome/browser/tab_contents/interstitial_page.h" |
| 23 #include "chrome/browser/tab_contents/navigation_controller.h" | 24 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 24 #include "chrome/browser/tab_contents/navigation_entry.h" | 25 #include "chrome/browser/tab_contents/navigation_entry.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 #include "net/base/net_util.h" | 41 #include "net/base/net_util.h" |
| 41 #include "net/base/registry_controlled_domain.h" | 42 #include "net/base/registry_controlled_domain.h" |
| 42 #include "net/url_request/url_request_context.h" | 43 #include "net/url_request/url_request_context.h" |
| 43 #include "webkit/glue/window_open_disposition.h" | 44 #include "webkit/glue/window_open_disposition.h" |
| 44 | 45 |
| 45 #if defined(OS_WIN) || defined(OS_LINUX) | 46 #if defined(OS_WIN) || defined(OS_LINUX) |
| 46 #include "chrome/browser/status_bubble.h" | 47 #include "chrome/browser/status_bubble.h" |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 50 | |
| 51 #include <windows.h> | 51 #include <windows.h> |
| 52 #include <shellapi.h> | 52 #include <shellapi.h> |
| 53 | 53 |
| 54 #include "chrome/browser/automation/ui_controls.h" | 54 #include "chrome/browser/automation/ui_controls.h" |
| 55 #include "chrome/browser/browser_process.h" | 55 #include "chrome/browser/browser_process.h" |
| 56 #include "chrome/browser/browser_url_handler.h" | 56 #include "chrome/browser/browser_url_handler.h" |
| 57 #include "chrome/browser/browser_window.h" | 57 #include "chrome/browser/browser_window.h" |
| 58 #include "chrome/browser/cert_store.h" | 58 #include "chrome/browser/cert_store.h" |
| 59 #include "chrome/browser/character_encoding.h" | 59 #include "chrome/browser/character_encoding.h" |
| 60 #include "chrome/browser/debugger/debugger_window.h" | 60 #include "chrome/browser/debugger/debugger_window.h" |
| 61 #include "chrome/browser/dock_info.h" | 61 #include "chrome/browser/dock_info.h" |
| 62 #include "chrome/browser/dom_ui/new_tab_ui.h" | 62 #include "chrome/browser/dom_ui/downloads_ui.h" |
| 63 #include "chrome/browser/dom_ui/history_ui.h" |
| 63 #include "chrome/browser/download/save_package.h" | 64 #include "chrome/browser/download/save_package.h" |
| 64 #include "chrome/browser/history_tab_ui.h" | |
| 65 #include "chrome/browser/options_window.h" | 65 #include "chrome/browser/options_window.h" |
| 66 #include "chrome/browser/ssl/ssl_error_info.h" | 66 #include "chrome/browser/ssl/ssl_error_info.h" |
| 67 #include "chrome/browser/tab_contents/web_contents_view.h" | 67 #include "chrome/browser/tab_contents/web_contents_view.h" |
| 68 #include "chrome/browser/task_manager.h" | 68 #include "chrome/browser/task_manager.h" |
| 69 #include "chrome/browser/user_data_manager.h" | 69 #include "chrome/browser/user_data_manager.h" |
| 70 #include "chrome/browser/view_ids.h" | 70 #include "chrome/browser/view_ids.h" |
| 71 #include "chrome/browser/views/download_tab_view.h" | 71 #include "chrome/browser/views/download_tab_view.h" |
| 72 #include "chrome/browser/views/location_bar_view.h" | 72 #include "chrome/browser/views/location_bar_view.h" |
| 73 #include "chrome/browser/window_sizer.h" | 73 #include "chrome/browser/window_sizer.h" |
| 74 #include "chrome/common/child_process_host.h" | 74 #include "chrome/common/child_process_host.h" |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 window_->ShowReportBugDialog(); | 951 window_->ShowReportBugDialog(); |
| 952 } | 952 } |
| 953 | 953 |
| 954 void Browser::ToggleBookmarkBar() { | 954 void Browser::ToggleBookmarkBar() { |
| 955 UserMetrics::RecordAction(L"ShowBookmarksBar", profile_); | 955 UserMetrics::RecordAction(L"ShowBookmarksBar", profile_); |
| 956 window_->ToggleBookmarkBar(); | 956 window_->ToggleBookmarkBar(); |
| 957 } | 957 } |
| 958 | 958 |
| 959 void Browser::ShowHistoryTab() { | 959 void Browser::ShowHistoryTab() { |
| 960 UserMetrics::RecordAction(L"ShowHistory", profile_); | 960 UserMetrics::RecordAction(L"ShowHistory", profile_); |
| 961 ShowNativeUITab(HistoryTabUI::GetURL()); | 961 GURL downloads_url = HistoryUI::GetBaseURL(); |
| 962 AddTabWithURL(downloads_url, GURL(), PageTransition::AUTO_BOOKMARK, true, |
| 963 NULL); |
| 962 } | 964 } |
| 963 | 965 |
| 964 void Browser::OpenBookmarkManager() { | 966 void Browser::OpenBookmarkManager() { |
| 965 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_); | 967 UserMetrics::RecordAction(L"ShowBookmarkManager", profile_); |
| 966 window_->ShowBookmarkManager(); | 968 window_->ShowBookmarkManager(); |
| 967 } | 969 } |
| 968 | 970 |
| 969 void Browser::ShowDownloadsTab() { | 971 void Browser::ShowDownloadsTab() { |
| 970 UserMetrics::RecordAction(L"ShowDownloads", profile_); | 972 UserMetrics::RecordAction(L"ShowDownloads", profile_); |
| 971 ShowNativeUITab(DownloadTabUI::GetURL()); | 973 GURL downloads_url = DownloadsUI::GetBaseURL(); |
| 974 AddTabWithURL(downloads_url, GURL(), PageTransition::AUTO_BOOKMARK, true, |
| 975 NULL); |
| 972 } | 976 } |
| 973 | 977 |
| 974 void Browser::OpenClearBrowsingDataDialog() { | 978 void Browser::OpenClearBrowsingDataDialog() { |
| 975 UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_); | 979 UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_); |
| 976 window_->ShowClearBrowsingDataDialog(); | 980 window_->ShowClearBrowsingDataDialog(); |
| 977 } | 981 } |
| 978 | 982 |
| 979 void Browser::OpenImportSettingsDialog() { | 983 void Browser::OpenImportSettingsDialog() { |
| 980 UserMetrics::RecordAction(L"Import_ShowDlg", profile_); | 984 UserMetrics::RecordAction(L"Import_ShowDlg", profile_); |
| 981 window_->ShowImportDialog(); | 985 window_->ShowImportDialog(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 default: | 1211 default: |
| 1208 LOG(WARNING) << "Received Unimplemented Command: " << id; | 1212 LOG(WARNING) << "Received Unimplemented Command: " << id; |
| 1209 break; | 1213 break; |
| 1210 } | 1214 } |
| 1211 } | 1215 } |
| 1212 | 1216 |
| 1213 /////////////////////////////////////////////////////////////////////////////// | 1217 /////////////////////////////////////////////////////////////////////////////// |
| 1214 // Browser, TabStripModelDelegate implementation: | 1218 // Browser, TabStripModelDelegate implementation: |
| 1215 | 1219 |
| 1216 GURL Browser::GetBlankTabURL() const { | 1220 GURL Browser::GetBlankTabURL() const { |
| 1217 return NewTabUIURL(); | 1221 return NewTabUI::GetBaseURL(); |
| 1218 } | 1222 } |
| 1219 | 1223 |
| 1220 void Browser::CreateNewStripWithContents(TabContents* detached_contents, | 1224 void Browser::CreateNewStripWithContents(TabContents* detached_contents, |
| 1221 const gfx::Rect& window_bounds, | 1225 const gfx::Rect& window_bounds, |
| 1222 const DockInfo& dock_info) { | 1226 const DockInfo& dock_info) { |
| 1223 DCHECK(type_ == TYPE_NORMAL); | 1227 DCHECK(type_ == TYPE_NORMAL); |
| 1224 | 1228 |
| 1225 gfx::Rect new_window_bounds = window_bounds; | 1229 gfx::Rect new_window_bounds = window_bounds; |
| 1226 bool maximize = false; | 1230 bool maximize = false; |
| 1227 if (dock_info.GetNewWindowBounds(&new_window_bounds, &maximize)) | 1231 if (dock_info.GetNewWindowBounds(&new_window_bounds, &maximize)) |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2365 // onblur="" handlers. | 2369 // onblur="" handlers. |
| 2366 browser->window()->Show(); | 2370 browser->window()->Show(); |
| 2367 // TODO(beng): See if this can be made to use | 2371 // TODO(beng): See if this can be made to use |
| 2368 // TabStripModel::AppendTabContents. | 2372 // TabStripModel::AppendTabContents. |
| 2369 browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, | 2373 browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, |
| 2370 gfx::Rect(), true); | 2374 gfx::Rect(), true); |
| 2371 } | 2375 } |
| 2372 | 2376 |
| 2373 GURL Browser::GetHomePage() { | 2377 GURL Browser::GetHomePage() { |
| 2374 if (profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) | 2378 if (profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) |
| 2375 return NewTabUIURL(); | 2379 return NewTabUI::GetBaseURL(); |
| 2376 GURL home_page = GURL(URLFixerUpper::FixupURL( | 2380 GURL home_page = GURL(URLFixerUpper::FixupURL( |
| 2377 WideToUTF8(profile_->GetPrefs()->GetString(prefs::kHomePage)), | 2381 WideToUTF8(profile_->GetPrefs()->GetString(prefs::kHomePage)), |
| 2378 std::string())); | 2382 std::string())); |
| 2379 if (!home_page.is_valid()) | 2383 if (!home_page.is_valid()) |
| 2380 return NewTabUIURL(); | 2384 return NewTabUI::GetBaseURL(); |
| 2381 return home_page; | 2385 return home_page; |
| 2382 } | 2386 } |
| 2383 | 2387 |
| 2384 #if defined(OS_WIN) | 2388 #if defined(OS_WIN) |
| 2385 void Browser::FindInPage(bool find_next, bool forward_direction) { | 2389 void Browser::FindInPage(bool find_next, bool forward_direction) { |
| 2386 window_->ShowFindBar(); | 2390 window_->ShowFindBar(); |
| 2387 if (find_next) { | 2391 if (find_next) { |
| 2388 GetSelectedTabContents()->AsWebContents()->StartFinding( | 2392 GetSelectedTabContents()->AsWebContents()->StartFinding( |
| 2389 std::wstring(), | 2393 std::wstring(), |
| 2390 forward_direction); | 2394 forward_direction); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2420 | 2424 |
| 2421 // We need to register the window position pref. | 2425 // We need to register the window position pref. |
| 2422 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2426 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2423 window_pref.append(L"_"); | 2427 window_pref.append(L"_"); |
| 2424 window_pref.append(app_name); | 2428 window_pref.append(app_name); |
| 2425 PrefService* prefs = g_browser_process->local_state(); | 2429 PrefService* prefs = g_browser_process->local_state(); |
| 2426 DCHECK(prefs); | 2430 DCHECK(prefs); |
| 2427 | 2431 |
| 2428 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2432 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2429 } | 2433 } |
| OLD | NEW |