Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 593503003: Support error handling for Surface readbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary headers. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (!attached()) 281 if (!attached())
282 return NULL; 282 return NULL;
283 return embedder_web_contents_->GetRenderWidgetHostView(); 283 return embedder_web_contents_->GetRenderWidgetHostView();
284 } 284 }
285 285
286 void BrowserPluginGuest::UpdateVisibility() { 286 void BrowserPluginGuest::UpdateVisibility() {
287 OnSetVisibility(browser_plugin_instance_id(), visible()); 287 OnSetVisibility(browser_plugin_instance_id(), visible());
288 } 288 }
289 289
290 void BrowserPluginGuest::CopyFromCompositingSurface( 290 void BrowserPluginGuest::CopyFromCompositingSurface(
291 gfx::Rect src_subrect, 291 gfx::Rect src_subrect,
292 gfx::Size dst_size, 292 gfx::Size dst_size,
293 const base::Callback<void(bool, const SkBitmap&)>& callback) { 293 CopyFromCompositingSurfaceCallback& callback) {
294 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback)); 294 copy_request_callbacks_.insert(std::make_pair(++copy_request_id_, callback));
295 SendMessageToEmbedder( 295 SendMessageToEmbedder(
296 new BrowserPluginMsg_CopyFromCompositingSurface( 296 new BrowserPluginMsg_CopyFromCompositingSurface(
297 browser_plugin_instance_id(), 297 browser_plugin_instance_id(),
298 copy_request_id_, 298 copy_request_id_,
299 src_subrect, 299 src_subrect,
300 dst_size)); 300 dst_size));
301 } 301 }
302 302
303 BrowserPluginGuestManager* 303 BrowserPluginGuestManager*
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 mouse_locked_ = false; 727 mouse_locked_ = false;
728 } 728 }
729 729
730 void BrowserPluginGuest::OnCopyFromCompositingSurfaceAck( 730 void BrowserPluginGuest::OnCopyFromCompositingSurfaceAck(
731 int browser_plugin_instance_id, 731 int browser_plugin_instance_id,
732 int request_id, 732 int request_id,
733 const SkBitmap& bitmap) { 733 const SkBitmap& bitmap) {
734 CHECK(copy_request_callbacks_.count(request_id)); 734 CHECK(copy_request_callbacks_.count(request_id));
735 if (!copy_request_callbacks_.count(request_id)) 735 if (!copy_request_callbacks_.count(request_id))
736 return; 736 return;
737 const CopyRequestCallback& callback = copy_request_callbacks_[request_id]; 737 const CopyFromCompositingSurfaceCallback& callback =
738 callback.Run(!bitmap.empty() && !bitmap.isNull(), bitmap); 738 copy_request_callbacks_[request_id];
739 bool success = !bitmap.empty() && !bitmap.isNull();
740 callback.Run(success,
741 bitmap,
742 success ? content::READBACK_SUCCESS : content::READBACK_FAILED);
739 copy_request_callbacks_.erase(request_id); 743 copy_request_callbacks_.erase(request_id);
740 } 744 }
741 745
742 void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id, 746 void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id,
743 const gfx::Rect& view_rect) { 747 const gfx::Rect& view_rect) {
744 // The plugin has moved within the embedder without resizing or the 748 // The plugin has moved within the embedder without resizing or the
745 // embedder/container's view rect changing. 749 // embedder/container's view rect changing.
746 guest_window_rect_ = view_rect; 750 guest_window_rect_ = view_rect;
747 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 751 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
748 GetWebContents()->GetRenderViewHost()); 752 GetWebContents()->GetRenderViewHost());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 void BrowserPluginGuest::OnImeCompositionRangeChanged( 808 void BrowserPluginGuest::OnImeCompositionRangeChanged(
805 const gfx::Range& range, 809 const gfx::Range& range,
806 const std::vector<gfx::Rect>& character_bounds) { 810 const std::vector<gfx::Rect>& character_bounds) {
807 static_cast<RenderWidgetHostViewBase*>( 811 static_cast<RenderWidgetHostViewBase*>(
808 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( 812 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged(
809 range, character_bounds); 813 range, character_bounds);
810 } 814 }
811 #endif 815 #endif
812 816
813 } // namespace content 817 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698