| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/extension_function.h" | 5 #include "extensions/browser/extension_function.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/public/browser/notification_source.h" | 8 #include "content/public/browser/notification_source.h" |
| 9 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 web_contents = dispatcher()->delegate()->GetAssociatedWebContents(); | 353 web_contents = dispatcher()->delegate()->GetAssociatedWebContents(); |
| 354 | 354 |
| 355 return web_contents; | 355 return web_contents; |
| 356 } | 356 } |
| 357 | 357 |
| 358 void UIThreadExtensionFunction::SendResponse(bool success) { | 358 void UIThreadExtensionFunction::SendResponse(bool success) { |
| 359 if (delegate_) | 359 if (delegate_) |
| 360 delegate_->OnSendResponse(this, success, bad_message_); | 360 delegate_->OnSendResponse(this, success, bad_message_); |
| 361 else | 361 else |
| 362 SendResponseImpl(success); | 362 SendResponseImpl(success); |
| 363 |
| 364 if (!transferred_blob_uuids_.empty()) { |
| 365 DCHECK(!delegate_) << "Blob transfer not supported with test delegate."; |
| 366 GetIPCSender()->Send( |
| 367 new ExtensionMsg_TransferBlobs(transferred_blob_uuids_)); |
| 368 } |
| 369 } |
| 370 |
| 371 void UIThreadExtensionFunction::SetTransferredBlobUUIDs( |
| 372 const std::vector<std::string>& blob_uuids) { |
| 373 DCHECK(transferred_blob_uuids_.empty()); // Should only be called once. |
| 374 transferred_blob_uuids_ = blob_uuids; |
| 363 } | 375 } |
| 364 | 376 |
| 365 void UIThreadExtensionFunction::WriteToConsole( | 377 void UIThreadExtensionFunction::WriteToConsole( |
| 366 content::ConsoleMessageLevel level, | 378 content::ConsoleMessageLevel level, |
| 367 const std::string& message) { | 379 const std::string& message) { |
| 368 if (render_view_host_) { | 380 GetIPCSender()->Send( |
| 369 render_view_host_->Send(new ExtensionMsg_AddMessageToConsole( | 381 new ExtensionMsg_AddMessageToConsole(GetRoutingID(), level, message)); |
| 370 render_view_host_->GetRoutingID(), level, message)); | 382 } |
| 371 } else { | 383 |
| 372 render_frame_host_->Send(new ExtensionMsg_AddMessageToConsole( | 384 IPC::Sender* UIThreadExtensionFunction::GetIPCSender() { |
| 373 render_frame_host_->GetRoutingID(), level, message)); | 385 if (render_view_host_) |
| 374 } | 386 return render_view_host_; |
| 387 else |
| 388 return render_frame_host_; |
| 389 } |
| 390 |
| 391 int UIThreadExtensionFunction::GetRoutingID() { |
| 392 if (render_view_host_) |
| 393 return render_view_host_->GetRoutingID(); |
| 394 else |
| 395 return render_frame_host_->GetRoutingID(); |
| 375 } | 396 } |
| 376 | 397 |
| 377 IOThreadExtensionFunction::IOThreadExtensionFunction() | 398 IOThreadExtensionFunction::IOThreadExtensionFunction() |
| 378 : routing_id_(MSG_ROUTING_NONE) { | 399 : routing_id_(MSG_ROUTING_NONE) { |
| 379 } | 400 } |
| 380 | 401 |
| 381 IOThreadExtensionFunction::~IOThreadExtensionFunction() { | 402 IOThreadExtensionFunction::~IOThreadExtensionFunction() { |
| 382 } | 403 } |
| 383 | 404 |
| 384 IOThreadExtensionFunction* | 405 IOThreadExtensionFunction* |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 454 |
| 434 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { | 455 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { |
| 435 return RespondNow(RunSync() ? ArgumentList(results_.Pass()) : Error(error_)); | 456 return RespondNow(RunSync() ? ArgumentList(results_.Pass()) : Error(error_)); |
| 436 } | 457 } |
| 437 | 458 |
| 438 // static | 459 // static |
| 439 bool SyncIOThreadExtensionFunction::ValidationFailure( | 460 bool SyncIOThreadExtensionFunction::ValidationFailure( |
| 440 SyncIOThreadExtensionFunction* function) { | 461 SyncIOThreadExtensionFunction* function) { |
| 441 return false; | 462 return false; |
| 442 } | 463 } |
| OLD | NEW |