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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 web_contents = dispatcher()->delegate()->GetAssociatedWebContents(); | 343 web_contents = dispatcher()->delegate()->GetAssociatedWebContents(); |
344 | 344 |
345 return web_contents; | 345 return web_contents; |
346 } | 346 } |
347 | 347 |
348 void UIThreadExtensionFunction::SendResponse(bool success) { | 348 void UIThreadExtensionFunction::SendResponse(bool success) { |
349 if (delegate_) | 349 if (delegate_) |
350 delegate_->OnSendResponse(this, success, bad_message_); | 350 delegate_->OnSendResponse(this, success, bad_message_); |
351 else | 351 else |
352 SendResponseImpl(success); | 352 SendResponseImpl(success); |
353 | |
354 if (!transferred_blob_uuids_.empty()) { | |
355 DCHECK(!delegate_) << "Blob transfer not supported with test delegate."; | |
356 GetIPCSender()->Send(new ExtensionMsg_TransferBlobs( | |
357 GetRoutingID(), transferred_blob_uuids_)); | |
michaeln
2014/05/23 00:12:34
What's the purpose if the routeid here?
tommycli
2014/05/23 16:27:44
Previously needed it due to it being a WebContents
| |
358 } | |
359 } | |
360 | |
361 void UIThreadExtensionFunction::SetTransferredBlobUUIDs( | |
362 const std::vector<std::string>& blob_uuids) { | |
363 DCHECK(transferred_blob_uuids_.empty()); // Should only be called once. | |
364 transferred_blob_uuids_ = blob_uuids; | |
353 } | 365 } |
354 | 366 |
355 void UIThreadExtensionFunction::WriteToConsole( | 367 void UIThreadExtensionFunction::WriteToConsole( |
356 content::ConsoleMessageLevel level, | 368 content::ConsoleMessageLevel level, |
357 const std::string& message) { | 369 const std::string& message) { |
358 if (render_view_host_) { | 370 GetIPCSender()->Send(new ExtensionMsg_AddMessageToConsole( |
359 render_view_host_->Send(new ExtensionMsg_AddMessageToConsole( | 371 GetRoutingID(), level, message)); |
360 render_view_host_->GetRoutingID(), level, message)); | 372 } |
361 } else { | 373 |
362 render_frame_host_->Send(new ExtensionMsg_AddMessageToConsole( | 374 IPC::Sender* UIThreadExtensionFunction::GetIPCSender() { |
363 render_frame_host_->GetRoutingID(), level, message)); | 375 if (render_view_host_) |
364 } | 376 return render_view_host_; |
377 else | |
378 return render_frame_host_; | |
379 } | |
380 | |
381 int UIThreadExtensionFunction::GetRoutingID() { | |
382 if (render_view_host_) | |
383 return render_view_host_->GetRoutingID(); | |
384 else | |
385 return render_frame_host_->GetRoutingID(); | |
365 } | 386 } |
366 | 387 |
367 IOThreadExtensionFunction::IOThreadExtensionFunction() | 388 IOThreadExtensionFunction::IOThreadExtensionFunction() |
368 : routing_id_(MSG_ROUTING_NONE) { | 389 : routing_id_(MSG_ROUTING_NONE) { |
369 } | 390 } |
370 | 391 |
371 IOThreadExtensionFunction::~IOThreadExtensionFunction() { | 392 IOThreadExtensionFunction::~IOThreadExtensionFunction() { |
372 } | 393 } |
373 | 394 |
374 IOThreadExtensionFunction* | 395 IOThreadExtensionFunction* |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { | 446 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { |
426 return RespondNow(RunSync() ? MultipleArguments(results_.get()) | 447 return RespondNow(RunSync() ? MultipleArguments(results_.get()) |
427 : Error(error_)); | 448 : Error(error_)); |
428 } | 449 } |
429 | 450 |
430 // static | 451 // static |
431 bool SyncIOThreadExtensionFunction::ValidationFailure( | 452 bool SyncIOThreadExtensionFunction::ValidationFailure( |
432 SyncIOThreadExtensionFunction* function) { | 453 SyncIOThreadExtensionFunction* function) { |
433 return false; | 454 return false; |
434 } | 455 } |
OLD | NEW |