| 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/developer_private/developer_private_api.
h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 return GetImageURLFromData(contents); | 138 return GetImageURLFromData(contents); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void BroadcastItemStateChanged(content::BrowserContext* browser_context, | 141 void BroadcastItemStateChanged(content::BrowserContext* browser_context, |
| 142 developer::EventType event_type, | 142 developer::EventType event_type, |
| 143 const std::string& item_id) { | 143 const std::string& item_id) { |
| 144 developer::EventData event_data; | 144 developer::EventData event_data; |
| 145 event_data.event_type = event_type; | 145 event_data.event_type = event_type; |
| 146 event_data.item_id = item_id; | 146 event_data.item_id = item_id; |
| 147 event_data.extension_info = |
| 148 ExtensionInfoGenerator(browser_context).CreateExtensionInfo(item_id); |
| 147 | 149 |
| 148 scoped_ptr<base::ListValue> args(new base::ListValue()); | 150 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 149 args->Append(event_data.ToValue().release()); | 151 args->Append(event_data.ToValue().release()); |
| 150 scoped_ptr<Event> event(new Event( | 152 scoped_ptr<Event> event(new Event( |
| 151 developer_private::OnItemStateChanged::kEventName, args.Pass())); | 153 developer_private::OnItemStateChanged::kEventName, args.Pass())); |
| 152 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass()); | 154 EventRouter::Get(browser_context)->BroadcastEvent(event.Pass()); |
| 153 } | 155 } |
| 154 | 156 |
| 155 std::string ReadFileToString(const base::FilePath& path) { | 157 std::string ReadFileToString(const base::FilePath& path) { |
| 156 std::string data; | 158 std::string data; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 DeveloperPrivateGetExtensionInfoFunction:: | 373 DeveloperPrivateGetExtensionInfoFunction:: |
| 372 ~DeveloperPrivateGetExtensionInfoFunction() { | 374 ~DeveloperPrivateGetExtensionInfoFunction() { |
| 373 } | 375 } |
| 374 | 376 |
| 375 ExtensionFunction::ResponseAction | 377 ExtensionFunction::ResponseAction |
| 376 DeveloperPrivateGetExtensionInfoFunction::Run() { | 378 DeveloperPrivateGetExtensionInfoFunction::Run() { |
| 377 scoped_ptr<developer::GetExtensionInfo::Params> params( | 379 scoped_ptr<developer::GetExtensionInfo::Params> params( |
| 378 developer::GetExtensionInfo::Params::Create(*args_)); | 380 developer::GetExtensionInfo::Params::Create(*args_)); |
| 379 EXTENSION_FUNCTION_VALIDATE(params); | 381 EXTENSION_FUNCTION_VALIDATE(params); |
| 380 | 382 |
| 381 ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); | 383 scoped_ptr<developer::ExtensionInfo> info = |
| 382 developer::ExtensionState state = developer::EXTENSION_STATE_ENABLED; | 384 ExtensionInfoGenerator(browser_context()).CreateExtensionInfo(params->id); |
| 383 const Extension* extension = | |
| 384 registry->enabled_extensions().GetByID(params->id); | |
| 385 if (!extension && | |
| 386 (extension = registry->disabled_extensions().GetByID(params->id)) != | |
| 387 nullptr) { | |
| 388 state = developer::EXTENSION_STATE_DISABLED; | |
| 389 } else if (!extension && | |
| 390 (extension = | |
| 391 registry->terminated_extensions().GetByID(params->id)) != | |
| 392 nullptr) { | |
| 393 state = developer::EXTENSION_STATE_TERMINATED; | |
| 394 } | |
| 395 | 385 |
| 396 if (!extension) | 386 if (!info) |
| 397 return RespondNow(Error(kNoSuchExtensionError)); | 387 return RespondNow(Error(kNoSuchExtensionError)); |
| 398 | 388 |
| 399 return RespondNow(OneArgument(ExtensionInfoGenerator(browser_context()). | 389 return RespondNow(OneArgument(info->ToValue().release())); |
| 400 CreateExtensionInfo(*extension, state)->ToValue().release())); | |
| 401 } | 390 } |
| 402 | 391 |
| 403 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} | 392 DeveloperPrivateGetItemsInfoFunction::DeveloperPrivateGetItemsInfoFunction() {} |
| 404 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} | 393 DeveloperPrivateGetItemsInfoFunction::~DeveloperPrivateGetItemsInfoFunction() {} |
| 405 | 394 |
| 406 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { | 395 ExtensionFunction::ResponseAction DeveloperPrivateGetItemsInfoFunction::Run() { |
| 407 scoped_ptr<developer::GetItemsInfo::Params> params( | 396 scoped_ptr<developer::GetItemsInfo::Params> params( |
| 408 developer::GetItemsInfo::Params::Create(*args_)); | 397 developer::GetItemsInfo::Params::Create(*args_)); |
| 409 EXTENSION_FUNCTION_VALIDATE(params); | 398 EXTENSION_FUNCTION_VALIDATE(params); |
| 410 | 399 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 } | 1185 } |
| 1197 error_console->RemoveErrors(ErrorMap::Filter( | 1186 error_console->RemoveErrors(ErrorMap::Filter( |
| 1198 properties.extension_id, type, error_ids, false)); | 1187 properties.extension_id, type, error_ids, false)); |
| 1199 | 1188 |
| 1200 return RespondNow(NoArguments()); | 1189 return RespondNow(NoArguments()); |
| 1201 } | 1190 } |
| 1202 | 1191 |
| 1203 } // namespace api | 1192 } // namespace api |
| 1204 | 1193 |
| 1205 } // namespace extensions | 1194 } // namespace extensions |
| OLD | NEW |