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