Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: chrome/browser/background/background_contents_service.cc

Issue 2806283002: Revert of Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
16 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
20 #include "base/time/time.h" 19 #include "base/time/time.h"
21 #include "base/values.h" 20 #include "base/values.h"
22 #include "chrome/browser/apps/app_load_service.h" 21 #include "chrome/browser/apps/app_load_service.h"
23 #include "chrome/browser/background/background_contents_service_factory.h" 22 #include "chrome/browser/background/background_contents_service_factory.h"
24 #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
757 DictionaryPrefUpdate update(prefs_, prefs::kRegisteredBackgroundContents); 756 DictionaryPrefUpdate update(prefs_, prefs::kRegisteredBackgroundContents);
758 base::DictionaryValue* pref = update.Get(); 757 base::DictionaryValue* pref = update.Get();
759 const base::string16& appid = GetParentApplicationId(background_contents); 758 const base::string16& appid = GetParentApplicationId(background_contents);
760 base::DictionaryValue* current; 759 base::DictionaryValue* current;
761 if (pref->GetDictionaryWithoutPathExpansion(base::UTF16ToUTF8(appid), 760 if (pref->GetDictionaryWithoutPathExpansion(base::UTF16ToUTF8(appid),
762 &current)) { 761 &current)) {
763 return; 762 return;
764 } 763 }
765 764
766 // No entry for this application yet, so add one. 765 // No entry for this application yet, so add one.
767 auto dict = base::MakeUnique<base::DictionaryValue>(); 766 base::DictionaryValue* dict = new base::DictionaryValue();
768 dict->SetString(kUrlKey, background_contents->GetURL().spec()); 767 dict->SetString(kUrlKey, background_contents->GetURL().spec());
769 dict->SetString(kFrameNameKey, contents_map_[appid].frame_name); 768 dict->SetString(kFrameNameKey, contents_map_[appid].frame_name);
770 pref->SetWithoutPathExpansion(base::UTF16ToUTF8(appid), std::move(dict)); 769 pref->SetWithoutPathExpansion(base::UTF16ToUTF8(appid), dict);
771 } 770 }
772 771
773 bool BackgroundContentsService::HasRegisteredBackgroundContents( 772 bool BackgroundContentsService::HasRegisteredBackgroundContents(
774 const base::string16& app_id) { 773 const base::string16& app_id) {
775 if (!prefs_) 774 if (!prefs_)
776 return false; 775 return false;
777 std::string app = base::UTF16ToUTF8(app_id); 776 std::string app = base::UTF16ToUTF8(app_id);
778 const base::DictionaryValue* contents = 777 const base::DictionaryValue* contents =
779 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); 778 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents);
780 return contents->HasKey(app); 779 return contents->HasKey(app);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 const gfx::Rect& initial_rect, 848 const gfx::Rect& initial_rect,
850 bool user_gesture, 849 bool user_gesture,
851 bool* was_blocked) { 850 bool* was_blocked) {
852 Browser* browser = chrome::FindLastActiveWithProfile( 851 Browser* browser = chrome::FindLastActiveWithProfile(
853 Profile::FromBrowserContext(new_contents->GetBrowserContext())); 852 Profile::FromBrowserContext(new_contents->GetBrowserContext()));
854 if (browser) { 853 if (browser) {
855 chrome::AddWebContents(browser, NULL, new_contents, disposition, 854 chrome::AddWebContents(browser, NULL, new_contents, disposition,
856 initial_rect, user_gesture, was_blocked); 855 initial_rect, user_gesture, was_blocked);
857 } 856 }
858 } 857 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698