| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 toolbar_model_(this), | 176 toolbar_model_(this), |
| 177 chrome_updater_factory_(this), | 177 chrome_updater_factory_(this), |
| 178 is_attempting_to_close_browser_(false), | 178 is_attempting_to_close_browser_(false), |
| 179 maximized_state_(MAXIMIZED_STATE_DEFAULT), | 179 maximized_state_(MAXIMIZED_STATE_DEFAULT), |
| 180 method_factory_(this), | 180 method_factory_(this), |
| 181 idle_task_(new BrowserIdleTimer) { | 181 idle_task_(new BrowserIdleTimer) { |
| 182 tabstrip_model_.AddObserver(this); | 182 tabstrip_model_.AddObserver(this); |
| 183 | 183 |
| 184 NotificationService::current()->AddObserver( | 184 NotificationService::current()->AddObserver( |
| 185 this, | 185 this, |
| 186 NotificationType::SSL_STATE_CHANGED, | 186 NotificationType::SSL_VISIBLE_STATE_CHANGED, |
| 187 NotificationService::AllSources()); | 187 NotificationService::AllSources()); |
| 188 | 188 |
| 189 InitCommandState(); | 189 InitCommandState(); |
| 190 BrowserList::AddBrowser(this); | 190 BrowserList::AddBrowser(this); |
| 191 | 191 |
| 192 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 192 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
| 193 profile_->GetPrefs(), NULL); | 193 profile_->GetPrefs(), NULL); |
| 194 | 194 |
| 195 // Trim browser memory on idle for low & medium memory models. | 195 // Trim browser memory on idle for low & medium memory models. |
| 196 if (g_browser_process->memory_model() < BrowserProcess::HIGH_MEMORY_MODEL) | 196 if (g_browser_process->memory_model() < BrowserProcess::HIGH_MEMORY_MODEL) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 221 SessionService* session_service = profile_->GetSessionService(); | 221 SessionService* session_service = profile_->GetSessionService(); |
| 222 if (session_service) | 222 if (session_service) |
| 223 session_service->WindowClosed(session_id_); | 223 session_service->WindowClosed(session_id_); |
| 224 | 224 |
| 225 TabRestoreService* tab_restore_service = profile()->GetTabRestoreService(); | 225 TabRestoreService* tab_restore_service = profile()->GetTabRestoreService(); |
| 226 if (tab_restore_service) | 226 if (tab_restore_service) |
| 227 tab_restore_service->BrowserClosed(this); | 227 tab_restore_service->BrowserClosed(this); |
| 228 | 228 |
| 229 NotificationService::current()->RemoveObserver( | 229 NotificationService::current()->RemoveObserver( |
| 230 this, | 230 this, |
| 231 NotificationType::SSL_STATE_CHANGED, | 231 NotificationType::SSL_VISIBLE_STATE_CHANGED, |
| 232 NotificationService::AllSources()); | 232 NotificationService::AllSources()); |
| 233 | 233 |
| 234 if (profile_->IsOffTheRecord() && | 234 if (profile_->IsOffTheRecord() && |
| 235 !BrowserList::IsOffTheRecordSessionActive()) { | 235 !BrowserList::IsOffTheRecordSessionActive()) { |
| 236 // We reuse the OTR cookie store across OTR windows. If the last OTR | 236 // We reuse the OTR cookie store across OTR windows. If the last OTR |
| 237 // window is closed, then we want to wipe the cookie store clean, so when | 237 // window is closed, then we want to wipe the cookie store clean, so when |
| 238 // an OTR window is open again, it starts with an empty cookie store. This | 238 // an OTR window is open again, it starts with an empty cookie store. This |
| 239 // also frees up the memory that the OTR cookies were using. OTR never | 239 // also frees up the memory that the OTR cookies were using. OTR never |
| 240 // loads or writes persistent cookies (there is no backing store), so we | 240 // loads or writes persistent cookies (there is no backing store), so we |
| 241 // can just delete all of the cookies in the store. | 241 // can just delete all of the cookies in the store. |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 case NotificationType::WEB_CONTENTS_DISCONNECTED: | 1925 case NotificationType::WEB_CONTENTS_DISCONNECTED: |
| 1926 if (is_attempting_to_close_browser_) { | 1926 if (is_attempting_to_close_browser_) { |
| 1927 // Need to do this asynchronously as it will close the tab, which is | 1927 // Need to do this asynchronously as it will close the tab, which is |
| 1928 // currently on the call stack above us. | 1928 // currently on the call stack above us. |
| 1929 MessageLoop::current()->PostTask(FROM_HERE, | 1929 MessageLoop::current()->PostTask(FROM_HERE, |
| 1930 method_factory_.NewRunnableMethod(&Browser::ClearUnloadState, | 1930 method_factory_.NewRunnableMethod(&Browser::ClearUnloadState, |
| 1931 Source<TabContents>(source).ptr())); | 1931 Source<TabContents>(source).ptr())); |
| 1932 } | 1932 } |
| 1933 break; | 1933 break; |
| 1934 | 1934 |
| 1935 case NotificationType::SSL_STATE_CHANGED: | 1935 case NotificationType::SSL_VISIBLE_STATE_CHANGED: |
| 1936 // When the current tab's SSL state changes, we need to update the URL | 1936 // When the current tab's SSL state changes, we need to update the URL |
| 1937 // bar to reflect the new state. Note that it's possible for the selected | 1937 // bar to reflect the new state. Note that it's possible for the selected |
| 1938 // tab contents to be NULL. This is because we listen for all sources | 1938 // tab contents to be NULL. This is because we listen for all sources |
| 1939 // (NavigationControllers) for convenience, so the notification could | 1939 // (NavigationControllers) for convenience, so the notification could |
| 1940 // actually be for a different window while we're doing asynchronous | 1940 // actually be for a different window while we're doing asynchronous |
| 1941 // closing of this one. | 1941 // closing of this one. |
| 1942 if (GetSelectedTabContents() && | 1942 if (GetSelectedTabContents() && |
| 1943 GetSelectedTabContents()->controller() == | 1943 GetSelectedTabContents()->controller() == |
| 1944 Source<NavigationController>(source).ptr()) | 1944 Source<NavigationController>(source).ptr()) |
| 1945 UpdateToolbar(false); | 1945 UpdateToolbar(false); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 | 2492 |
| 2493 // We need to register the window position pref. | 2493 // We need to register the window position pref. |
| 2494 std::wstring window_pref(prefs::kBrowserWindowPlacement); | 2494 std::wstring window_pref(prefs::kBrowserWindowPlacement); |
| 2495 window_pref.append(L"_"); | 2495 window_pref.append(L"_"); |
| 2496 window_pref.append(app_name); | 2496 window_pref.append(app_name); |
| 2497 PrefService* prefs = g_browser_process->local_state(); | 2497 PrefService* prefs = g_browser_process->local_state(); |
| 2498 DCHECK(prefs); | 2498 DCHECK(prefs); |
| 2499 | 2499 |
| 2500 prefs->RegisterDictionaryPref(window_pref.c_str()); | 2500 prefs->RegisterDictionaryPref(window_pref.c_str()); |
| 2501 } | 2501 } |
| OLD | NEW |