| 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/extension_function_registry.h" | 5 #include "chrome/browser/extensions/extension_function_registry.h" | 
| 6 | 6 | 
| 7 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 7 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 
| 8 #include "chrome/browser/bookmarks/bookmark_extension_api.h" | 8 #include "chrome/browser/bookmarks/bookmark_extension_api.h" | 
| 9 #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" | 9 #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" | 
| 10 #include "chrome/browser/download/download_extension_api.h" | 10 #include "chrome/browser/download/download_extension_api.h" | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 78 } | 78 } | 
| 79 | 79 | 
| 80 ExtensionFunctionRegistry::ExtensionFunctionRegistry() { | 80 ExtensionFunctionRegistry::ExtensionFunctionRegistry() { | 
| 81   ResetFunctions(); | 81   ResetFunctions(); | 
| 82 } | 82 } | 
| 83 | 83 | 
| 84 ExtensionFunctionRegistry::~ExtensionFunctionRegistry() { | 84 ExtensionFunctionRegistry::~ExtensionFunctionRegistry() { | 
| 85 } | 85 } | 
| 86 | 86 | 
| 87 void ExtensionFunctionRegistry::ResetFunctions() { | 87 void ExtensionFunctionRegistry::ResetFunctions() { | 
|  | 88 #if defined(ENABLE_EXTENSIONS) | 
|  | 89 | 
| 88   // Register all functions here. | 90   // Register all functions here. | 
| 89 | 91 | 
| 90   // Alarms | 92   // Alarms | 
| 91   RegisterFunction<extensions::AlarmsCreateFunction>(); | 93   RegisterFunction<extensions::AlarmsCreateFunction>(); | 
| 92   RegisterFunction<extensions::AlarmsGetFunction>(); | 94   RegisterFunction<extensions::AlarmsGetFunction>(); | 
| 93   RegisterFunction<extensions::AlarmsGetAllFunction>(); | 95   RegisterFunction<extensions::AlarmsGetAllFunction>(); | 
| 94   RegisterFunction<extensions::AlarmsClearFunction>(); | 96   RegisterFunction<extensions::AlarmsClearFunction>(); | 
| 95   RegisterFunction<extensions::AlarmsClearAllFunction>(); | 97   RegisterFunction<extensions::AlarmsClearAllFunction>(); | 
| 96 | 98 | 
| 97   // Windows | 99   // Windows | 
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 504   RegisterFunction<UpdateOffscreenTabFunction>(); | 506   RegisterFunction<UpdateOffscreenTabFunction>(); | 
| 505 | 507 | 
| 506   // Identity | 508   // Identity | 
| 507   RegisterFunction<extensions::GetAuthTokenFunction>(); | 509   RegisterFunction<extensions::GetAuthTokenFunction>(); | 
| 508 | 510 | 
| 509   // Runtime | 511   // Runtime | 
| 510   RegisterFunction<extensions::RuntimeGetBackgroundPageFunction>(); | 512   RegisterFunction<extensions::RuntimeGetBackgroundPageFunction>(); | 
| 511 | 513 | 
| 512   // Generated APIs | 514   // Generated APIs | 
| 513   extensions::api::GeneratedFunctionRegistry::RegisterAll(this); | 515   extensions::api::GeneratedFunctionRegistry::RegisterAll(this); | 
|  | 516 #endif  // defined(ENABLE_EXTENSIONS) | 
| 514 } | 517 } | 
| 515 | 518 | 
| 516 void ExtensionFunctionRegistry::GetAllNames(std::vector<std::string>* names) { | 519 void ExtensionFunctionRegistry::GetAllNames(std::vector<std::string>* names) { | 
| 517   for (FactoryMap::iterator iter = factories_.begin(); | 520   for (FactoryMap::iterator iter = factories_.begin(); | 
| 518        iter != factories_.end(); ++iter) { | 521        iter != factories_.end(); ++iter) { | 
| 519     names->push_back(iter->first); | 522     names->push_back(iter->first); | 
| 520   } | 523   } | 
| 521 } | 524 } | 
| 522 | 525 | 
| 523 bool ExtensionFunctionRegistry::OverrideFunction( | 526 bool ExtensionFunctionRegistry::OverrideFunction( | 
| 524     const std::string& name, | 527     const std::string& name, | 
| 525     ExtensionFunctionFactory factory) { | 528     ExtensionFunctionFactory factory) { | 
| 526   FactoryMap::iterator iter = factories_.find(name); | 529   FactoryMap::iterator iter = factories_.find(name); | 
| 527   if (iter == factories_.end()) { | 530   if (iter == factories_.end()) { | 
| 528     return false; | 531     return false; | 
| 529   } else { | 532   } else { | 
| 530     iter->second = factory; | 533     iter->second = factory; | 
| 531     return true; | 534     return true; | 
| 532   } | 535   } | 
| 533 } | 536 } | 
| 534 | 537 | 
| 535 ExtensionFunction* ExtensionFunctionRegistry::NewFunction( | 538 ExtensionFunction* ExtensionFunctionRegistry::NewFunction( | 
| 536     const std::string& name) { | 539     const std::string& name) { | 
| 537   FactoryMap::iterator iter = factories_.find(name); | 540   FactoryMap::iterator iter = factories_.find(name); | 
| 538   DCHECK(iter != factories_.end()); | 541   DCHECK(iter != factories_.end()); | 
| 539   ExtensionFunction* function = iter->second(); | 542   ExtensionFunction* function = iter->second(); | 
| 540   function->set_name(name); | 543   function->set_name(name); | 
| 541   return function; | 544   return function; | 
| 542 } | 545 } | 
| OLD | NEW | 
|---|