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