| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/apps/drive/drive_app_mapping.h" | 5 #include "chrome/browser/apps/drive/drive_app_mapping.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/prefs/scoped_user_pref_update.h" | 8 #include "base/prefs/scoped_user_pref_update.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool DriveAppMapping::IsChromeAppGenerated( | 96 bool DriveAppMapping::IsChromeAppGenerated( |
| 97 const std::string& chrome_app_id) const { | 97 const std::string& chrome_app_id) const { |
| 98 const base::DictionaryValue* mapping = | 98 const base::DictionaryValue* mapping = |
| 99 prefs_->GetDictionary(prefs::kAppLauncherDriveAppMapping); | 99 prefs_->GetDictionary(prefs::kAppLauncherDriveAppMapping); |
| 100 for (base::DictionaryValue::Iterator it(*mapping); !it.IsAtEnd(); | 100 for (base::DictionaryValue::Iterator it(*mapping); !it.IsAtEnd(); |
| 101 it.Advance()) { | 101 it.Advance()) { |
| 102 const base::DictionaryValue* info_dict; | 102 const base::DictionaryValue* info_dict; |
| 103 std::string value_string; | 103 std::string value_string; |
| 104 bool generated; | 104 bool generated = false; |
| 105 DCHECK(it.value().IsType(base::Value::TYPE_DICTIONARY)); | 105 DCHECK(it.value().IsType(base::Value::TYPE_DICTIONARY)); |
| 106 if (it.value().GetAsDictionary(&info_dict) && | 106 if (it.value().GetAsDictionary(&info_dict) && |
| 107 info_dict->GetStringWithoutPathExpansion(kKeyChromeApp, | 107 info_dict->GetStringWithoutPathExpansion(kKeyChromeApp, |
| 108 &value_string) && | 108 &value_string) && |
| 109 value_string == chrome_app_id && | 109 value_string == chrome_app_id && |
| 110 info_dict->GetBooleanWithoutPathExpansion(kKeyGenerated, &generated)) { | 110 info_dict->GetBooleanWithoutPathExpansion(kKeyGenerated, &generated)) { |
| 111 return generated; | 111 return generated; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 std::set<std::string> DriveAppMapping::GetDriveAppIds() const { | 118 std::set<std::string> DriveAppMapping::GetDriveAppIds() const { |
| 119 const base::DictionaryValue* mapping = | 119 const base::DictionaryValue* mapping = |
| 120 prefs_->GetDictionary(prefs::kAppLauncherDriveAppMapping); | 120 prefs_->GetDictionary(prefs::kAppLauncherDriveAppMapping); |
| 121 std::set<std::string> keys; | 121 std::set<std::string> keys; |
| 122 for (base::DictionaryValue::Iterator it(*mapping); !it.IsAtEnd(); | 122 for (base::DictionaryValue::Iterator it(*mapping); !it.IsAtEnd(); |
| 123 it.Advance()) { | 123 it.Advance()) { |
| 124 keys.insert(it.key()); | 124 keys.insert(it.key()); |
| 125 } | 125 } |
| 126 return keys; | 126 return keys; |
| 127 } | 127 } |
| OLD | NEW |