| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/idle_timer.h" | 9 #include "base/idle_timer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/thread.h" | 12 #include "base/thread.h" |
| 13 #include "chrome/app/chrome_dll_resource.h" | 13 #include "chrome/app/chrome_dll_resource.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 16 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
| 17 #include "chrome/browser/browser_window.h" | 17 #include "chrome/browser/browser_window.h" |
| 18 #include "chrome/browser/character_encoding.h" | 18 #include "chrome/browser/character_encoding.h" |
| 19 #include "chrome/browser/debugger/debugger_host.h" | 19 #include "chrome/browser/debugger/debugger_host.h" |
| 20 #include "chrome/browser/debugger/devtools_manager.h" | 20 #include "chrome/browser/debugger/devtools_manager.h" |
| 21 #include "chrome/browser/download/download_item_model.h" |
| 21 #include "chrome/browser/download/download_manager.h" | 22 #include "chrome/browser/download/download_manager.h" |
| 23 #include "chrome/browser/download/download_shelf.h" |
| 24 #include "chrome/browser/download/download_started_animation.h" |
| 22 #include "chrome/browser/find_bar.h" | 25 #include "chrome/browser/find_bar.h" |
| 23 #include "chrome/browser/find_bar_controller.h" | 26 #include "chrome/browser/find_bar_controller.h" |
| 24 #include "chrome/browser/location_bar.h" | 27 #include "chrome/browser/location_bar.h" |
| 25 #include "chrome/browser/metrics/user_metrics.h" | 28 #include "chrome/browser/metrics/user_metrics.h" |
| 26 #include "chrome/browser/net/url_fixer_upper.h" | 29 #include "chrome/browser/net/url_fixer_upper.h" |
| 27 #include "chrome/browser/options_window.h" | 30 #include "chrome/browser/options_window.h" |
| 28 #include "chrome/browser/profile.h" | 31 #include "chrome/browser/profile.h" |
| 29 #include "chrome/browser/sessions/session_service.h" | 32 #include "chrome/browser/sessions/session_service.h" |
| 30 #include "chrome/browser/sessions/session_types.h" | 33 #include "chrome/browser/sessions/session_types.h" |
| 31 #include "chrome/browser/sessions/tab_restore_service.h" | 34 #include "chrome/browser/sessions/tab_restore_service.h" |
| 32 #include "chrome/browser/status_bubble.h" | 35 #include "chrome/browser/status_bubble.h" |
| 33 #include "chrome/browser/tab_contents/interstitial_page.h" | 36 #include "chrome/browser/tab_contents/interstitial_page.h" |
| 34 #include "chrome/browser/tab_contents/navigation_controller.h" | 37 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 35 #include "chrome/browser/tab_contents/navigation_entry.h" | 38 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 36 #include "chrome/browser/tab_contents/site_instance.h" | 39 #include "chrome/browser/tab_contents/site_instance.h" |
| 37 #include "chrome/browser/tab_contents/tab_contents.h" | 40 #include "chrome/browser/tab_contents/tab_contents.h" |
| 38 #include "chrome/browser/tab_contents/tab_contents_view.h" | 41 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 39 #include "chrome/browser/window_sizer.h" | 42 #include "chrome/browser/window_sizer.h" |
| 40 #include "chrome/common/chrome_constants.h" | 43 #include "chrome/common/chrome_constants.h" |
| 41 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/extensions/extension.h" | 45 #include "chrome/common/extensions/extension.h" |
| 43 #include "chrome/common/notification_service.h" | 46 #include "chrome/common/notification_service.h" |
| 44 #include "chrome/common/page_transition_types.h" | 47 #include "chrome/common/page_transition_types.h" |
| 48 #include "chrome/common/platform_util.h" |
| 45 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/common/pref_service.h" | 50 #include "chrome/common/pref_service.h" |
| 47 #include "chrome/common/url_constants.h" | 51 #include "chrome/common/url_constants.h" |
| 48 #ifdef CHROME_PERSONALIZATION | 52 #ifdef CHROME_PERSONALIZATION |
| 49 #include "chrome/personalization/personalization.h" | 53 #include "chrome/personalization/personalization.h" |
| 50 #endif | 54 #endif |
| 51 #include "grit/chromium_strings.h" | 55 #include "grit/chromium_strings.h" |
| 52 #include "grit/generated_resources.h" | 56 #include "grit/generated_resources.h" |
| 53 #include "grit/locale_settings.h" | 57 #include "grit/locale_settings.h" |
| 54 #include "net/base/cookie_monster.h" | 58 #include "net/base/cookie_monster.h" |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 UserMetrics::RecordAction(L"AboutChrome", profile_); | 1150 UserMetrics::RecordAction(L"AboutChrome", profile_); |
| 1147 window_->ShowAboutChromeDialog(); | 1151 window_->ShowAboutChromeDialog(); |
| 1148 } | 1152 } |
| 1149 | 1153 |
| 1150 void Browser::OpenHelpTab() { | 1154 void Browser::OpenHelpTab() { |
| 1151 GURL help_url(WideToASCII(l10n_util::GetString(IDS_HELP_CONTENT_URL))); | 1155 GURL help_url(WideToASCII(l10n_util::GetString(IDS_HELP_CONTENT_URL))); |
| 1152 AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1, | 1156 AddTabWithURL(help_url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1, |
| 1153 false, NULL); | 1157 false, NULL); |
| 1154 } | 1158 } |
| 1155 | 1159 |
| 1160 void Browser::OnStartDownload(DownloadItem* download) { |
| 1161 if (!window()) |
| 1162 return; |
| 1163 |
| 1164 // GetDownloadShelf creates the download shelf if it was not yet created. |
| 1165 window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download)); |
| 1166 |
| 1167 // TODO(port): port for mac. |
| 1168 #if defined(OS_WIN) || defined(OS_LINUX) |
| 1169 // Don't show the animation for "Save file" downloads. |
| 1170 if (download->total_bytes() > 0) { |
| 1171 TabContents* current_tab = GetSelectedTabContents(); |
| 1172 // We make this check for the case of minimized windows, unit tests, etc. |
| 1173 if (platform_util::IsVisible(current_tab->GetNativeView())) |
| 1174 DownloadStartedAnimation::Show(current_tab); |
| 1175 } |
| 1176 #endif |
| 1177 } |
| 1178 |
| 1156 /////////////////////////////////////////////////////////////////////////////// | 1179 /////////////////////////////////////////////////////////////////////////////// |
| 1157 | 1180 |
| 1158 // static | 1181 // static |
| 1159 void Browser::RegisterPrefs(PrefService* prefs) { | 1182 void Browser::RegisterPrefs(PrefService* prefs) { |
| 1160 prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 1183 prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); |
| 1161 prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); | 1184 prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); |
| 1162 } | 1185 } |
| 1163 | 1186 |
| 1164 // static | 1187 // static |
| 1165 void Browser::RegisterUserPrefs(PrefService* prefs) { | 1188 void Browser::RegisterUserPrefs(PrefService* prefs) { |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 | 2682 |
| 2660 // We need to register the window position pref. | 2683 // We need to register the window position pref. |
| 2661 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2684 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2662 window_pref.append(L"_"); | 2685 window_pref.append(L"_"); |
| 2663 window_pref.append(app_name); | 2686 window_pref.append(app_name); |
| 2664 PrefService* prefs = g_browser_process->local_state(); | 2687 PrefService* prefs = g_browser_process->local_state(); |
| 2665 DCHECK(prefs); | 2688 DCHECK(prefs); |
| 2666 | 2689 |
| 2667 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2690 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2668 } | 2691 } |
| OLD | NEW |