| 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 "extensions/browser/extension_function_dispatcher.h" | 5 #include "extensions/browser/extension_function_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // if function->Run() ended up closing the tab that owns us. | 403 // if function->Run() ended up closing the tab that owns us. |
| 404 | 404 |
| 405 // Check if extension was uninstalled by management.uninstall. | 405 // Check if extension was uninstalled by management.uninstall. |
| 406 if (!registry->enabled_extensions().GetByID(params.extension_id)) | 406 if (!registry->enabled_extensions().GetByID(params.extension_id)) |
| 407 return; | 407 return; |
| 408 | 408 |
| 409 // We only adjust the keepalive count for UIThreadExtensionFunction for | 409 // We only adjust the keepalive count for UIThreadExtensionFunction for |
| 410 // now, largely for simplicity's sake. This is OK because currently, only | 410 // now, largely for simplicity's sake. This is OK because currently, only |
| 411 // the webRequest API uses IOThreadExtensionFunction, and that API is not | 411 // the webRequest API uses IOThreadExtensionFunction, and that API is not |
| 412 // compatible with lazy background pages. | 412 // compatible with lazy background pages. |
| 413 extension_system->process_manager()->IncrementLazyKeepaliveCount(extension); | 413 ProcessManager::Get(browser_context_)->IncrementLazyKeepaliveCount(extension); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void ExtensionFunctionDispatcher::OnExtensionFunctionCompleted( | 416 void ExtensionFunctionDispatcher::OnExtensionFunctionCompleted( |
| 417 const Extension* extension) { | 417 const Extension* extension) { |
| 418 if (extension) { | 418 if (extension) { |
| 419 ExtensionSystem::Get(browser_context_) | 419 ProcessManager::Get(browser_context_) |
| 420 ->process_manager() | |
| 421 ->DecrementLazyKeepaliveCount(extension); | 420 ->DecrementLazyKeepaliveCount(extension); |
| 422 } | 421 } |
| 423 } | 422 } |
| 424 | 423 |
| 425 // static | 424 // static |
| 426 bool ExtensionFunctionDispatcher::CheckPermissions( | 425 bool ExtensionFunctionDispatcher::CheckPermissions( |
| 427 ExtensionFunction* function, | 426 ExtensionFunction* function, |
| 428 const ExtensionHostMsg_Request_Params& params, | 427 const ExtensionHostMsg_Request_Params& params, |
| 429 const ExtensionFunction::ResponseCallback& callback) { | 428 const ExtensionFunction::ResponseCallback& callback) { |
| 430 if (!function->HasPermission()) { | 429 if (!function->HasPermission()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 468 |
| 470 // static | 469 // static |
| 471 void ExtensionFunctionDispatcher::SendAccessDenied( | 470 void ExtensionFunctionDispatcher::SendAccessDenied( |
| 472 const ExtensionFunction::ResponseCallback& callback) { | 471 const ExtensionFunction::ResponseCallback& callback) { |
| 473 base::ListValue empty_list; | 472 base::ListValue empty_list; |
| 474 callback.Run(ExtensionFunction::FAILED, empty_list, | 473 callback.Run(ExtensionFunction::FAILED, empty_list, |
| 475 "Access to extension API denied."); | 474 "Access to extension API denied."); |
| 476 } | 475 } |
| 477 | 476 |
| 478 } // namespace extensions | 477 } // namespace extensions |
| OLD | NEW |