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

Side by Side Diff: chrome/browser/extensions/extension_prefs.cc

Issue 164151: Fix "crashed extension" infobar browser crashes.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: sync with trunk Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions/extension_prefs.h" 5 #include "chrome/browser/extensions/extension_prefs.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 9
10 namespace { 10 namespace {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 382 }
383 383
384 return version; 384 return version;
385 } 385 }
386 386
387 void ExtensionPrefs::MigrateToPrefs(Extension* extension) { 387 void ExtensionPrefs::MigrateToPrefs(Extension* extension) {
388 UpdateExtensionPref(extension->id(), kPrefManifest, 388 UpdateExtensionPref(extension->id(), kPrefManifest,
389 extension->manifest_value()->DeepCopy()); 389 extension->manifest_value()->DeepCopy());
390 } 390 }
391 391
392 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) {
393 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);
394 if (!dict || dict->GetSize() == 0)
395 return FilePath();
396
397 std::wstring path;
398 if (!dict->GetString(ASCIIToWide(extension_id) + L"." + kPrefPath, &path))
399 return FilePath();
400
401 return install_directory_.Append(FilePath::FromWStringHack(path));
402 }
403
392 bool ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, 404 bool ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id,
393 const std::wstring& key, 405 const std::wstring& key,
394 Value* data_value) { 406 Value* data_value) {
395 DictionaryValue* extension = GetOrCreateExtensionPref(extension_id); 407 DictionaryValue* extension = GetOrCreateExtensionPref(extension_id);
396 if (!extension->Set(key, data_value)) { 408 if (!extension->Set(key, data_value)) {
397 NOTREACHED() << "Cannot modify key: '" << key.c_str() 409 NOTREACHED() << "Cannot modify key: '" << key.c_str()
398 << "' for extension: '" << extension_id.c_str() << "'"; 410 << "' for extension: '" << extension_id.c_str() << "'";
399 return false; 411 return false;
400 } 412 }
401 return true; 413 return true;
(...skipping 22 matching lines...) Expand all
424 } 436 }
425 437
426 DictionaryValue* ExtensionPrefs::GetExtensionPref( 438 DictionaryValue* ExtensionPrefs::GetExtensionPref(
427 const std::string& extension_id) { 439 const std::string& extension_id) {
428 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); 440 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);
429 DictionaryValue* extension = NULL; 441 DictionaryValue* extension = NULL;
430 std::wstring id = ASCIIToWide(extension_id); 442 std::wstring id = ASCIIToWide(extension_id);
431 dict->GetDictionary(id, &extension); 443 dict->GetDictionary(id, &extension);
432 return extension; 444 return extension;
433 } 445 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extensions_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698