OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/instance_id/instance_id_api.h" | 5 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" | 10 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 void InstanceIDGetCreationTimeFunction::GetCreationTimeCompleted( | 111 void InstanceIDGetCreationTimeFunction::GetCreationTimeCompleted( |
112 const base::Time& creation_time) { | 112 const base::Time& creation_time) { |
113 Respond(OneArgument(new base::FundamentalValue(creation_time.ToDoubleT()))); | 113 Respond(OneArgument(new base::FundamentalValue(creation_time.ToDoubleT()))); |
114 } | 114 } |
115 | 115 |
116 InstanceIDGetTokenFunction::InstanceIDGetTokenFunction() {} | 116 InstanceIDGetTokenFunction::InstanceIDGetTokenFunction() {} |
117 | 117 |
118 InstanceIDGetTokenFunction::~InstanceIDGetTokenFunction() {} | 118 InstanceIDGetTokenFunction::~InstanceIDGetTokenFunction() {} |
119 | 119 |
120 ExtensionFunction::ResponseAction InstanceIDGetTokenFunction::DoWork() { | 120 ExtensionFunction::ResponseAction InstanceIDGetTokenFunction::DoWork() { |
121 scoped_ptr<api::instance_id::GetToken::Params> params = | 121 std::unique_ptr<api::instance_id::GetToken::Params> params = |
122 api::instance_id::GetToken::Params::Create(*args_); | 122 api::instance_id::GetToken::Params::Create(*args_); |
123 EXTENSION_FUNCTION_VALIDATE(params.get()); | 123 EXTENSION_FUNCTION_VALIDATE(params.get()); |
124 | 124 |
125 std::map<std::string, std::string> options; | 125 std::map<std::string, std::string> options; |
126 if (params->get_token_params.options.get()) | 126 if (params->get_token_params.options.get()) |
127 options = params->get_token_params.options->additional_properties; | 127 options = params->get_token_params.options->additional_properties; |
128 | 128 |
129 GetInstanceID()->GetToken( | 129 GetInstanceID()->GetToken( |
130 params->get_token_params.authorized_entity, | 130 params->get_token_params.authorized_entity, |
131 params->get_token_params.scope, | 131 params->get_token_params.scope, |
(...skipping 10 matching lines...) Expand all Loading... |
142 Respond(OneArgument(new base::StringValue(token))); | 142 Respond(OneArgument(new base::StringValue(token))); |
143 else | 143 else |
144 Respond(Error(InstanceIDResultToError(result))); | 144 Respond(Error(InstanceIDResultToError(result))); |
145 } | 145 } |
146 | 146 |
147 InstanceIDDeleteTokenFunction::InstanceIDDeleteTokenFunction() {} | 147 InstanceIDDeleteTokenFunction::InstanceIDDeleteTokenFunction() {} |
148 | 148 |
149 InstanceIDDeleteTokenFunction::~InstanceIDDeleteTokenFunction() {} | 149 InstanceIDDeleteTokenFunction::~InstanceIDDeleteTokenFunction() {} |
150 | 150 |
151 ExtensionFunction::ResponseAction InstanceIDDeleteTokenFunction::DoWork() { | 151 ExtensionFunction::ResponseAction InstanceIDDeleteTokenFunction::DoWork() { |
152 scoped_ptr<api::instance_id::DeleteToken::Params> params = | 152 std::unique_ptr<api::instance_id::DeleteToken::Params> params = |
153 api::instance_id::DeleteToken::Params::Create(*args_); | 153 api::instance_id::DeleteToken::Params::Create(*args_); |
154 EXTENSION_FUNCTION_VALIDATE(params.get()); | 154 EXTENSION_FUNCTION_VALIDATE(params.get()); |
155 | 155 |
156 GetInstanceID()->DeleteToken( | 156 GetInstanceID()->DeleteToken( |
157 params->delete_token_params.authorized_entity, | 157 params->delete_token_params.authorized_entity, |
158 params->delete_token_params.scope, | 158 params->delete_token_params.scope, |
159 base::Bind(&InstanceIDDeleteTokenFunction::DeleteTokenCompleted, this)); | 159 base::Bind(&InstanceIDDeleteTokenFunction::DeleteTokenCompleted, this)); |
160 | 160 |
161 return RespondLater(); | 161 return RespondLater(); |
162 } | 162 } |
(...skipping 19 matching lines...) Expand all Loading... |
182 | 182 |
183 void InstanceIDDeleteIDFunction::DeleteIDCompleted( | 183 void InstanceIDDeleteIDFunction::DeleteIDCompleted( |
184 instance_id::InstanceID::Result result) { | 184 instance_id::InstanceID::Result result) { |
185 if (result == instance_id::InstanceID::SUCCESS) | 185 if (result == instance_id::InstanceID::SUCCESS) |
186 Respond(NoArguments()); | 186 Respond(NoArguments()); |
187 else | 187 else |
188 Respond(Error(InstanceIDResultToError(result))); | 188 Respond(Error(InstanceIDResultToError(result))); |
189 } | 189 } |
190 | 190 |
191 } // namespace extensions | 191 } // namespace extensions |
OLD | NEW |