| 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/management/management_api.h" | 5 #include "chrome/browser/extensions/api/management/management_api.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } // namespace | 228 } // namespace |
| 229 | 229 |
| 230 ExtensionService* ManagementFunction::service() { | 230 ExtensionService* ManagementFunction::service() { |
| 231 return GetProfile()->GetExtensionService(); | 231 return GetProfile()->GetExtensionService(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 ExtensionService* AsyncManagementFunction::service() { | 234 ExtensionService* AsyncManagementFunction::service() { |
| 235 return GetProfile()->GetExtensionService(); | 235 return GetProfile()->GetExtensionService(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool ManagementGetAllFunction::RunImpl() { | 238 bool ManagementGetAllFunction::RunSync() { |
| 239 ExtensionInfoList extensions; | 239 ExtensionInfoList extensions; |
| 240 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); | 240 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); |
| 241 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); | 241 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); |
| 242 | 242 |
| 243 AddExtensionInfo(registry->enabled_extensions(), system, &extensions); | 243 AddExtensionInfo(registry->enabled_extensions(), system, &extensions); |
| 244 AddExtensionInfo(registry->disabled_extensions(), system, &extensions); | 244 AddExtensionInfo(registry->disabled_extensions(), system, &extensions); |
| 245 AddExtensionInfo(registry->terminated_extensions(), system, &extensions); | 245 AddExtensionInfo(registry->terminated_extensions(), system, &extensions); |
| 246 | 246 |
| 247 results_ = management::GetAll::Results::Create(extensions); | 247 results_ = management::GetAll::Results::Create(extensions); |
| 248 return true; | 248 return true; |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool ManagementGetFunction::RunImpl() { | 251 bool ManagementGetFunction::RunSync() { |
| 252 scoped_ptr<management::Get::Params> params( | 252 scoped_ptr<management::Get::Params> params( |
| 253 management::Get::Params::Create(*args_)); | 253 management::Get::Params::Create(*args_)); |
| 254 EXTENSION_FUNCTION_VALIDATE(params.get()); | 254 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 255 | 255 |
| 256 const Extension* extension = service()->GetExtensionById(params->id, true); | 256 const Extension* extension = service()->GetExtensionById(params->id, true); |
| 257 if (!extension) { | 257 if (!extension) { |
| 258 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, | 258 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, |
| 259 params->id); | 259 params->id); |
| 260 return false; | 260 return false; |
| 261 } | 261 } |
| 262 | 262 |
| 263 scoped_ptr<management::ExtensionInfo> info = | 263 scoped_ptr<management::ExtensionInfo> info = |
| 264 CreateExtensionInfo(*extension, ExtensionSystem::Get(GetProfile())); | 264 CreateExtensionInfo(*extension, ExtensionSystem::Get(GetProfile())); |
| 265 results_ = management::Get::Results::Create(*info); | 265 results_ = management::Get::Results::Create(*info); |
| 266 | 266 |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| 269 | 269 |
| 270 bool ManagementGetPermissionWarningsByIdFunction::RunImpl() { | 270 bool ManagementGetPermissionWarningsByIdFunction::RunSync() { |
| 271 scoped_ptr<management::GetPermissionWarningsById::Params> params( | 271 scoped_ptr<management::GetPermissionWarningsById::Params> params( |
| 272 management::GetPermissionWarningsById::Params::Create(*args_)); | 272 management::GetPermissionWarningsById::Params::Create(*args_)); |
| 273 EXTENSION_FUNCTION_VALIDATE(params.get()); | 273 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 274 | 274 |
| 275 const Extension* extension = service()->GetExtensionById(params->id, true); | 275 const Extension* extension = service()->GetExtensionById(params->id, true); |
| 276 if (!extension) { | 276 if (!extension) { |
| 277 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, | 277 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, |
| 278 params->id); | 278 params->id); |
| 279 return false; | 279 return false; |
| 280 } | 280 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 412 |
| 413 void ManagementGetPermissionWarningsByManifestFunction::OnParseFailure( | 413 void ManagementGetPermissionWarningsByManifestFunction::OnParseFailure( |
| 414 const std::string& error) { | 414 const std::string& error) { |
| 415 error_ = error; | 415 error_ = error; |
| 416 SendResponse(false); | 416 SendResponse(false); |
| 417 | 417 |
| 418 // Matched with AddRef() in RunImpl(). | 418 // Matched with AddRef() in RunImpl(). |
| 419 Release(); | 419 Release(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 bool ManagementLaunchAppFunction::RunImpl() { | 422 bool ManagementLaunchAppFunction::RunSync() { |
| 423 scoped_ptr<management::LaunchApp::Params> params( | 423 scoped_ptr<management::LaunchApp::Params> params( |
| 424 management::LaunchApp::Params::Create(*args_)); | 424 management::LaunchApp::Params::Create(*args_)); |
| 425 EXTENSION_FUNCTION_VALIDATE(params.get()); | 425 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 426 const Extension* extension = service()->GetExtensionById(params->id, true); | 426 const Extension* extension = service()->GetExtensionById(params->id, true); |
| 427 if (!extension) { | 427 if (!extension) { |
| 428 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, | 428 error_ = ErrorUtils::FormatErrorMessage(keys::kNoExtensionError, |
| 429 params->id); | 429 params->id); |
| 430 return false; | 430 return false; |
| 431 } | 431 } |
| 432 if (!extension->is_app()) { | 432 if (!extension->is_app()) { |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 return g_factory.Pointer(); | 740 return g_factory.Pointer(); |
| 741 } | 741 } |
| 742 | 742 |
| 743 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { | 743 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 744 management_event_router_.reset( | 744 management_event_router_.reset( |
| 745 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); | 745 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_))); |
| 746 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 746 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 747 } | 747 } |
| 748 | 748 |
| 749 } // namespace extensions | 749 } // namespace extensions |
| OLD | NEW |