| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/background/background_contents_service.h" | 5 #include "chrome/browser/background/background_contents_service.h" |
| 6 | 6 |
| 7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // ... etc ... | 256 // ... etc ... |
| 257 // } | 257 // } |
| 258 const char kUrlKey[] = "url"; | 258 const char kUrlKey[] = "url"; |
| 259 const char kFrameNameKey[] = "name"; | 259 const char kFrameNameKey[] = "name"; |
| 260 | 260 |
| 261 int BackgroundContentsService::restart_delay_in_ms_ = 3000; // 3 seconds. | 261 int BackgroundContentsService::restart_delay_in_ms_ = 3000; // 3 seconds. |
| 262 | 262 |
| 263 BackgroundContentsService::BackgroundContentsService( | 263 BackgroundContentsService::BackgroundContentsService( |
| 264 Profile* profile, const CommandLine* command_line) | 264 Profile* profile, const CommandLine* command_line) |
| 265 : prefs_(NULL) { | 265 : prefs_(NULL) { |
| 266 // Don't load/store preferences if the proper switch is not enabled, or if | 266 // Don't load/store preferences if the parent profile is incognito. |
| 267 // the parent profile is incognito. | 267 if (!profile->IsOffTheRecord()) |
| 268 if (!profile->IsOffTheRecord() && | |
| 269 !command_line->HasSwitch(switches::kDisableRestoreBackgroundContents)) | |
| 270 prefs_ = profile->GetPrefs(); | 268 prefs_ = profile->GetPrefs(); |
| 271 | 269 |
| 272 // Listen for events to tell us when to load/unload persisted background | 270 // Listen for events to tell us when to load/unload persisted background |
| 273 // contents. | 271 // contents. |
| 274 StartObserving(profile); | 272 StartObserving(profile); |
| 275 } | 273 } |
| 276 | 274 |
| 277 BackgroundContentsService::~BackgroundContentsService() { | 275 BackgroundContentsService::~BackgroundContentsService() { |
| 278 // BackgroundContents should be shutdown before we go away, as otherwise | 276 // BackgroundContents should be shutdown before we go away, as otherwise |
| 279 // our browser process refcount will be off. | 277 // our browser process refcount will be off. |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 bool user_gesture, | 787 bool user_gesture, |
| 790 bool* was_blocked) { | 788 bool* was_blocked) { |
| 791 Browser* browser = chrome::FindLastActiveWithProfile( | 789 Browser* browser = chrome::FindLastActiveWithProfile( |
| 792 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 790 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 793 chrome::GetActiveDesktop()); | 791 chrome::GetActiveDesktop()); |
| 794 if (browser) { | 792 if (browser) { |
| 795 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 793 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 796 initial_pos, user_gesture, was_blocked); | 794 initial_pos, user_gesture, was_blocked); |
| 797 } | 795 } |
| 798 } | 796 } |
| OLD | NEW |