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/extensions/api/commands/command_service.h" | 5 #include "chrome/browser/extensions/api/commands/command_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 | 798 |
799 const base::DictionaryValue* item = NULL; | 799 const base::DictionaryValue* item = NULL; |
800 it.value().GetAsDictionary(&item); | 800 it.value().GetAsDictionary(&item); |
801 | 801 |
802 std::string extension; | 802 std::string extension; |
803 item->GetString(kExtension, &extension); | 803 item->GetString(kExtension, &extension); |
804 | 804 |
805 if (extension == extension_id) { | 805 if (extension == extension_id) { |
806 // If |command_name| is specified, delete only that command. Otherwise, | 806 // If |command_name| is specified, delete only that command. Otherwise, |
807 // delete all commands. | 807 // delete all commands. |
808 if (!command_name.empty()) { | |
809 std::string command; | 808 std::string command; |
Mike Wittman
2015/02/13 22:11:20
indentation (+ next three lines)
| |
810 item->GetString(kCommandName, &command); | 809 item->GetString(kCommandName, &command); |
811 if (command_name != command) | 810 if (!command_name.empty() && command_name != command) |
812 continue; | 811 continue; |
813 } | |
814 | 812 |
815 keys_to_remove.push_back(it.key()); | 813 keys_to_remove.push_back(it.key()); |
814 | |
815 // Only clear the was_assigned pref if we clear all commands. | |
816 if (!command_name.empty()) | |
817 continue; | |
818 | |
819 scoped_ptr<base::DictionaryValue> command_keys(new base::DictionaryValue); | |
820 command_keys->SetBoolean(kSuggestedKeyWasAssigned, false); | |
Mike Wittman
2015/02/13 22:11:20
I'd prefer to remove this key from the preferences
| |
821 scoped_ptr<base::DictionaryValue> suggested_key_prefs( | |
822 new base::DictionaryValue); | |
823 suggested_key_prefs->Set(command, command_keys.release()); | |
824 MergeSuggestedKeyPrefs(extension_id, ExtensionPrefs::Get(profile_), | |
825 suggested_key_prefs.Pass()); | |
816 } | 826 } |
817 } | 827 } |
818 | 828 |
819 for (KeysToRemove::const_iterator it = keys_to_remove.begin(); | 829 for (KeysToRemove::const_iterator it = keys_to_remove.begin(); |
820 it != keys_to_remove.end(); ++it) { | 830 it != keys_to_remove.end(); ++it) { |
821 std::string key = *it; | 831 std::string key = *it; |
822 bindings->Remove(key, NULL); | 832 bindings->Remove(key, NULL); |
823 | 833 |
824 ExtensionCommandRemovedDetails details(extension_id, command_name, | 834 ExtensionCommandRemovedDetails details(extension_id, command_name, |
825 StripCurrentPlatform(key)); | 835 StripCurrentPlatform(key)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 return true; | 895 return true; |
886 } | 896 } |
887 | 897 |
888 template <> | 898 template <> |
889 void | 899 void |
890 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { | 900 BrowserContextKeyedAPIFactory<CommandService>::DeclareFactoryDependencies() { |
891 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); | 901 DependsOn(ExtensionCommandsGlobalRegistry::GetFactoryInstance()); |
892 } | 902 } |
893 | 903 |
894 } // namespace extensions | 904 } // namespace extensions |
OLD | NEW |