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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
jdoerrie
2017/04/06 14:25:49
#include "base/memory/ptr_util.h"
vabr (Chromium)
2017/04/07 20:40:39
Done.
| |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "chrome/browser/apps/app_load_service.h" | 21 #include "chrome/browser/apps/app_load_service.h" |
22 #include "chrome/browser/background/background_contents_service_factory.h" | 22 #include "chrome/browser/background/background_contents_service_factory.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 DictionaryPrefUpdate update(prefs_, prefs::kRegisteredBackgroundContents); | 756 DictionaryPrefUpdate update(prefs_, prefs::kRegisteredBackgroundContents); |
757 base::DictionaryValue* pref = update.Get(); | 757 base::DictionaryValue* pref = update.Get(); |
758 const base::string16& appid = GetParentApplicationId(background_contents); | 758 const base::string16& appid = GetParentApplicationId(background_contents); |
759 base::DictionaryValue* current; | 759 base::DictionaryValue* current; |
760 if (pref->GetDictionaryWithoutPathExpansion(base::UTF16ToUTF8(appid), | 760 if (pref->GetDictionaryWithoutPathExpansion(base::UTF16ToUTF8(appid), |
761 ¤t)) { | 761 ¤t)) { |
762 return; | 762 return; |
763 } | 763 } |
764 | 764 |
765 // No entry for this application yet, so add one. | 765 // No entry for this application yet, so add one. |
766 base::DictionaryValue* dict = new base::DictionaryValue(); | 766 auto dict = base::MakeUnique<base::DictionaryValue>(); |
767 dict->SetString(kUrlKey, background_contents->GetURL().spec()); | 767 dict->SetString(kUrlKey, background_contents->GetURL().spec()); |
768 dict->SetString(kFrameNameKey, contents_map_[appid].frame_name); | 768 dict->SetString(kFrameNameKey, contents_map_[appid].frame_name); |
769 pref->SetWithoutPathExpansion(base::UTF16ToUTF8(appid), dict); | 769 pref->SetWithoutPathExpansion(base::UTF16ToUTF8(appid), std::move(dict)); |
770 } | 770 } |
771 | 771 |
772 bool BackgroundContentsService::HasRegisteredBackgroundContents( | 772 bool BackgroundContentsService::HasRegisteredBackgroundContents( |
773 const base::string16& app_id) { | 773 const base::string16& app_id) { |
774 if (!prefs_) | 774 if (!prefs_) |
775 return false; | 775 return false; |
776 std::string app = base::UTF16ToUTF8(app_id); | 776 std::string app = base::UTF16ToUTF8(app_id); |
777 const base::DictionaryValue* contents = | 777 const base::DictionaryValue* contents = |
778 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); | 778 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); |
779 return contents->HasKey(app); | 779 return contents->HasKey(app); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 const gfx::Rect& initial_rect, | 848 const gfx::Rect& initial_rect, |
849 bool user_gesture, | 849 bool user_gesture, |
850 bool* was_blocked) { | 850 bool* was_blocked) { |
851 Browser* browser = chrome::FindLastActiveWithProfile( | 851 Browser* browser = chrome::FindLastActiveWithProfile( |
852 Profile::FromBrowserContext(new_contents->GetBrowserContext())); | 852 Profile::FromBrowserContext(new_contents->GetBrowserContext())); |
853 if (browser) { | 853 if (browser) { |
854 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 854 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
855 initial_rect, user_gesture, was_blocked); | 855 initial_rect, user_gesture, was_blocked); |
856 } | 856 } |
857 } | 857 } |
OLD | NEW |