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

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

Issue 3033050: Rename DictionaryValue's SetStringFromUTF16() to SetString() (and overload). (Closed)
Patch Set: There shouldn't be wstrings in platform-ind. code. Created 10 years, 4 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_contents_service.h" 5 #include "chrome/browser/background_contents_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 16 matching lines...) Expand all
27 // prefs::kRegisteredBackgroundContents). Information about each 27 // prefs::kRegisteredBackgroundContents). Information about each
28 // BackgroundContents is stored under that top-level DictionaryValue, keyed 28 // BackgroundContents is stored under that top-level DictionaryValue, keyed
29 // by the parent application ID for easy lookup. 29 // by the parent application ID for easy lookup.
30 // 30 //
31 // kRegisteredBackgroundContents: 31 // kRegisteredBackgroundContents:
32 // DictionaryValue { 32 // DictionaryValue {
33 // <appid_1>: { "url": <url1>, "name": <frame_name> }, 33 // <appid_1>: { "url": <url1>, "name": <frame_name> },
34 // <appid_2>: { "url": <url2>, "name": <frame_name> }, 34 // <appid_2>: { "url": <url2>, "name": <frame_name> },
35 // ... etc ... 35 // ... etc ...
36 // } 36 // }
37 const wchar_t kUrlKey[] = L"url"; 37 const char kUrlKey[] = "url";
38 const wchar_t kFrameNameKey[] = L"name"; 38 const char kFrameNameKey[] = "name";
39 39
40 BackgroundContentsService::BackgroundContentsService( 40 BackgroundContentsService::BackgroundContentsService(
41 Profile* profile, const CommandLine* command_line) 41 Profile* profile, const CommandLine* command_line)
42 : prefs_(NULL), 42 : prefs_(NULL),
43 always_keep_alive_(command_line->HasSwitch(switches::kKeepAliveForTest)) { 43 always_keep_alive_(command_line->HasSwitch(switches::kKeepAliveForTest)) {
44 // Don't load/store preferences if the proper switch is not enabled, or if 44 // Don't load/store preferences if the proper switch is not enabled, or if
45 // the parent profile is off the record. 45 // the parent profile is off the record.
46 if (!profile->IsOffTheRecord() && 46 if (!profile->IsOffTheRecord() &&
47 command_line->HasSwitch(switches::kRestoreBackgroundContents)) 47 command_line->HasSwitch(switches::kRestoreBackgroundContents))
48 prefs_ = profile->GetPrefs(); 48 prefs_ = profile->GetPrefs();
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 DictionaryValue* pref = prefs_->GetMutableDictionary( 213 DictionaryValue* pref = prefs_->GetMutableDictionary(
214 prefs::kRegisteredBackgroundContents); 214 prefs::kRegisteredBackgroundContents);
215 const string16& appid = GetParentApplicationId(background_contents); 215 const string16& appid = GetParentApplicationId(background_contents);
216 DictionaryValue* current; 216 DictionaryValue* current;
217 if (pref->GetDictionaryWithoutPathExpansion(UTF16ToWide(appid), &current)) 217 if (pref->GetDictionaryWithoutPathExpansion(UTF16ToWide(appid), &current))
218 return; 218 return;
219 219
220 // No entry for this application yet, so add one. 220 // No entry for this application yet, so add one.
221 DictionaryValue* dict = new DictionaryValue(); 221 DictionaryValue* dict = new DictionaryValue();
222 dict->SetString(kUrlKey, background_contents->GetURL().spec()); 222 dict->SetString(kUrlKey, background_contents->GetURL().spec());
223 dict->SetStringFromUTF16(kFrameNameKey, contents_map_[appid].frame_name); 223 dict->SetString(kFrameNameKey, contents_map_[appid].frame_name);
224 pref->SetWithoutPathExpansion(UTF16ToWide(appid), dict); 224 pref->SetWithoutPathExpansion(UTF16ToWide(appid), dict);
225 prefs_->ScheduleSavePersistentPrefs(); 225 prefs_->ScheduleSavePersistentPrefs();
226 } 226 }
227 227
228 void BackgroundContentsService::UnregisterBackgroundContents( 228 void BackgroundContentsService::UnregisterBackgroundContents(
229 BackgroundContents* background_contents) { 229 BackgroundContents* background_contents) {
230 if (!prefs_) 230 if (!prefs_)
231 return; 231 return;
232 DCHECK(IsTracked(background_contents)); 232 DCHECK(IsTracked(background_contents));
233 const string16 appid = GetParentApplicationId(background_contents); 233 const string16 appid = GetParentApplicationId(background_contents);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if (contents == it->second.contents) 293 if (contents == it->second.contents)
294 return it->first; 294 return it->first;
295 } 295 }
296 return EmptyString16(); 296 return EmptyString16();
297 } 297 }
298 298
299 // static 299 // static
300 void BackgroundContentsService::RegisterUserPrefs(PrefService* prefs) { 300 void BackgroundContentsService::RegisterUserPrefs(PrefService* prefs) {
301 prefs->RegisterDictionaryPref(prefs::kRegisteredBackgroundContents); 301 prefs->RegisterDictionaryPref(prefs::kRegisteredBackgroundContents);
302 } 302 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.cc ('k') | chrome/browser/bookmarks/bookmark_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698