| 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/execute_code_in_tab_function.h" | 5 #include "chrome/browser/extensions/execute_code_in_tab_function.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/extensions/extension_tabs_module.h" | 9 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 10 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 10 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 TabContents* contents = NULL; | 117 TabContents* contents = NULL; |
| 118 Browser* browser = NULL; | 118 Browser* browser = NULL; |
| 119 if (!ExtensionTabUtil::GetTabById(execute_tab_id_, profile(), &browser, NULL, | 119 if (!ExtensionTabUtil::GetTabById(execute_tab_id_, profile(), &browser, NULL, |
| 120 &contents, NULL) && contents && browser) { | 120 &contents, NULL) && contents && browser) { |
| 121 SendResponse(false); | 121 SendResponse(false); |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool is_js_code = true; | 125 bool is_js_code = true; |
| 126 std::string function_name = name(); | 126 std::string function_name = name(); |
| 127 if (function_name == keys::kInsertCSSFunction) { | 127 if (function_name == TabsInsertCSSFunction::function_name()) { |
| 128 is_js_code = false; | 128 is_js_code = false; |
| 129 } else if (function_name != keys::kExecuteScriptFunction) { | 129 } else if (function_name != TabsExecuteScriptFunction::function_name()) { |
| 130 DCHECK(false); | 130 DCHECK(false); |
| 131 } | 131 } |
| 132 registrar_.Add(this, NotificationType::TAB_CODE_EXECUTED, | 132 registrar_.Add(this, NotificationType::TAB_CODE_EXECUTED, |
| 133 NotificationService::AllSources()); | 133 NotificationService::AllSources()); |
| 134 AddRef(); // balanced in Observe() | 134 AddRef(); // balanced in Observe() |
| 135 contents->ExecuteCode(request_id(), extension_id(), is_js_code, | 135 contents->ExecuteCode(request_id(), extension_id(), is_js_code, |
| 136 code_string); | 136 code_string); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void ExecuteCodeInTabFunction::Observe(NotificationType type, | 139 void ExecuteCodeInTabFunction::Observe(NotificationType type, |
| 140 const NotificationSource& source, | 140 const NotificationSource& source, |
| 141 const NotificationDetails& details) { | 141 const NotificationDetails& details) { |
| 142 std::pair<int, bool>* result_details = | 142 std::pair<int, bool>* result_details = |
| 143 Details<std::pair<int, bool> >(details).ptr(); | 143 Details<std::pair<int, bool> >(details).ptr(); |
| 144 if (result_details->first == request_id()) { | 144 if (result_details->first == request_id()) { |
| 145 SendResponse(result_details->second); | 145 SendResponse(result_details->second); |
| 146 Release(); // balanced in Execute() | 146 Release(); // balanced in Execute() |
| 147 } | 147 } |
| 148 } | 148 } |
| OLD | NEW |