OLD | NEW |
---|---|
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/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 "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 } | 557 } |
558 | 558 |
559 void ExtensionPrefs::SetAllowFileAccess(const std::string& extension_id, | 559 void ExtensionPrefs::SetAllowFileAccess(const std::string& extension_id, |
560 bool allow) { | 560 bool allow) { |
561 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, | 561 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, |
562 Value::CreateBooleanValue(allow)); | 562 Value::CreateBooleanValue(allow)); |
563 SavePrefsAndNotify(); | 563 SavePrefsAndNotify(); |
564 } | 564 } |
565 | 565 |
566 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType( | 566 ExtensionPrefs::LaunchType ExtensionPrefs::GetLaunchType( |
567 const std::string& extension_id) { | 567 const std::string& extension_id, |
568 ExtensionPrefs::LaunchType default_pref_value) { | |
568 int value; | 569 int value; |
570 LaunchType result; | |
Aaron Boodman
2010/11/30 00:29:28
Nit: Always initialize primitives.
Sam Kerner (Chrome)
2010/11/30 01:21:04
Done.
| |
571 | |
569 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) && | 572 if (ReadExtensionPrefInteger(extension_id, kPrefLaunchType, &value) && |
570 (value == LAUNCH_PINNED || | 573 (value == LAUNCH_PINNED || |
571 value == LAUNCH_REGULAR || | 574 value == LAUNCH_REGULAR || |
572 value == LAUNCH_FULLSCREEN || | 575 value == LAUNCH_FULLSCREEN || |
573 value == LAUNCH_WINDOW)) { | 576 value == LAUNCH_WINDOW)) { |
574 | 577 result = static_cast<LaunchType>(value); |
575 #if defined(OS_MACOSX) | 578 } else { |
579 result = default_pref_value; | |
580 } | |
581 #if defined(OS_MACOSX) | |
576 // App windows are not yet supported on mac. Pref sync could make | 582 // App windows are not yet supported on mac. Pref sync could make |
577 // the launch type LAUNCH_WINDOW, even if there is no UI to set it | 583 // the launch type LAUNCH_WINDOW, even if there is no UI to set it |
578 // on mac. | 584 // on mac. |
579 if (value == LAUNCH_WINDOW) | 585 if (result == LAUNCH_WINDOW) |
580 return LAUNCH_REGULAR; | 586 result = LAUNCH_REGULAR; |
581 #endif | 587 #endif |
582 return static_cast<LaunchType>(value); | |
583 } | |
584 | 588 |
585 return LAUNCH_REGULAR; | 589 return result; |
590 } | |
591 | |
592 extension_misc::LaunchContainer ExtensionPrefs::GetLaunchContainer( | |
593 const Extension* extension, | |
594 ExtensionPrefs::LaunchType default_pref_value) { | |
595 extension_misc::LaunchContainer launch_container = | |
596 extension->launch_container(); | |
597 | |
598 ExtensionPrefs::LaunchType prefs_launch_type = | |
599 GetLaunchType(extension->id(), default_pref_value); | |
600 | |
601 // If the user chose to open in a window, then launch in one. | |
602 if (prefs_launch_type == ExtensionPrefs::LAUNCH_WINDOW) | |
603 return extension_misc::LAUNCH_WINDOW; | |
604 | |
605 // Otherwise, use the container the extension chose. | |
606 return launch_container; | |
586 } | 607 } |
587 | 608 |
588 void ExtensionPrefs::SetLaunchType(const std::string& extension_id, | 609 void ExtensionPrefs::SetLaunchType(const std::string& extension_id, |
589 LaunchType launch_type) { | 610 LaunchType launch_type) { |
590 UpdateExtensionPref(extension_id, kPrefLaunchType, | 611 UpdateExtensionPref(extension_id, kPrefLaunchType, |
591 Value::CreateIntegerValue(static_cast<int>(launch_type))); | 612 Value::CreateIntegerValue(static_cast<int>(launch_type))); |
592 SavePrefsAndNotify(); | 613 SavePrefsAndNotify(); |
593 } | 614 } |
594 | 615 |
595 void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) { | 616 void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { | 1093 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
1073 prefs->RegisterDictionaryPref(kExtensionsPref); | 1094 prefs->RegisterDictionaryPref(kExtensionsPref); |
1074 prefs->RegisterListPref(kExtensionToolbar); | 1095 prefs->RegisterListPref(kExtensionToolbar); |
1075 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); | 1096 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); |
1076 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); | 1097 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); |
1077 prefs->RegisterListPref(prefs::kExtensionInstallAllowList); | 1098 prefs->RegisterListPref(prefs::kExtensionInstallAllowList); |
1078 prefs->RegisterListPref(prefs::kExtensionInstallDenyList); | 1099 prefs->RegisterListPref(prefs::kExtensionInstallDenyList); |
1079 prefs->RegisterListPref(prefs::kExtensionInstallForceList); | 1100 prefs->RegisterListPref(prefs::kExtensionInstallForceList); |
1080 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */); | 1101 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */); |
1081 } | 1102 } |
OLD | NEW |