| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_dispatcher.h" | 5 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/json_reader.h" | 7 #include "base/json_reader.h" |
| 8 #include "base/json_writer.h" | 8 #include "base/json_writer.h" |
| 9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 FactoryRegistry* FactoryRegistry::instance() { | 42 FactoryRegistry* FactoryRegistry::instance() { |
| 43 return Singleton<FactoryRegistry>::get(); | 43 return Singleton<FactoryRegistry>::get(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 FactoryRegistry::FactoryRegistry() { | 46 FactoryRegistry::FactoryRegistry() { |
| 47 // Register all functions here. | 47 // Register all functions here. |
| 48 factories_["GetTabsForWindow"] = | 48 factories_["GetTabsForWindow"] = |
| 49 &NewExtensionFunction<GetTabsForWindowFunction>; | 49 &NewExtensionFunction<GetTabsForWindowFunction>; |
| 50 factories_["GetTab"] = &NewExtensionFunction<GetTabFunction>; |
| 50 factories_["CreateTab"] = &NewExtensionFunction<CreateTabFunction>; | 51 factories_["CreateTab"] = &NewExtensionFunction<CreateTabFunction>; |
| 52 factories_["UpdateTab"] = &NewExtensionFunction<UpdateTabFunction>; |
| 53 factories_["RemoveTab"] = &NewExtensionFunction<RemoveTabFunction>; |
| 51 } | 54 } |
| 52 | 55 |
| 53 void FactoryRegistry::GetAllNames( | 56 void FactoryRegistry::GetAllNames( |
| 54 std::vector<std::string>* names) { | 57 std::vector<std::string>* names) { |
| 55 for (FactoryMap::iterator iter = factories_.begin(); iter != factories_.end(); | 58 for (FactoryMap::iterator iter = factories_.begin(); iter != factories_.end(); |
| 56 ++iter) { | 59 ++iter) { |
| 57 names->push_back(iter->first); | 60 names->push_back(iter->first); |
| 58 } | 61 } |
| 59 } | 62 } |
| 60 | 63 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 109 |
| 107 void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function) { | 110 void ExtensionFunctionDispatcher::SendResponse(ExtensionFunction* function) { |
| 108 std::string json; | 111 std::string json; |
| 109 | 112 |
| 110 // Some functions might not need to return any results. | 113 // Some functions might not need to return any results. |
| 111 if (function->result()) | 114 if (function->result()) |
| 112 JSONWriter::Write(function->result(), false, &json); | 115 JSONWriter::Write(function->result(), false, &json); |
| 113 | 116 |
| 114 render_view_host_->SendExtensionResponse(function->callback_id(), json); | 117 render_view_host_->SendExtensionResponse(function->callback_id(), json); |
| 115 } | 118 } |
| OLD | NEW |