| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 const string16& appid = GetParentApplicationId(background_contents); | 495 const string16& appid = GetParentApplicationId(background_contents); |
| 496 DictionaryValue* current; | 496 DictionaryValue* current; |
| 497 if (pref->GetDictionaryWithoutPathExpansion(UTF16ToUTF8(appid), ¤t)) | 497 if (pref->GetDictionaryWithoutPathExpansion(UTF16ToUTF8(appid), ¤t)) |
| 498 return; | 498 return; |
| 499 | 499 |
| 500 // No entry for this application yet, so add one. | 500 // No entry for this application yet, so add one. |
| 501 DictionaryValue* dict = new DictionaryValue(); | 501 DictionaryValue* dict = new DictionaryValue(); |
| 502 dict->SetString(kUrlKey, background_contents->GetURL().spec()); | 502 dict->SetString(kUrlKey, background_contents->GetURL().spec()); |
| 503 dict->SetString(kFrameNameKey, contents_map_[appid].frame_name); | 503 dict->SetString(kFrameNameKey, contents_map_[appid].frame_name); |
| 504 pref->SetWithoutPathExpansion(UTF16ToUTF8(appid), dict); | 504 pref->SetWithoutPathExpansion(UTF16ToUTF8(appid), dict); |
| 505 prefs_->ScheduleSavePersistentPrefs(); | |
| 506 } | 505 } |
| 507 | 506 |
| 508 void BackgroundContentsService::UnregisterBackgroundContents( | 507 void BackgroundContentsService::UnregisterBackgroundContents( |
| 509 BackgroundContents* background_contents) { | 508 BackgroundContents* background_contents) { |
| 510 if (!prefs_) | 509 if (!prefs_) |
| 511 return; | 510 return; |
| 512 DCHECK(IsTracked(background_contents)); | 511 DCHECK(IsTracked(background_contents)); |
| 513 const string16 appid = GetParentApplicationId(background_contents); | 512 const string16 appid = GetParentApplicationId(background_contents); |
| 514 DictionaryPrefUpdate update(prefs_, prefs::kRegisteredBackgroundContents); | 513 DictionaryPrefUpdate update(prefs_, prefs::kRegisteredBackgroundContents); |
| 515 update.Get()->RemoveWithoutPathExpansion(UTF16ToUTF8(appid), NULL); | 514 update.Get()->RemoveWithoutPathExpansion(UTF16ToUTF8(appid), NULL); |
| 516 prefs_->ScheduleSavePersistentPrefs(); | |
| 517 } | 515 } |
| 518 | 516 |
| 519 void BackgroundContentsService::ShutdownAssociatedBackgroundContents( | 517 void BackgroundContentsService::ShutdownAssociatedBackgroundContents( |
| 520 const string16& appid) { | 518 const string16& appid) { |
| 521 BackgroundContents* contents = GetAppBackgroundContents(appid); | 519 BackgroundContents* contents = GetAppBackgroundContents(appid); |
| 522 if (contents) { | 520 if (contents) { |
| 523 UnregisterBackgroundContents(contents); | 521 UnregisterBackgroundContents(contents); |
| 524 // Background contents destructor shuts down the renderer. | 522 // Background contents destructor shuts down the renderer. |
| 525 delete contents; | 523 delete contents; |
| 526 } | 524 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 TabContents* new_contents, | 570 TabContents* new_contents, |
| 573 WindowOpenDisposition disposition, | 571 WindowOpenDisposition disposition, |
| 574 const gfx::Rect& initial_pos, | 572 const gfx::Rect& initial_pos, |
| 575 bool user_gesture) { | 573 bool user_gesture) { |
| 576 Browser* browser = BrowserList::GetLastActiveWithProfile( | 574 Browser* browser = BrowserList::GetLastActiveWithProfile( |
| 577 Profile::FromBrowserContext(new_contents->GetBrowserContext())); | 575 Profile::FromBrowserContext(new_contents->GetBrowserContext())); |
| 578 if (!browser) | 576 if (!browser) |
| 579 return; | 577 return; |
| 580 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); | 578 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); |
| 581 } | 579 } |
| OLD | NEW |