| 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/execute_code_in_tab_function.h" | 5 #include "chrome/browser/extensions/execute_code_in_tab_function.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 Observe(contents->web_contents()); | 231 Observe(contents->web_contents()); |
| 232 AddRef(); // balanced in OnExecuteCodeFinished() | 232 AddRef(); // balanced in OnExecuteCodeFinished() |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool ExecuteCodeInTabFunction::OnMessageReceived(const IPC::Message& message) { | 236 bool ExecuteCodeInTabFunction::OnMessageReceived(const IPC::Message& message) { |
| 237 if (message.type() != ExtensionHostMsg_ExecuteCodeFinished::ID) | 237 if (message.type() != ExtensionHostMsg_ExecuteCodeFinished::ID) |
| 238 return false; | 238 return false; |
| 239 | 239 |
| 240 int message_request_id; | 240 int message_request_id; |
| 241 void* iter = NULL; | 241 PickleIterator iter(message); |
| 242 if (!message.ReadInt(&iter, &message_request_id)) { | 242 if (!message.ReadInt(&iter, &message_request_id)) { |
| 243 NOTREACHED() << "malformed extension message"; | 243 NOTREACHED() << "malformed extension message"; |
| 244 return true; | 244 return true; |
| 245 } | 245 } |
| 246 | 246 |
| 247 if (message_request_id != request_id()) | 247 if (message_request_id != request_id()) |
| 248 return false; | 248 return false; |
| 249 | 249 |
| 250 IPC_BEGIN_MESSAGE_MAP(ExecuteCodeInTabFunction, message) | 250 IPC_BEGIN_MESSAGE_MAP(ExecuteCodeInTabFunction, message) |
| 251 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ExecuteCodeFinished, | 251 IPC_MESSAGE_HANDLER(ExtensionHostMsg_ExecuteCodeFinished, |
| 252 OnExecuteCodeFinished) | 252 OnExecuteCodeFinished) |
| 253 IPC_END_MESSAGE_MAP() | 253 IPC_END_MESSAGE_MAP() |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 void ExecuteCodeInTabFunction::OnExecuteCodeFinished(int request_id, | 257 void ExecuteCodeInTabFunction::OnExecuteCodeFinished(int request_id, |
| 258 bool success, | 258 bool success, |
| 259 const std::string& error) { | 259 const std::string& error) { |
| 260 if (!error.empty()) { | 260 if (!error.empty()) { |
| 261 CHECK(!success); | 261 CHECK(!success); |
| 262 error_ = error; | 262 error_ = error; |
| 263 } | 263 } |
| 264 | 264 |
| 265 SendResponse(success); | 265 SendResponse(success); |
| 266 | 266 |
| 267 Observe(NULL); | 267 Observe(NULL); |
| 268 Release(); // balanced in Execute() | 268 Release(); // balanced in Execute() |
| 269 } | 269 } |
| OLD | NEW |