diff options
Diffstat (limited to 'chrome/browser/renderer_host')
78 files changed, 859 insertions, 1467 deletions
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc index fdba6ea..7fb2e07 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_mac.cc +++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.cc @@ -14,7 +14,7 @@ AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( bool opaque) : manager_(manager), opaque_(opaque), - surface_(NULL), + surface_id_(0), width_(0), height_(0), texture_(0), @@ -25,29 +25,17 @@ AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( } AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { - ReleaseIOSurface(); -} - -void AcceleratedSurfaceContainerMac::ReleaseIOSurface() { - if (surface_) { - CFRelease(surface_); - surface_ = NULL; - } } void AcceleratedSurfaceContainerMac::SetSizeAndIOSurface( int32 width, int32 height, uint64 io_surface_identifier) { - ReleaseIOSurface(); - IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); - if (io_surface_support) { - surface_ = io_surface_support->IOSurfaceLookup( - static_cast<uint32>(io_surface_identifier)); - EnqueueTextureForDeletion(); - width_ = width; - height_ = height; - } + // Ignore |io_surface_identifier|: The surface hasn't been painted to and + // only contains garbage data. Update the surface in |set_was_painted_to()| + // instead. + width_ = width; + height_ = height; } void AcceleratedSurfaceContainerMac::SetSizeAndTransportDIB( @@ -85,7 +73,7 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { texture_pending_deletion_ = 0; } if (!texture_) { - if ((io_surface_support && !surface_) || + if ((io_surface_support && !surface_.get()) || (!io_surface_support && !transport_dib_.get())) return; glGenTextures(1, &texture_); @@ -112,18 +100,18 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { // When using an IOSurface, the texture does not need to be repeatedly // uploaded, just when we've been told we have to. if (io_surface_support && texture_needs_upload_) { - DCHECK(surface_); + DCHECK(surface_.get()); glBindTexture(target, texture_); // Don't think we need to identify a plane. GLuint plane = 0; io_surface_support->CGLTexImageIOSurface2D(context, target, GL_RGBA, - width_, - height_, + surface_width_, + surface_height_, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, - surface_, + surface_.get(), plane); texture_needs_upload_ = false; } @@ -146,6 +134,9 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { } if (texture_) { + int texture_width = io_surface_support ? surface_width_ : width_; + int texture_height = io_surface_support ? surface_height_ : height_; + // TODO(kbr): convert this to use only OpenGL ES 2.0 functionality. // TODO(kbr): may need to pay attention to cutout rects. @@ -154,6 +145,11 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { int clipWidth = clipRect_.width(); int clipHeight = clipRect_.height(); + if (clipX + clipWidth > texture_width) + clipWidth = texture_width - clipX; + if (clipY + clipHeight > texture_height) + clipHeight = texture_height - clipY; + if (opaque_) { // Pepper 3D's output is currently considered opaque even if the // program draws pixels with alpha less than 1. In order to have @@ -184,16 +180,16 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { glEnable(target); glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(clipX, height_ - clipY); + glTexCoord2f(clipX, texture_height - clipY); glVertex3f(0, 0, 0); - glTexCoord2f(clipX + clipWidth, height_ - clipY); + glTexCoord2f(clipX + clipWidth, texture_height - clipY); glVertex3f(clipWidth, 0, 0); - glTexCoord2f(clipX, height_ - clipY - clipHeight); + glTexCoord2f(clipX, texture_height - clipY - clipHeight); glVertex3f(0, clipHeight, 0); - glTexCoord2f(clipX + clipWidth, height_ - clipY - clipHeight); + glTexCoord2f(clipX + clipWidth, texture_height - clipY - clipHeight); glVertex3f(clipWidth, clipHeight, 0); glEnd(); @@ -201,6 +197,27 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) { } } +void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) { + if (surface_id && (!surface_ || surface_id != surface_id_)) { + // Keep the surface that was most recently painted to around. + if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) { + CFTypeRef surface = io_surface_support->IOSurfaceLookup( + static_cast<uint32>(surface_id)); + // Can fail if IOSurface with that ID was already released by the + // gpu process or the plugin process. We will get a |set_was_painted_to()| + // message with a new surface soon in that case. + if (surface) { + surface_.reset(surface); + surface_id_ = surface_id; + surface_width_ = io_surface_support->IOSurfaceGetWidth(surface_); + surface_height_ = io_surface_support->IOSurfaceGetHeight(surface_); + EnqueueTextureForDeletion(); + } + } + } + was_painted_to_ = true; +} + void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() { if (texture_) { DCHECK(texture_pending_deletion_ == 0); diff --git a/chrome/browser/renderer_host/accelerated_surface_container_mac.h b/chrome/browser/renderer_host/accelerated_surface_container_mac.h index b0b6051..0c343e4 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_mac.h +++ b/chrome/browser/renderer_host/accelerated_surface_container_mac.h @@ -31,6 +31,7 @@ #include "app/surface/transport_dib.h" #include "base/basictypes.h" +#include "base/mac/scoped_cftyperef.h" #include "base/scoped_ptr.h" #include "gfx/native_widget_types.h" #include "gfx/rect.h" @@ -75,8 +76,11 @@ class AcceleratedSurfaceContainerMac { // time the drawing context has changed. void ForceTextureReload() { texture_needs_upload_ = true; } - // Notifies the surface that it was painted to. - void set_was_painted_to() { was_painted_to_ = true; } + // Notifies the the container that its surface was painted to. + void set_was_painted_to(uint64 surface_id); + + // Notifies the container that its surface is invalid. + void set_surface_invalid() { was_painted_to_ = false; } // Returns if the surface should be shown. bool should_be_visible() const { return visible_ && was_painted_to_; } @@ -91,14 +95,22 @@ class AcceleratedSurfaceContainerMac { // plugin process back to the browser process for drawing. // This is held as a CFTypeRef because we can't refer to the // IOSurfaceRef type when building on 10.5. - CFTypeRef surface_; + base::mac::ScopedCFTypeRef<CFTypeRef> surface_; + + // The id of |surface_|, or 0 if |surface_| is NULL. + uint64 surface_id_; + + // The width and height of the io surface. During resizing, this is different + // from |width_| and |height_|. + int32 surface_width_; + int32 surface_height_; // The TransportDIB which is used in pre-10.6 systems where the IOSurface // API is not supported. This is a weak reference to the actual TransportDIB // whic is owned by the GPU process. scoped_ptr<TransportDIB> transport_dib_; - // The width and height of the surface. + // The width and height of the container. int32 width_; int32 height_; diff --git a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc index 8e8a17e..b123f76 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc +++ b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.cc @@ -53,6 +53,13 @@ bool AcceleratedSurfaceContainerManagerMac::IsRootContainer( root_container_handle_ == id; } +void AcceleratedSurfaceContainerManagerMac:: + set_gpu_rendering_active(bool active) { + if (gpu_rendering_active_ && !active) + SetRootSurfaceInvalid(); + gpu_rendering_active_ = active; +} + void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface( gfx::PluginWindowHandle id, int32 width, @@ -92,7 +99,10 @@ void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context, AutoLock lock(lock_); glColorMask(true, true, true, true); - glClearColor(0, 0, 0, 0); + // Should match the clear color of RenderWidgetHostViewMac. + glClearColor(255, 255, 255, 255); + // TODO(thakis): Clearing the whole color buffer is wasteful, since most of + // it is overwritten by the surface. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); @@ -124,12 +134,18 @@ void AcceleratedSurfaceContainerManagerMac::ForceTextureReload() { } void AcceleratedSurfaceContainerManagerMac::SetSurfaceWasPaintedTo( - gfx::PluginWindowHandle id) { + gfx::PluginWindowHandle id, uint64 surface_id) { AutoLock lock(lock_); AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); if (container) - container->set_was_painted_to(); + container->set_was_painted_to(surface_id); +} + +void AcceleratedSurfaceContainerManagerMac::SetRootSurfaceInvalid() { + AutoLock lock(lock_); + if (root_container_) + root_container_->set_surface_invalid(); } bool AcceleratedSurfaceContainerManagerMac::SurfaceShouldBeVisible( diff --git a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h index 0e38c11..a03a5c4 100644 --- a/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h +++ b/chrome/browser/renderer_host/accelerated_surface_container_manager_mac.h @@ -46,7 +46,7 @@ class AcceleratedSurfaceContainerManagerMac { } // Informs the manager if gpu rendering is active. - void set_gpu_rendering_active(bool active) { gpu_rendering_active_ = active; } + void set_gpu_rendering_active(bool active); // Sets the size and backing store of the plugin instance. There are two // versions: the IOSurface version is used on systems where the IOSurface @@ -74,7 +74,10 @@ class AcceleratedSurfaceContainerManagerMac { void ForceTextureReload(); // Notifies a surface that it has been painted to. - void SetSurfaceWasPaintedTo(gfx::PluginWindowHandle id); + void SetSurfaceWasPaintedTo(gfx::PluginWindowHandle id, uint64 surface_id); + + // Notifies the root container that its surface is invalid. + void SetRootSurfaceInvalid(); // Returns if a given surface should be shown. bool SurfaceShouldBeVisible(gfx::PluginWindowHandle id) const; diff --git a/chrome/browser/renderer_host/async_resource_handler.cc b/chrome/browser/renderer_host/async_resource_handler.cc index 92202fa..70dfc74 100644 --- a/chrome/browser/renderer_host/async_resource_handler.cc +++ b/chrome/browser/renderer_host/async_resource_handler.cc @@ -48,8 +48,7 @@ class SharedIOBuffer : public net::IOBuffer { buffer_size_(buffer_size) {} bool Init() { - if (shared_memory_.Create(std::string(), false, false, buffer_size_) && - shared_memory_.Map(buffer_size_)) { + if (shared_memory_.CreateAndMapAnonymous(buffer_size_)) { data_ = reinterpret_cast<char*>(shared_memory_.memory()); DCHECK(data_); ok_ = true; diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc index 0b594a0..4c83384 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.cc +++ b/chrome/browser/renderer_host/audio_renderer_host.cc @@ -67,6 +67,15 @@ static uint32 SelectHardwarePacketSize(AudioParameters params) { return params.channels * samples * params.bits_per_sample / 8; } +AudioRendererHost::AudioEntry::AudioEntry() + : render_view_id(0), + stream_id(0), + pending_buffer_request(false), + pending_close(false) { +} + +AudioRendererHost::AudioEntry::~AudioEntry() {} + /////////////////////////////////////////////////////////////////////////////// // AudioRendererHost implementations. AudioRendererHost::AudioRendererHost() @@ -216,7 +225,7 @@ void AudioRendererHost::DoCompleteCreation( SendMessage(new ViewMsg_NotifyLowLatencyAudioStreamCreated( entry->render_view_id, entry->stream_id, foreign_memory_handle, - foreign_socket_handle, entry->shared_memory.max_size())); + foreign_socket_handle, entry->shared_memory.created_size())); return; } @@ -224,7 +233,7 @@ void AudioRendererHost::DoCompleteCreation( // process. SendMessage(new ViewMsg_NotifyAudioStreamCreated( entry->render_view_id, entry->stream_id, foreign_memory_handle, - entry->shared_memory.max_size())); + entry->shared_memory.created_size())); } void AudioRendererHost::DoSendPlayingMessage( @@ -346,8 +355,7 @@ void AudioRendererHost::OnCreateStream( scoped_ptr<AudioEntry> entry(new AudioEntry()); // Create the shared memory and share with the renderer process. - if (!entry->shared_memory.Create("", false, false, hardware_packet_size) || - !entry->shared_memory.Map(entry->shared_memory.max_size())) { + if (!entry->shared_memory.CreateAndMapAnonymous(hardware_packet_size)) { // If creation of shared memory failed then send an error message. SendErrorMessage(msg.routing_id(), stream_id); return; @@ -471,7 +479,7 @@ void AudioRendererHost::OnNotifyPacketReady( } DCHECK(!entry->controller->LowLatencyMode()); - CHECK(packet_size <= entry->shared_memory.max_size()); + CHECK(packet_size <= entry->shared_memory.created_size()); if (!entry->pending_buffer_request) { NOTREACHED() << "Buffer received but no such pending request"; diff --git a/chrome/browser/renderer_host/audio_renderer_host.h b/chrome/browser/renderer_host/audio_renderer_host.h index 8ec3cd1..d2dfd59 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.h +++ b/chrome/browser/renderer_host/audio_renderer_host.h @@ -83,12 +83,8 @@ class AudioRendererHost : public base::RefCountedThreadSafe< typedef std::pair<int32, int> AudioEntryId; struct AudioEntry { - AudioEntry() - : render_view_id(0), - stream_id(0), - pending_buffer_request(false), - pending_close(false) { - } + AudioEntry(); + ~AudioEntry(); // The AudioOutputController that manages the audio stream. scoped_refptr<media::AudioOutputController> controller; diff --git a/chrome/browser/renderer_host/audio_sync_reader.cc b/chrome/browser/renderer_host/audio_sync_reader.cc index f664d19..ce989e5 100644 --- a/chrome/browser/renderer_host/audio_sync_reader.cc +++ b/chrome/browser/renderer_host/audio_sync_reader.cc @@ -20,9 +20,9 @@ void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { } uint32 AudioSyncReader::Read(void* data, uint32 size) { - int read_size = std::min(size, shared_memory_->max_size()); + uint32 read_size = std::min(size, shared_memory_->created_size()); memcpy(data, shared_memory_->memory(), read_size); - memset(shared_memory_->memory(), 0, shared_memory_->max_size()); + memset(shared_memory_->memory(), 0, shared_memory_->created_size()); return read_size; } diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h index 53d0288..57d5078 100644 --- a/chrome/browser/renderer_host/backing_store.h +++ b/chrome/browser/renderer_host/backing_store.h @@ -40,18 +40,11 @@ class BackingStore { // Paints the bitmap from the renderer onto the backing store. bitmap_rect // gives the location of bitmap, and copy_rects specifies the subregion(s) of // the backingstore to be painted from the bitmap. - // - // The value placed into |*painted_synchronously| indicates if the paint was - // completed synchronously and the TransportDIB can be freed. False means that - // the backing store may still be using the transport DIB and it will manage - // notifying the RenderWidgetHost that it's done with it via - // DonePaintingToBackingStore(). virtual void PaintToBackingStore( RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously) = 0; + const std::vector<gfx::Rect>& copy_rects) = 0; // Extracts the gives subset of the backing store and copies it to the given // PlatformCanvas. The PlatformCanvas should not be initialized. This function diff --git a/chrome/browser/renderer_host/backing_store_mac.h b/chrome/browser/renderer_host/backing_store_mac.h index 2c75400..9c4cc6d 100644 --- a/chrome/browser/renderer_host/backing_store_mac.h +++ b/chrome/browser/renderer_host/backing_store_mac.h @@ -28,8 +28,7 @@ class BackingStoreMac : public BackingStore { RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously); + const std::vector<gfx::Rect>& copy_rects); virtual bool CopyFromBackingStore(const gfx::Rect& rect, skia::PlatformCanvas* output); virtual void ScrollBackingStore(int dx, int dy, diff --git a/chrome/browser/renderer_host/backing_store_mac.mm b/chrome/browser/renderer_host/backing_store_mac.mm index bea378f..5754839 100644 --- a/chrome/browser/renderer_host/backing_store_mac.mm +++ b/chrome/browser/renderer_host/backing_store_mac.mm @@ -56,12 +56,7 @@ void BackingStoreMac::PaintToBackingStore( RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously) { - // Our paints are always synchronous and the caller can free the TransportDIB, - // even on failure. - *painted_synchronously = true; - + const std::vector<gfx::Rect>& copy_rects) { DCHECK_NE(static_cast<bool>(cg_layer()), static_cast<bool>(cg_bitmap())); TransportDIB* dib = process->GetTransportDIB(bitmap); diff --git a/chrome/browser/renderer_host/backing_store_manager.cc b/chrome/browser/renderer_host/backing_store_manager.cc index 4325f31..755a772 100644 --- a/chrome/browser/renderer_host/backing_store_manager.cc +++ b/chrome/browser/renderer_host/backing_store_manager.cc @@ -196,11 +196,7 @@ void BackingStoreManager::PrepareBackingStore( TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, - bool* needs_full_paint, - bool* painted_synchronously) { - // Default to declaring we're done using the transport DIB so it can be freed. - *painted_synchronously = true; - + bool* needs_full_paint) { BackingStore* backing_store = GetBackingStore(host, backing_store_size); if (!backing_store) { // We need to get Webkit to generate a new paint here, as we @@ -218,8 +214,7 @@ void BackingStoreManager::PrepareBackingStore( } backing_store->PaintToBackingStore(host->process(), bitmap, - bitmap_rect, copy_rects, - painted_synchronously); + bitmap_rect, copy_rects); } // static diff --git a/chrome/browser/renderer_host/backing_store_manager.h b/chrome/browser/renderer_host/backing_store_manager.h index 1ab78cc..3db86b0 100644 --- a/chrome/browser/renderer_host/backing_store_manager.h +++ b/chrome/browser/renderer_host/backing_store_manager.h @@ -43,19 +43,13 @@ class BackingStoreManager { // needs_full_paint // Set if we need to send out a request to paint the view // to the renderer. - // painted_synchronously - // Will be set by the function if the request was processed synchronously, - // and the bitmap is done being used. False means that the backing store - // will paint the bitmap at a later time and that the TransportDIB can't be - // freed (it will be the backing store's job to free it later). static void PrepareBackingStore( RenderWidgetHost* host, const gfx::Size& backing_store_size, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, - bool* needs_full_paint, - bool* painted_synchronously); + bool* needs_full_paint); // Returns a matching backing store for the host. // Returns NULL if we fail to find one. diff --git a/chrome/browser/renderer_host/backing_store_proxy.cc b/chrome/browser/renderer_host/backing_store_proxy.cc deleted file mode 100644 index 3d2fd8e..0000000 --- a/chrome/browser/renderer_host/backing_store_proxy.cc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/backing_store_proxy.h" - -#include "build/build_config.h" -#include "chrome/browser/gpu_process_host_ui_shim.h" -#include "chrome/browser/renderer_host/render_process_host.h" -#include "chrome/browser/renderer_host/render_widget_host.h" -#include "chrome/common/gpu_messages.h" -#include "chrome/common/render_messages.h" -#include "gfx/rect.h" - -#if defined(OS_WIN) -#include <windows.h> -#endif - -BackingStoreProxy::BackingStoreProxy(RenderWidgetHost* widget, - const gfx::Size& size, - GpuProcessHostUIShim* process_shim, - int32 routing_id) - : BackingStore(widget, size), - process_shim_(process_shim), - routing_id_(routing_id), - waiting_for_paint_ack_(false) { - process_shim_->AddRoute(routing_id_, this); -} - -BackingStoreProxy::~BackingStoreProxy() { - process_shim_->RemoveRoute(routing_id_); -} - -void BackingStoreProxy::PaintToBackingStore( - RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously) { - DCHECK(!waiting_for_paint_ack_); - - base::ProcessId process_id; -#if defined(OS_WIN) - process_id = ::GetProcessId(process->GetHandle()); -#elif defined(OS_POSIX) - process_id = process->GetHandle(); -#endif - - if (process_shim_->Send(new GpuMsg_PaintToBackingStore( - routing_id_, process_id, bitmap, bitmap_rect, copy_rects))) { - // Message sent successfully, so the caller can not destroy the - // TransportDIB. OnDonePaintingToBackingStore will free it later. - *painted_synchronously = false; - waiting_for_paint_ack_ = true; - } else { - // On error, we're done with the TransportDIB and the caller can free it. - *painted_synchronously = true; - } -} - -bool BackingStoreProxy::CopyFromBackingStore(const gfx::Rect& rect, - skia::PlatformCanvas* output) { - NOTIMPLEMENTED(); - return false; -} - -void BackingStoreProxy::ScrollBackingStore(int dx, int dy, - const gfx::Rect& clip_rect, - const gfx::Size& view_size) { - process_shim_->Send(new GpuMsg_ScrollBackingStore(routing_id_, dx, dy, - clip_rect, view_size)); -} - -void BackingStoreProxy::OnMessageReceived(const IPC::Message& msg) { - IPC_BEGIN_MESSAGE_MAP(BackingStoreProxy, msg) - IPC_MESSAGE_HANDLER(GpuHostMsg_PaintToBackingStore_ACK, - OnPaintToBackingStoreACK) - IPC_END_MESSAGE_MAP_EX() -} - -void BackingStoreProxy::OnChannelConnected(int32 peer_pid) { -} - -void BackingStoreProxy::OnChannelError() { - if (waiting_for_paint_ack_) { - // If the GPU process dies while painting, the renderer will be waiting for - // the paint ACK before painting any more. Since no ack is coming, we - // manually declare that we're done with the transport DIB here so it can - // continue. - OnPaintToBackingStoreACK(); - } - - // TODO(brettw): does this mean we aren't getting any more messages and we - // should delete outselves? -} - -void BackingStoreProxy::OnPaintToBackingStoreACK() { - DCHECK(waiting_for_paint_ack_); - render_widget_host()->DonePaintingToBackingStore(); - waiting_for_paint_ack_ = false; -} diff --git a/chrome/browser/renderer_host/backing_store_proxy.h b/chrome/browser/renderer_host/backing_store_proxy.h deleted file mode 100644 index 610f7ef..0000000 --- a/chrome/browser/renderer_host/backing_store_proxy.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_PROXY_H_ -#define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_PROXY_H_ -#pragma once - -#include "base/basictypes.h" -#include "chrome/browser/renderer_host/backing_store.h" -#include "ipc/ipc_channel.h" - -class GpuProcessHostUIShim; - -class BackingStoreProxy : public BackingStore, - public IPC::Channel::Listener { - public: - BackingStoreProxy(RenderWidgetHost* widget, const gfx::Size& size, - GpuProcessHostUIShim* process_shim, int32 routing_id); - virtual ~BackingStoreProxy(); - - // BackingStore implementation. - virtual void PaintToBackingStore(RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously); - virtual bool CopyFromBackingStore(const gfx::Rect& rect, - skia::PlatformCanvas* output); - virtual void ScrollBackingStore(int dx, int dy, - const gfx::Rect& clip_rect, - const gfx::Size& view_size); - - // IPC::Channel::Listener implementation. - virtual void OnMessageReceived(const IPC::Message& message); - virtual void OnChannelConnected(int32 peer_pid); - virtual void OnChannelError(); - - private: - // Message handlers. - void OnPaintToBackingStoreACK(); - - GpuProcessHostUIShim* process_shim_; - int32 routing_id_; - - // Set to true when we're waiting for the GPU process to do a paint and send - // back a "done" message. In this case, the renderer will be waiting for our - // message that we're done using the backing store. - bool waiting_for_paint_ack_; - - DISALLOW_COPY_AND_ASSIGN(BackingStoreProxy); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_PROXY_H_ diff --git a/chrome/browser/renderer_host/backing_store_win.cc b/chrome/browser/renderer_host/backing_store_win.cc index 94d9cbf..2013104 100644 --- a/chrome/browser/renderer_host/backing_store_win.cc +++ b/chrome/browser/renderer_host/backing_store_win.cc @@ -116,12 +116,7 @@ void BackingStoreWin::PaintToBackingStore( RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously) { - // Our paints are always synchronous and the TransportDIB can be freed when - // we're done (even on error). - *painted_synchronously = true; - + const std::vector<gfx::Rect>& copy_rects) { if (!backing_store_dib_) { backing_store_dib_ = CreateDIB(hdc_, size().width(), size().height(), color_depth_); diff --git a/chrome/browser/renderer_host/backing_store_win.h b/chrome/browser/renderer_host/backing_store_win.h index 221e0aa..ce4c419 100644 --- a/chrome/browser/renderer_host/backing_store_win.h +++ b/chrome/browser/renderer_host/backing_store_win.h @@ -26,8 +26,7 @@ class BackingStoreWin : public BackingStore { virtual void PaintToBackingStore(RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously); + const std::vector<gfx::Rect>& copy_rects); virtual bool CopyFromBackingStore(const gfx::Rect& rect, skia::PlatformCanvas* output); virtual void ScrollBackingStore(int dx, int dy, diff --git a/chrome/browser/renderer_host/backing_store_x.cc b/chrome/browser/renderer_host/backing_store_x.cc index a79a8fc..9fc7e5c 100644 --- a/chrome/browser/renderer_host/backing_store_x.cc +++ b/chrome/browser/renderer_host/backing_store_x.cc @@ -160,12 +160,7 @@ void BackingStoreX::PaintToBackingStore( RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously) { - // Our paints are always synchronous and the caller can free the TransportDIB - // when we're done, even on error. - *painted_synchronously = true; - + const std::vector<gfx::Rect>& copy_rects) { if (!display_) return; diff --git a/chrome/browser/renderer_host/backing_store_x.h b/chrome/browser/renderer_host/backing_store_x.h index 283c19f..e6a73a7 100644 --- a/chrome/browser/renderer_host/backing_store_x.h +++ b/chrome/browser/renderer_host/backing_store_x.h @@ -53,8 +53,7 @@ class BackingStoreX : public BackingStore { RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously); + const std::vector<gfx::Rect>& copy_rects); virtual bool CopyFromBackingStore(const gfx::Rect& rect, skia::PlatformCanvas* output); virtual void ScrollBackingStore(int dx, int dy, diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index b7af07f..af37c6b 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -47,6 +47,7 @@ #include "chrome/browser/renderer_host/resource_message_filter.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/spellcheck_host.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/visitedlink_master.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -258,7 +259,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) } BrowserRenderProcessHost::~BrowserRenderProcessHost() { - LOG_IF(INFO, g_log_bug53991) << "~BrowserRenderProcessHost: " << this; + VLOG_IF(1, g_log_bug53991) << "~BrowserRenderProcessHost: " << this; WebCacheManager::GetInstance()->Remove(id()); ChildProcessSecurityPolicy::GetInstance()->Remove(id()); @@ -296,14 +297,14 @@ bool BrowserRenderProcessHost::Init( // Construct the AudioRendererHost with the IO thread. audio_renderer_host_ = new AudioRendererHost(); - scoped_refptr<ResourceMessageFilter> resource_message_filter = + scoped_refptr<ResourceMessageFilter> resource_message_filter( new ResourceMessageFilter(g_browser_process->resource_dispatcher_host(), id(), audio_renderer_host_.get(), PluginService::GetInstance(), g_browser_process->print_job_manager(), profile(), - widget_helper_); + widget_helper_)); CommandLine::StringType renderer_prefix; #if defined(OS_POSIX) @@ -334,8 +335,8 @@ bool BrowserRenderProcessHost::Init( // be doing. channel_->set_sync_messages_with_no_timeout_allowed(false); - scoped_refptr<PepperFileMessageFilter> pepper_file_message_filter = - new PepperFileMessageFilter(id(), profile()); + scoped_refptr<PepperFileMessageFilter> pepper_file_message_filter( + new PepperFileMessageFilter(id(), profile())); channel_->AddFilter(pepper_file_message_filter); if (run_renderer_in_process()) { @@ -578,7 +579,6 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( switches::kInternalNaCl, switches::kInternalPepper, switches::kRegisterPepperPlugins, - switches::kDisableByteRangeSupport, switches::kDisableDatabases, switches::kDisableDesktopNotifications, switches::kDisableWebSockets, @@ -594,7 +594,6 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( switches::kEnableOpenMax, switches::kVideoThreads, switches::kEnableVideoFullscreen, - switches::kEnableVideoLayering, switches::kEnableVideoLogging, switches::kEnableTouch, // We propagate the Chrome Frame command line here as well in case the @@ -607,6 +606,9 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( switches::kDisableExperimentalWebGL, switches::kDisableGLSLTranslator, switches::kInProcessWebGL, + // This flag needs to be propagated to the renderer process for + // --in-process-webgl. + switches::kUseGL, switches::kDisableAcceleratedCompositing, #if defined(OS_MACOSX) // Allow this to be set when invoking the browser and relayed along. @@ -708,7 +710,7 @@ void BrowserRenderProcessHost::SendExtensionInfo() { return; ViewMsg_ExtensionsUpdated_Params params; for (size_t i = 0; i < service->extensions()->size(); ++i) { - Extension* extension = service->extensions()->at(i); + const Extension* extension = service->extensions()->at(i); ViewMsg_ExtensionRendererInfo info; info.id = extension->id(); info.web_extent = extension->web_extent(); @@ -869,6 +871,8 @@ void BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { OnExtensionRemoveListener) IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionCloseChannel, OnExtensionCloseChannel) + IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, + OnUserMetricsRecordAction) IPC_MESSAGE_HANDLER(ViewHostMsg_SpellChecker_RequestDictionary, OnSpellCheckerRequestDictionary) IPC_MESSAGE_UNHANDLED_ERROR() @@ -1089,6 +1093,11 @@ void BrowserRenderProcessHost::OnExtensionCloseChannel(int port_id) { } } +void BrowserRenderProcessHost::OnUserMetricsRecordAction( + const std::string& action) { + UserMetrics::RecordComputedAction(action, profile()); +} + void BrowserRenderProcessHost::OnSpellCheckerRequestDictionary() { if (profile()->GetSpellCheckHost()) { // The spellchecker initialization already started and finished; just send diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h index 639ba32..841b6ae 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.h +++ b/chrome/browser/renderer_host/browser_render_process_host.h @@ -113,6 +113,7 @@ class BrowserRenderProcessHost : public RenderProcessHost, void OnExtensionRemoveListener(const std::string& extension_id, const std::string& event_name); void OnExtensionCloseChannel(int port_id); + void OnUserMetricsRecordAction(const std::string& action); // Initialize support for visited links. Send the renderer process its initial // set of visited links. diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc index a19d3c3..0a141b0 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.cc +++ b/chrome/browser/renderer_host/buffered_resource_handler.cc @@ -149,6 +149,8 @@ bool BufferedResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { return real_handler_->OnReadCompleted(request_id, bytes_read); } +BufferedResourceHandler::~BufferedResourceHandler() {} + bool BufferedResourceHandler::DelayResponse() { std::string mime_type; request_->GetMimeType(&mime_type); @@ -172,7 +174,7 @@ bool BufferedResourceHandler::DelayResponse() { // is. That means we need to delay sending the ResponseStarted message // over the IPC channel. sniff_content_ = true; - LOG(INFO) << "To buffer: " << request_->url().spec(); + VLOG(1) << "To buffer: " << request_->url().spec(); return true; } diff --git a/chrome/browser/renderer_host/buffered_resource_handler.h b/chrome/browser/renderer_host/buffered_resource_handler.h index 26bd7f8..69e64c5 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.h +++ b/chrome/browser/renderer_host/buffered_resource_handler.h @@ -22,21 +22,21 @@ class BufferedResourceHandler : public ResourceHandler { URLRequest* request); // ResourceHandler implementation: - bool OnUploadProgress(int request_id, uint64 position, uint64 size); - bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, bool* defer); - bool OnResponseStarted(int request_id, ResourceResponse* response); - bool OnWillStart(int request_id, const GURL& url, bool* defer); - bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, - int min_size); - bool OnReadCompleted(int request_id, int* bytes_read); - bool OnResponseCompleted(int request_id, - const URLRequestStatus& status, - const std::string& security_info); - void OnRequestClosed(); + virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); + virtual bool OnRequestRedirected(int request_id, const GURL& new_url, + ResourceResponse* response, bool* defer); + virtual bool OnResponseStarted(int request_id, ResourceResponse* response); + virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); + virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, + int min_size); + virtual bool OnReadCompleted(int request_id, int* bytes_read); + virtual bool OnResponseCompleted(int request_id, + const URLRequestStatus& status, + const std::string& security_info); + virtual void OnRequestClosed(); private: - ~BufferedResourceHandler() {} + virtual ~BufferedResourceHandler(); // Returns true if we should delay OnResponseStarted forwarding. bool DelayResponse(); diff --git a/chrome/browser/renderer_host/cross_site_resource_handler.cc b/chrome/browser/renderer_host/cross_site_resource_handler.cc index 3198e76..ddab0e7 100644 --- a/chrome/browser/renderer_host/cross_site_resource_handler.cc +++ b/chrome/browser/renderer_host/cross_site_resource_handler.cc @@ -175,6 +175,8 @@ void CrossSiteResourceHandler::ResumeResponse() { } } +CrossSiteResourceHandler::~CrossSiteResourceHandler() {} + // Prepare to render the cross-site response in a new RenderViewHost, by // telling the old RenderViewHost to run its onunload handler. void CrossSiteResourceHandler::StartCrossSiteTransition( diff --git a/chrome/browser/renderer_host/cross_site_resource_handler.h b/chrome/browser/renderer_host/cross_site_resource_handler.h index aa731ca..33c1109 100644 --- a/chrome/browser/renderer_host/cross_site_resource_handler.h +++ b/chrome/browser/renderer_host/cross_site_resource_handler.h @@ -25,26 +25,26 @@ class CrossSiteResourceHandler : public ResourceHandler { ResourceDispatcherHost* resource_dispatcher_host); // ResourceHandler implementation: - bool OnUploadProgress(int request_id, uint64 position, uint64 size); - bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, bool* defer); - bool OnResponseStarted(int request_id, - ResourceResponse* response); - bool OnWillStart(int request_id, const GURL& url, bool* defer); - bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, - int min_size); - bool OnReadCompleted(int request_id, int* bytes_read); - bool OnResponseCompleted(int request_id, - const URLRequestStatus& status, - const std::string& security_info); - void OnRequestClosed(); + virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); + virtual bool OnRequestRedirected(int request_id, const GURL& new_url, + ResourceResponse* response, bool* defer); + virtual bool OnResponseStarted(int request_id, + ResourceResponse* response); + virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); + virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, + int min_size); + virtual bool OnReadCompleted(int request_id, int* bytes_read); + virtual bool OnResponseCompleted(int request_id, + const URLRequestStatus& status, + const std::string& security_info); + virtual void OnRequestClosed(); // We can now send the response to the new renderer, which will cause // TabContents to swap in the new renderer and destroy the old one. void ResumeResponse(); private: - ~CrossSiteResourceHandler() {} + virtual ~CrossSiteResourceHandler(); // Prepare to render the cross-site response in a new RenderViewHost, by // telling the old RenderViewHost to run its onunload handler. diff --git a/chrome/browser/renderer_host/database_dispatcher_host.cc b/chrome/browser/renderer_host/database_dispatcher_host.cc index 276ba75..11c5125 100644 --- a/chrome/browser/renderer_host/database_dispatcher_host.cc +++ b/chrome/browser/renderer_host/database_dispatcher_host.cc @@ -124,6 +124,8 @@ void DatabaseDispatcherHost::Send(IPC::Message* message) { delete message; } +DatabaseDispatcherHost::~DatabaseDispatcherHost() {} + void DatabaseDispatcherHost::OnDatabaseOpenFile(const string16& vfs_file_name, int desired_flags, IPC::Message* reply_msg) { diff --git a/chrome/browser/renderer_host/database_dispatcher_host.h b/chrome/browser/renderer_host/database_dispatcher_host.h index 58b9b6e..000c063 100644 --- a/chrome/browser/renderer_host/database_dispatcher_host.h +++ b/chrome/browser/renderer_host/database_dispatcher_host.h @@ -74,6 +74,9 @@ class DatabaseDispatcherHost void Send(IPC::Message* message); private: + friend class base::RefCountedThreadSafe<DatabaseDispatcherHost>; + virtual ~DatabaseDispatcherHost(); + class PromptDelegate; void AddObserver(); diff --git a/chrome/browser/renderer_host/gpu_view_host.cc b/chrome/browser/renderer_host/gpu_view_host.cc deleted file mode 100644 index fa8c19c..0000000 --- a/chrome/browser/renderer_host/gpu_view_host.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/gpu_view_host.h" - -#include "chrome/browser/gpu_process_host_ui_shim.h" -#include "chrome/browser/renderer_host/backing_store_proxy.h" -#include "chrome/browser/renderer_host/video_layer_proxy.h" -#include "chrome/common/gpu_messages.h" - -GpuViewHost::GpuViewHost(RenderWidgetHost* widget, GpuNativeWindowHandle parent) - : widget_(widget), - process_shim_(GpuProcessHostUIShim::Get()), - routing_id_(0) { - if (!process_shim_) { - // TODO(brettw) handle error. - return; - } - routing_id_ = process_shim_->NewRenderWidgetHostView(parent); -} - -GpuViewHost::~GpuViewHost() { -} - -BackingStore* GpuViewHost::CreateBackingStore(const gfx::Size& size) { - int32 backing_store_routing_id = process_shim_->GetNextRoutingId(); - BackingStoreProxy* result = - new BackingStoreProxy(widget_, size, - process_shim_, backing_store_routing_id); - process_shim_->Send(new GpuMsg_NewBackingStore(routing_id_, - backing_store_routing_id, - size)); - return result; -} - -VideoLayer* GpuViewHost::CreateVideoLayer(const gfx::Size& size) { - int32 video_layer_routing_id = process_shim_->GetNextRoutingId(); - VideoLayerProxy* result = - new VideoLayerProxy(widget_, size, - process_shim_, video_layer_routing_id); - process_shim_->Send(new GpuMsg_NewVideoLayer(routing_id_, - video_layer_routing_id, - size)); - return result; -} - -void GpuViewHost::OnWindowPainted() { - process_shim_->Send(new GpuMsg_WindowPainted(routing_id_)); -} diff --git a/chrome/browser/renderer_host/gpu_view_host.h b/chrome/browser/renderer_host/gpu_view_host.h deleted file mode 100644 index c37409c..0000000 --- a/chrome/browser/renderer_host/gpu_view_host.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_HOST_GPU_VIEW_HOST_H_ -#define CHROME_BROWSER_RENDERER_HOST_GPU_VIEW_HOST_H_ -#pragma once - -#include "base/basictypes.h" -#include "chrome/common/gpu_native_window_handle.h" - -class BackingStore; -class GpuProcessHostUIShim; -class RenderWidgetHost; -class VideoLayer; - -namespace gfx { -class Size; -} - -// A proxy for the GPU process' window for rendering pages. -class GpuViewHost { - public: - GpuViewHost(RenderWidgetHost* widget, GpuNativeWindowHandle parent); - ~GpuViewHost(); - - // Creates a new backing store in the GPU process and returns ownership of - // the new pointer to the caller. - BackingStore* CreateBackingStore(const gfx::Size& size); - - // Creates a new video layer in the GPU process and returns ownership of the - // new pointer to the caller. - VideoLayer* CreateVideoLayer(const gfx::Size& size); - - // Notification that the RenderWidgetHost has been asked to paint the window. - // Depending on the backing store, the GPU backing store may have to repaint - // at this time. On Linux this is needed because the GPU process paints - // directly into the RWH's X window. - void OnWindowPainted(); - - private: - RenderWidgetHost* widget_; - - GpuProcessHostUIShim* process_shim_; - int32 routing_id_; - - DISALLOW_COPY_AND_ASSIGN(GpuViewHost); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_GPU_VIEW_HOST_H_ diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc index 1c07795..a766f3c 100644 --- a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc +++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc @@ -10,12 +10,11 @@ #include <algorithm> #include "app/l10n_util.h" -#include "base/gtk_util.h" #include "base/logging.h" #include "base/string_util.h" #include "base/third_party/icu/icu_utf.h" #include "base/utf_string_conversions.h" -#include "chrome/app/chrome_dll_resource.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/gtk/gtk_util.h" #if !defined(TOOLKIT_VIEWS) #include "chrome/browser/gtk/menu_gtk.h" @@ -24,6 +23,7 @@ #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/render_messages.h" +#include "gfx/gtk_util.h" #include "gfx/rect.h" #include "grit/generated_resources.h" #include "third_party/skia/include/core/SkColor.h" @@ -266,7 +266,7 @@ void GtkIMContextWrapper::AppendInputMethodsContextMenu(MenuGtk* menu) { if (!show_input_method_menu) return; - std::string label = gtk_util::ConvertAcceleratorsFromWindowsStyle( + std::string label = gfx::ConvertAcceleratorsFromWindowsStyle( l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_INPUT_METHODS_MENU)); GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic(label.c_str()); GtkWidget* submenu = gtk_menu_new(); diff --git a/chrome/browser/renderer_host/gtk_key_bindings_handler_unittest.cc b/chrome/browser/renderer_host/gtk_key_bindings_handler_unittest.cc index 19f0806..1ac020c 100644 --- a/chrome/browser/renderer_host/gtk_key_bindings_handler_unittest.cc +++ b/chrome/browser/renderer_host/gtk_key_bindings_handler_unittest.cc @@ -85,7 +85,8 @@ class GtkKeyBindingsHandlerTest : public testing::Test { GtkKeyBindingsHandler* handler_; }; -TEST_F(GtkKeyBindingsHandlerTest, MoveCursor) { +// Does not work in a chroot. See bug 60363. +TEST_F(GtkKeyBindingsHandlerTest, FLAKY_MoveCursor) { static const EditCommand kEditCommands[] = { // "move-cursor" (logical-positions, -2, 0) { "MoveBackward", "" }, @@ -127,7 +128,8 @@ TEST_F(GtkKeyBindingsHandlerTest, MoveCursor) { kEditCommands, arraysize(kEditCommands)); } -TEST_F(GtkKeyBindingsHandlerTest, DeleteFromCursor) { +// Does not work in a chroot. See bug 60363. +TEST_F(GtkKeyBindingsHandlerTest, FLAKY_DeleteFromCursor) { static const EditCommand kEditCommands[] = { // "delete-from-cursor" (chars, -2) { "DeleteBackward", "" }, @@ -171,7 +173,8 @@ TEST_F(GtkKeyBindingsHandlerTest, DeleteFromCursor) { kEditCommands, arraysize(kEditCommands)); } -TEST_F(GtkKeyBindingsHandlerTest, OtherActions) { +// Does not work in a chroot. See bug 60363. +TEST_F(GtkKeyBindingsHandlerTest, FLAKY_OtherActions) { static const EditCommand kBackspace[] = { { "DeleteBackward", "" } }; diff --git a/chrome/browser/renderer_host/offline_resource_handler.cc b/chrome/browser/renderer_host/offline_resource_handler.cc index 68a036d..ba94bee 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.cc +++ b/chrome/browser/renderer_host/offline_resource_handler.cc @@ -68,7 +68,7 @@ bool OfflineResourceHandler::OnWillStart(int request_id, if (ShouldShowOfflinePage(url)) { deferred_request_id_ = request_id; deferred_url_ = url; - DLOG(INFO) << "WillStart: this=" << this << ", request id=" << request_id; + DVLOG(1) << "WillStart: this=" << this << ", request id=" << request_id; AddRef(); // Balanced with OnBlockingPageComplete BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -148,8 +148,7 @@ void OfflineResourceHandler::Resume() { DCHECK_NE(request_id, -1); bool defer = false; - DLOG(INFO) << "Resume load: this=" << this - << ", request id=" << request_id; + DVLOG(1) << "Resume load: this=" << this << ", request id=" << request_id; next_handler_->OnWillStart(request_id, url, &defer); if (!defer) rdh_->StartDeferredRequest(process_host_id_, request_id); diff --git a/chrome/browser/renderer_host/pepper_file_message_filter.cc b/chrome/browser/renderer_host/pepper_file_message_filter.cc index e7b331b..cbd09af 100644 --- a/chrome/browser/renderer_host/pepper_file_message_filter.cc +++ b/chrome/browser/renderer_host/pepper_file_message_filter.cc @@ -104,7 +104,7 @@ void PepperFileMessageFilter::OnMessageReceivedFileThread( } } -void PepperFileMessageFilter::OnDestruct() { +void PepperFileMessageFilter::OnDestruct() const { BrowserThread::DeleteOnIOThread::Destruct(this); } diff --git a/chrome/browser/renderer_host/pepper_file_message_filter.h b/chrome/browser/renderer_host/pepper_file_message_filter.h index 37e57f6..003d258 100644 --- a/chrome/browser/renderer_host/pepper_file_message_filter.h +++ b/chrome/browser/renderer_host/pepper_file_message_filter.h @@ -37,7 +37,7 @@ class PepperFileMessageFilter : public IPC::ChannelProxy::MessageFilter { virtual void OnChannelError(); virtual void OnChannelClosing(); virtual bool OnMessageReceived(const IPC::Message& message); - virtual void OnDestruct(); + virtual void OnDestruct() const; // Called from the FILE thread. void Send(IPC::Message* message); diff --git a/chrome/browser/renderer_host/render_process_host.cc b/chrome/browser/renderer_host/render_process_host.cc index b224b1f..a2c328c 100644 --- a/chrome/browser/renderer_host/render_process_host.cc +++ b/chrome/browser/renderer_host/render_process_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -111,14 +111,13 @@ RenderProcessHost::~RenderProcessHost() { void RenderProcessHost::Attach(IPC::Channel::Listener* listener, int routing_id) { - LOG_IF(INFO, g_log_bug53991) << - "AddListener: (" << this << "): " << routing_id; + VLOG_IF(1, g_log_bug53991) << "AddListener: (" << this << "): " << routing_id; listeners_.AddWithID(listener, routing_id); } void RenderProcessHost::Release(int listener_id) { - LOG_IF(INFO, g_log_bug53991) << - "RemListener: (" << this << "): " << listener_id; + VLOG_IF(1, g_log_bug53991) << "RemListener: (" << this << "): " + << listener_id; DCHECK(listeners_.Lookup(listener_id) != NULL); listeners_.Remove(listener_id); diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc index 5292d95..0253f9e 100644 --- a/chrome/browser/renderer_host/render_sandbox_host_linux.cc +++ b/chrome/browser/renderer_host/render_sandbox_host_linux.cc @@ -360,7 +360,7 @@ class SandboxIPCProcess { return; int shm_fd = -1; base::SharedMemory shm; - if (shm.Create("", false, false, shm_size)) + if (shm.CreateAnonymous(shm_size)) shm_fd = shm.handle().fd; Pickle reply; SendRendererReply(fds, reply, shm_fd); @@ -540,6 +540,9 @@ class SandboxIPCProcess { FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("lv")); FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("lt")); break; + // TODO(jungshik): Would we be better off mapping Big5 to zh-tw + // and GB2312 to zh-cn? Fontconfig has 4 separate orthography + // files (zh-{cn,tw,hk,mo}. case NPCharsetChineseBIG5: case NPCharsetGB2312: FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("zh")); @@ -565,7 +568,7 @@ class SandboxIPCProcess { break; case NPCharsetShiftJIS: // Japanese - FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("jp")); + FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("ja")); break; case NPCharsetTurkish: FcLangSetAdd(langset, reinterpret_cast<const FcChar8*>("tr")); diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 3781bed..134274e 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -23,7 +23,6 @@ #include "chrome/browser/dom_operation_notification_details.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/in_process_webkit/session_storage_namespace.h" -#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/profile.h" @@ -89,7 +88,7 @@ void FilterURL(ChildProcessSecurityPolicy* policy, int renderer_id, GURL* url) { // If this renderer is not permitted to request this URL, we invalidate the // URL. This prevents us from storing the blocked URL and becoming confused // later. - LOG(INFO) << "Blocked URL " << url->spec(); + VLOG(1) << "Blocked URL " << url->spec(); *url = GURL(); } } @@ -386,6 +385,10 @@ bool RenderViewHost::PrintPages() { return Send(new ViewMsg_PrintPages(routing_id())); } +bool RenderViewHost::PrintPreview() { + return Send(new ViewMsg_PrintPreview(routing_id())); +} + void RenderViewHost::PrintingDone(int document_cookie, bool success) { Send(new ViewMsg_PrintingDone(routing_id(), document_cookie, success)); } @@ -433,6 +436,10 @@ void RenderViewHost::Zoom(PageZoom::Function function) { Send(new ViewMsg_Zoom(routing_id(), function)); } +void RenderViewHost::SetZoomLevel(double zoom_level) { + Send(new ViewMsg_SetZoomLevel(routing_id(), zoom_level)); +} + void RenderViewHost::SetPageEncoding(const std::string& encoding_name) { Send(new ViewMsg_SetPageEncoding(routing_id(), encoding_name)); } @@ -796,6 +803,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { OnMsgForwardMessageToExternalHost) IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, OnMsgDocumentLoadedInFrame) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, + OnMsgDidFinishLoad) IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnMsgGoToEntryAtOffset) IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) @@ -833,8 +842,6 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { OnRequestUndockDevToolsWindow); IPC_MESSAGE_HANDLER(ViewHostMsg_DevToolsRuntimePropertyChanged, OnDevToolsRuntimePropertyChanged); - IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, - OnUserMetricsRecordAction) IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus); IPC_MESSAGE_HANDLER(ViewHostMsg_NonSandboxedPluginBlocked, OnNonSandboxedPluginBlocked); @@ -884,12 +891,24 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) - IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestResult, OnSetSuggestResult) + IPC_MESSAGE_HANDLER(ViewHostMsg_SetSuggestions, OnSetSuggestions) + IPC_MESSAGE_HANDLER(ViewHostMsg_InstantSupportDetermined, + OnInstantSupportDetermined) IPC_MESSAGE_HANDLER(ViewHostMsg_DetectedPhishingSite, OnDetectedPhishingSite) IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, OnUpdateContentRestrictions) +#if defined(OS_MACOSX) + IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) +#endif +#if defined(OS_MACOSX) || defined(OS_WIN) + IPC_MESSAGE_HANDLER(ViewHostMsg_PageReadyForPreview, + OnPageReadyForPreview) +#else + IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, + OnPagesReadyForPreview) +#endif // Have the super handle all other messages. IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg)) IPC_END_MESSAGE_MAP_EX() @@ -1192,11 +1211,11 @@ void RenderViewHost::OnMsgDidFailProvisionalLoadWithError( int error_code, const GURL& url, bool showing_repost_interstitial) { - LOG(INFO) << "Failed Provisional Load: " << url.possibly_invalid_spec() - << ", error_code: " << error_code - << " is_main_frame: " << is_main_frame - << " showing_repost_interstitial: " << showing_repost_interstitial - << " frame_id: " << frame_id; + VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() + << ", error_code: " << error_code + << " is_main_frame: " << is_main_frame + << " showing_repost_interstitial: " << showing_repost_interstitial + << " frame_id: " << frame_id; GURL validated_url(url); FilterURL(ChildProcessSecurityPolicy::GetInstance(), process()->id(), &validated_url); @@ -1349,11 +1368,18 @@ void RenderViewHost::OnMsgForwardMessageToExternalHost( delegate_->ProcessExternalHostMessage(message, origin, target); } -void RenderViewHost::OnMsgDocumentLoadedInFrame() { +void RenderViewHost::OnMsgDocumentLoadedInFrame(long long frame_id) { RenderViewHostDelegate::Resource* resource_delegate = delegate_->GetResourceDelegate(); if (resource_delegate) - resource_delegate->DocumentLoadedInFrame(); + resource_delegate->DocumentLoadedInFrame(frame_id); +} + +void RenderViewHost::OnMsgDidFinishLoad(long long frame_id) { + RenderViewHostDelegate::Resource* resource_delegate = + delegate_->GetResourceDelegate(); + if (resource_delegate) + resource_delegate->DidFinishLoad(frame_id); } void RenderViewHost::DisassociateFromPopupCount() { @@ -1567,10 +1593,6 @@ void RenderViewHost::OnDevToolsRuntimePropertyChanged( RuntimePropertyChanged(this, name, value); } -void RenderViewHost::OnUserMetricsRecordAction(const std::string& action) { - UserMetrics::RecordComputedAction(action, process()->profile()); -} - bool RenderViewHost::PreHandleKeyboardEvent( const NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); @@ -1831,8 +1853,22 @@ void RenderViewHost::NotifyRendererResponsive() { delegate_->RendererResponsive(this); } -void RenderViewHost::OnMsgFocusedNodeChanged() { +void RenderViewHost::OnMsgFocusedNodeChanged(bool is_editable_node) { delegate_->FocusedNodeChanged(); + +#if defined(TOUCH_UI) + if (is_editable_node) { + // Need to summon on-screen keyboard + // TODO(bryeung): implement this + + // The currently focused element can be placed out of the view as the screen + // is now shared by the keyboard. Hence, we tell the renderer to scroll + // until the focused element comes in view. + Send(new ViewMsg_ScrollFocusedEditableNodeIntoView(routing_id())); + } else { + // TODO(bryeung): implement this. Should hide the on-screen keyboard. + } +#endif } void RenderViewHost::OnMsgFocus() { @@ -2009,6 +2045,41 @@ void RenderViewHost::EnablePreferredSizeChangedMode(int flags) { Send(new ViewMsg_EnablePreferredSizeChangedMode(routing_id(), flags)); } +#if defined(OS_MACOSX) +void RenderViewHost::DidSelectPopupMenuItem(int selected_index) { + Send(new ViewMsg_SelectPopupMenuItem(routing_id(), selected_index)); +} + +void RenderViewHost::DidCancelPopupMenu() { + Send(new ViewMsg_SelectPopupMenuItem(routing_id(), -1)); +} +#endif + +void RenderViewHost::SearchBoxChange(const string16& value, + bool verbatim, + int selection_start, + int selection_end) { + Send(new ViewMsg_SearchBoxChange( + routing_id(), value, verbatim, selection_start, selection_end)); +} + +void RenderViewHost::SearchBoxSubmit(const string16& value, + bool verbatim) { + Send(new ViewMsg_SearchBoxSubmit(routing_id(), value, verbatim)); +} + +void RenderViewHost::SearchBoxCancel() { + Send(new ViewMsg_SearchBoxCancel(routing_id())); +} + +void RenderViewHost::SearchBoxResize(const gfx::Rect& search_box_bounds) { + Send(new ViewMsg_SearchBoxResize(routing_id(), search_box_bounds)); +} + +void RenderViewHost::DetermineIfPageSupportsInstant(const string16& value) { + Send(new ViewMsg_DetermineIfPageSupportsInstant(routing_id(), value)); +} + void RenderViewHost::OnExtensionPostMessage( int port_id, const std::string& message) { if (process()->profile()->GetExtensionMessageService()) { @@ -2111,13 +2182,22 @@ void RenderViewHost::OnUpdateZoomLimits(int minimum_percent, delegate_->UpdateZoomLimits(minimum_percent, maximum_percent, remember); } -void RenderViewHost::OnSetSuggestResult(int32 page_id, - const std::string& result) { +void RenderViewHost::OnSetSuggestions( + int32 page_id, + const std::vector<std::string>& suggestions) { + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (!integration_delegate) + return; + integration_delegate->OnSetSuggestions(page_id, suggestions); +} + +void RenderViewHost::OnInstantSupportDetermined(int32 page_id, bool result) { RenderViewHostDelegate::BrowserIntegration* integration_delegate = delegate_->GetBrowserIntegrationDelegate(); if (!integration_delegate) return; - integration_delegate->OnSetSuggestResult(page_id, result); + integration_delegate->OnInstantSupportDetermined(page_id, result); } void RenderViewHost::OnDetectedPhishingSite(const GURL& phishing_url, @@ -2139,3 +2219,37 @@ void RenderViewHost::OnScriptEvalResponse(int id, bool result) { void RenderViewHost::OnUpdateContentRestrictions(int restrictions) { delegate_->UpdateContentRestrictions(restrictions); } + +#if defined(OS_MACOSX) +void RenderViewHost::OnMsgShowPopup( + const ViewHostMsg_ShowPopup_Params& params) { + RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); + if (view) { + view->ShowPopupMenu(params.bounds, + params.item_height, + params.item_font_size, + params.selected_item, + params.popup_items, + params.right_aligned); + } +} +#endif + +#if defined(OS_MACOSX) || defined(OS_WIN) +void RenderViewHost::OnPageReadyForPreview( + const ViewHostMsg_DidPrintPage_Params& params) { + // TODO(kmadhusu): Function definition needs to be changed. + // 'params' contains the metafile handle for preview. + + // Send the printingDone msg for now. + Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); +} +#else +void RenderViewHost::OnPagesReadyForPreview(int fd_in_browser) { + // TODO(kmadhusu): Function definition needs to be changed. + // fd_in_browser should be the file descriptor of the metafile. + + // Send the printingDone msg for now. + Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); +} +#endif diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 76f1f01..efcf56c 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -202,6 +202,9 @@ class RenderViewHost : public RenderWidgetHost { // behalf. bool PrintPages(); + // Asks the renderer to render pages for print preview. + bool PrintPreview(); + // Notify renderer of success/failure of print job. void PrintingDone(int document_cookie, bool success); @@ -216,9 +219,12 @@ class RenderViewHost : public RenderWidgetHost { // Cancel a pending find operation. void StopFinding(FindBarController::SelectionAction selection_action); - // Change the zoom level of a page. + // Increment, decrement, or reset the zoom level of a page. void Zoom(PageZoom::Function function); + // Change the zoom level of a page to a specific value. + void SetZoomLevel(double zoom_level); + // Change the encoding of the page. void SetPageEncoding(const std::string& encoding); @@ -490,6 +496,23 @@ class RenderViewHost : public RenderWidgetHost { // in render_messages.h. void EnablePreferredSizeChangedMode(int flags); +#if defined(OS_MACOSX) + // Select popup menu related methods (for external popup menus). + void DidSelectPopupMenuItem(int selected_index); + void DidCancelPopupMenu(); +#endif + + // SearchBox notifications. + void SearchBoxChange(const string16& value, + bool verbatim, + int selection_start, + int selection_end); + void SearchBoxSubmit(const string16& value, + bool verbatim); + void SearchBoxCancel(); + void SearchBoxResize(const gfx::Rect& search_box_bounds); + void DetermineIfPageSupportsInstant(const string16& value); + #if defined(UNIT_TEST) // These functions shouldn't be necessary outside of testing. @@ -512,7 +535,7 @@ class RenderViewHost : public RenderWidgetHost { virtual void OnUserGesture(); virtual void NotifyRendererUnresponsive(); virtual void NotifyRendererResponsive(); - virtual void OnMsgFocusedNodeChanged(); + virtual void OnMsgFocusedNodeChanged(bool is_editable_node); virtual void OnMsgFocus(); virtual void OnMsgBlur(); @@ -582,7 +605,8 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgForwardMessageToExternalHost(const std::string& message, const std::string& origin, const std::string& target); - void OnMsgDocumentLoadedInFrame(); + void OnMsgDocumentLoadedInFrame(long long frame_id); + void OnMsgDidFinishLoad(long long frame_id); void OnMsgGoToEntryAtOffset(int offset); void OnMsgSetTooltipText(const std::wstring& tooltip_text, WebKit::WebTextDirection text_direction_hint); @@ -631,8 +655,6 @@ class RenderViewHost : public RenderWidgetHost { void OnRequestUndockDevToolsWindow(); void OnDevToolsRuntimePropertyChanged(const std::string& name, const std::string& value); - - void OnUserMetricsRecordAction(const std::string& action); void OnMissingPluginStatus(int status); void OnNonSandboxedPluginBlocked(const std::string& plugin, const string16& name); @@ -694,12 +716,23 @@ class RenderViewHost : public RenderWidgetHost { void OnUpdateZoomLimits(int minimum_percent, int maximum_percent, bool remember); - void OnSetSuggestResult(int32 page_id, const std::string& result); + void OnSetSuggestions(int32 page_id, + const std::vector<std::string>& suggestions); + void OnInstantSupportDetermined(int32 page_id, bool result); void OnDetectedPhishingSite(const GURL& phishing_url, double phishing_score, const SkBitmap& thumbnail); void OnScriptEvalResponse(int id, bool result); void OnUpdateContentRestrictions(int restrictions); +#if defined(OS_MACOSX) || defined(OS_WIN) + void OnPageReadyForPreview(const ViewHostMsg_DidPrintPage_Params& params); +#else + void OnPagesReadyForPreview(int fd_in_browser); +#endif + +#if defined(OS_MACOSX) + void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params); +#endif private: friend class TestRenderViewHost; diff --git a/chrome/browser/renderer_host/render_view_host_delegate.cc b/chrome/browser/renderer_host/render_view_host_delegate.cc index 19722a1..523fd8f 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.cc +++ b/chrome/browser/renderer_host/render_view_host_delegate.cc @@ -112,7 +112,3 @@ gfx::Rect RenderViewHostDelegate::GetRootWindowResizerRect() const { bool RenderViewHostDelegate::IsExternalTabContainer() const { return false; } - -bool RenderViewHostDelegate::View::ShouldDrawDropShadow() { - return false; -} diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index d0c88d6..a4e88a3 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -50,6 +50,7 @@ struct ViewHostMsg_FrameNavigate_Params; struct ViewHostMsg_PageHasOSDD_Type; struct ViewHostMsg_RunFileChooser_Params; struct WebDropData; +struct WebMenuItem; class WebKeyboardEvent; struct WebPreferences; @@ -146,6 +147,16 @@ class RenderViewHostDelegate { // provided in the supplied params. virtual void ShowContextMenu(const ContextMenuParams& params) = 0; + // Shows a popup menu with the specified items. + // This method should call RenderViewHost::DidSelectPopupMenuItemAt() or + // RenderViewHost::DidCancelPopupMenu() ased on the user action. + virtual void ShowPopupMenu(const gfx::Rect& bounds, + int item_height, + double item_font_size, + int selected_item, + const std::vector<WebMenuItem>& items, + bool right_aligned) = 0; + // The user started dragging content of the specified type within the // RenderView. Contextual information about the dragged content is supplied // by WebDropData. @@ -198,10 +209,6 @@ class RenderViewHostDelegate { // The contents' preferred size changed. virtual void UpdatePreferredSize(const gfx::Size& pref_size) = 0; - // Called to determine whether the render view needs to draw a drop shadow - // at the top (currently used for infobars). - virtual bool ShouldDrawDropShadow(); - protected: virtual ~View() {} }; @@ -292,8 +299,12 @@ class RenderViewHostDelegate { TranslateErrors::Type error_type) = 0; // Notification that the page has a suggest result. - virtual void OnSetSuggestResult(int32 page_id, - const std::string& result) = 0; + virtual void OnSetSuggestions( + int32 page_id, + const std::vector<std::string>& result) = 0; + + // Notification of whether the page supports instant-style interaction. + virtual void OnInstantSupportDetermined(int32 page_id, bool result) = 0; protected: virtual ~BrowserIntegration() {} @@ -354,7 +365,10 @@ class RenderViewHostDelegate { bool showing_repost_interstitial) = 0; // Notification that a document has been loaded in a frame. - virtual void DocumentLoadedInFrame() = 0; + virtual void DocumentLoadedInFrame(long long frame_id) = 0; + + // Notification that a frame finished loading. + virtual void DidFinishLoad(long long frame_id) = 0; protected: virtual ~Resource() {} @@ -383,7 +397,6 @@ class RenderViewHostDelegate { // |blocked_by_policy| should be true, and this function should invoke // OnContentBlocked. virtual void OnIndexedDBAccessed(const GURL& url, - const string16& name, const string16& description, bool blocked_by_policy) = 0; diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc index 0124117..c3abe80 100644 --- a/chrome/browser/renderer_host/render_widget_helper.cc +++ b/chrome/browser/renderer_host/render_widget_helper.cc @@ -195,7 +195,7 @@ void RenderWidgetHelper::OnCancelResourceRequests( } void RenderWidgetHelper::OnCrossSiteClosePageACK( - ViewMsg_ClosePage_Params params) { + const ViewMsg_ClosePage_Params& params) { resource_dispatcher_host_->OnClosePageACK(params); } @@ -290,8 +290,7 @@ TransportDIB* RenderWidgetHelper::MapTransportDIB(TransportDIB::Id dib_id) { void RenderWidgetHelper::AllocTransportDIB( size_t size, bool cache_in_browser, TransportDIB::Handle* result) { scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); - if (!shared_memory->Create("", false /* read write */, - false /* do not open existing */, size)) { + if (!shared_memory->CreateAnonymous(size)) { result->fd = -1; result->auto_close = false; return; diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h index 6cad1dc..6d3dcfa 100644 --- a/chrome/browser/renderer_host/render_widget_helper.h +++ b/chrome/browser/renderer_host/render_widget_helper.h @@ -189,7 +189,7 @@ class RenderWidgetHelper void OnCancelResourceRequests(int render_widget_id); // Called on the IO thread to resume a cross-site response. - void OnCrossSiteClosePageACK(ViewMsg_ClosePage_Params params); + void OnCrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params); #if defined(OS_MACOSX) // Called on destruction to release all allocated transport DIBs diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index a6efd58..6f586ee 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -17,7 +17,6 @@ #include "chrome/browser/renderer_host/render_widget_helper.h" #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" -#include "chrome/browser/renderer_host/video_layer.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/notification_service.h" @@ -150,9 +149,6 @@ void RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect) - IPC_MESSAGE_HANDLER(ViewHostMsg_CreateVideo, OnMsgCreateVideo) - IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateVideo, OnMsgUpdateVideo) - IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyVideo, OnMsgDestroyVideo) IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck) IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) @@ -164,7 +160,6 @@ void RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_GpuRenderingActivated, OnMsgGpuRenderingActivated) #if defined(OS_MACOSX) - IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo) IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect) IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnMsgGetRootWindowRect) @@ -793,7 +788,6 @@ void RenderWidgetHost::OnMsgUpdateRect( DCHECK(!params.bitmap_rect.IsEmpty()); DCHECK(!params.view_size.IsEmpty()); - bool painted_synchronously = true; // Default to sending a paint ACK below. if (!is_gpu_rendering_active_) { const size_t size = params.bitmap_rect.height() * params.bitmap_rect.width() * 4; @@ -817,8 +811,7 @@ void RenderWidgetHost::OnMsgUpdateRect( // renderer-supplied bits. The view will read out of the backing store // later to actually draw to the screen. PaintBackingStoreRect(params.bitmap, params.bitmap_rect, - params.copy_rects, params.view_size, - &painted_synchronously); + params.copy_rects, params.view_size); } } } @@ -826,10 +819,8 @@ void RenderWidgetHost::OnMsgUpdateRect( // ACK early so we can prefetch the next PaintRect if there is a next one. // This must be done AFTER we're done painting with the bitmap supplied by the // renderer. This ACK is a signal to the renderer that the backing store can - // be re-used, so the bitmap may be invalid after this call. If the backing - // store is painting asynchronously, it will manage issuing this IPC. - if (painted_synchronously) - Send(new ViewMsg_UpdateRect_ACK(routing_id_)); + // be re-used, so the bitmap may be invalid after this call. + Send(new ViewMsg_UpdateRect_ACK(routing_id_)); // We don't need to update the view if the view is hidden. We must do this // early return after the ACK is sent, however, or the renderer will not send @@ -872,27 +863,6 @@ void RenderWidgetHost::OnMsgUpdateRect( UMA_HISTOGRAM_TIMES("MPArch.RWH_OnMsgUpdateRect", delta); } -void RenderWidgetHost::OnMsgCreateVideo(const gfx::Size& size) { - DCHECK(!video_layer_.get()); - - video_layer_.reset(view_->AllocVideoLayer(size)); - - // TODO(scherkus): support actual video ids! - Send(new ViewMsg_CreateVideo_ACK(routing_id_, -1)); -} - -void RenderWidgetHost::OnMsgUpdateVideo(TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect) { - PaintVideoLayer(bitmap, bitmap_rect); - - // TODO(scherkus): support actual video ids! - Send(new ViewMsg_UpdateVideo_ACK(routing_id_, -1)); -} - -void RenderWidgetHost::OnMsgDestroyVideo() { - video_layer_.reset(); -} - void RenderWidgetHost::OnMsgInputEventAck(const IPC::Message& message) { // Log the time delta for processing an input event. TimeDelta delta = TimeTicks::Now() - input_event_start_time_; @@ -978,16 +948,6 @@ void RenderWidgetHost::OnMsgGpuRenderingActivated(bool activated) { #if defined(OS_MACOSX) -void RenderWidgetHost::OnMsgShowPopup( - const ViewHostMsg_ShowPopup_Params& params) { - view_->ShowPopupWithItems(params.bounds, - params.item_height, - params.item_font_size, - params.selected_item, - params.popup_items, - params.right_aligned); -} - void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view, WebScreenInfo* results) { gfx::NativeView native_view = view_ ? view_->GetNativeView() : NULL; @@ -1056,9 +1016,9 @@ void RenderWidgetHost::OnAcceleratedSurfaceSetTransportDIB( } void RenderWidgetHost::OnAcceleratedSurfaceBuffersSwapped( - gfx::PluginWindowHandle window) { + gfx::PluginWindowHandle window, uint64 surface_id) { if (view_) { - view_->AcceleratedSurfaceBuffersSwapped(window); + view_->AcceleratedSurfaceBuffersSwapped(window, surface_id); } } #elif defined(OS_POSIX) @@ -1088,12 +1048,7 @@ void RenderWidgetHost::PaintBackingStoreRect( TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, - const gfx::Size& view_size, - bool* painted_synchronously) { - // On failure, we need to be sure our caller knows we're done with the - // backing store. - *painted_synchronously = true; - + const gfx::Size& view_size) { // The view may be destroyed already. if (!view_) return; @@ -1108,8 +1063,7 @@ void RenderWidgetHost::PaintBackingStoreRect( bool needs_full_paint = false; BackingStoreManager::PrepareBackingStore(this, view_size, bitmap, bitmap_rect, - copy_rects, &needs_full_paint, - painted_synchronously); + copy_rects, &needs_full_paint); if (needs_full_paint) { repaint_start_time_ = TimeTicks::Now(); repaint_ack_pending_ = true; @@ -1137,26 +1091,6 @@ void RenderWidgetHost::ScrollBackingStoreRect(int dx, int dy, backing_store->ScrollBackingStore(dx, dy, clip_rect, view_size); } -void RenderWidgetHost::PaintVideoLayer(TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect) { - if (is_hidden_ || !video_layer_.get()) - return; - - video_layer_->CopyTransportDIB(process(), bitmap, bitmap_rect); - - // Don't update the view if we're hidden or if the view has been destroyed. - if (is_hidden_ || !view_) - return; - - // Trigger a paint for the updated video layer bitmap. - std::vector<gfx::Rect> copy_rects; - copy_rects.push_back(bitmap_rect); - - view_being_painted_ = true; - view_->DidUpdateBackingStore(gfx::Rect(), 0, 0, copy_rects); - view_being_painted_ = false; -} - void RenderWidgetHost::ToggleSpellPanel(bool is_currently_visible) { Send(new ViewMsg_ToggleSpellPanel(routing_id(), is_currently_visible)); } diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 6c3fed7..42bdbde 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -42,7 +42,6 @@ class RenderProcessHost; class RenderWidgetHostView; class RenderWidgetHostPaintingObserver; class TransportDIB; -class VideoLayer; class WebCursor; struct ViewHostMsg_ShowPopup_Params; struct ViewHostMsg_UpdateRect_Params; @@ -248,9 +247,6 @@ class RenderWidgetHost : public IPC::Channel::Listener, // block briefly waiting for an ack from the renderer. void ScheduleComposite(); - // Returns the video layer if it exists, NULL otherwise. - VideoLayer* video_layer() const { return video_layer_.get(); } - // Starts a hang monitor timeout. If there's already a hang monitor timeout // the new one will only fire if it has a shorter delay than the time // left on the existing timeouts. @@ -479,9 +475,6 @@ class RenderWidgetHost : public IPC::Channel::Listener, void OnMsgRequestMove(const gfx::Rect& pos); void OnMsgPaintAtSizeAck(int tag, const gfx::Size& size); void OnMsgUpdateRect(const ViewHostMsg_UpdateRect_Params& params); - void OnMsgCreateVideo(const gfx::Size& size); - void OnMsgUpdateVideo(TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect); - void OnMsgDestroyVideo(); void OnMsgInputEventAck(const IPC::Message& message); virtual void OnMsgFocus(); virtual void OnMsgBlur(); @@ -494,7 +487,6 @@ class RenderWidgetHost : public IPC::Channel::Listener, void OnMsgGpuRenderingActivated(bool activated); #if defined(OS_MACOSX) - void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params); void OnMsgGetScreenInfo(gfx::NativeViewId view, WebKit::WebScreenInfo* results); void OnMsgGetWindowRect(gfx::NativeViewId window_id, gfx::Rect* results); @@ -512,22 +504,18 @@ class RenderWidgetHost : public IPC::Channel::Listener, int32 width, int32 height, TransportDIB::Handle transport_dib); - void OnAcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window); + void OnAcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window, + uint64 surface_id); #elif defined(OS_POSIX) void OnMsgCreatePluginContainer(gfx::PluginWindowHandle id); void OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id); #endif // Paints the given bitmap to the current backing store at the given location. - // |*painted_synchronously| will be true if the message was processed - // synchronously, and the bitmap is done being used. False means that the - // backing store will paint the bitmap at a later time and that the DIB can't - // be freed (it will be the backing store's job to free it later). void PaintBackingStoreRect(TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, const std::vector<gfx::Rect>& copy_rects, - const gfx::Size& view_size, - bool* painted_synchronously); + const gfx::Size& view_size); // Scrolls the given |clip_rect| in the backing by the given dx/dy amount. The // |dib| and its corresponding location |bitmap_rect| in the backing store @@ -535,12 +523,6 @@ class RenderWidgetHost : public IPC::Channel::Listener, void ScrollBackingStoreRect(int dx, int dy, const gfx::Rect& clip_rect, const gfx::Size& view_size); - // Paints the entire given bitmap into the current video layer, if it exists. - // |bitmap_rect| specifies the destination size and absolute location of the - // bitmap on the backing store. - void PaintVideoLayer(TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect); - // Called by OnMsgInputEventAck() to process a keyboard event ack message. void ProcessKeyboardEventAck(int type, bool processed); @@ -690,9 +672,6 @@ class RenderWidgetHost : public IPC::Channel::Listener, // changed. bool suppress_next_char_events_; - // Optional video YUV layer for used for out-of-process compositing. - scoped_ptr<VideoLayer> video_layer_; - DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); }; diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index 46d6bda..d7fa9c3 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -30,11 +30,9 @@ class Message; class BackingStore; class RenderProcessHost; class RenderWidgetHost; -class VideoLayer; class WebCursor; struct NativeWebKeyboardEvent; struct ViewHostMsg_AccessibilityNotification_Params; -struct WebMenuItem; namespace webkit_glue { struct WebAccessibility; @@ -174,9 +172,6 @@ class RenderWidgetHostView { // Allocate a backing store for this view virtual BackingStore* AllocBackingStore(const gfx::Size& size) = 0; - // Allocate a video layer for this view. - virtual VideoLayer* AllocVideoLayer(const gfx::Size& size) = 0; - #if defined(OS_MACOSX) // Tells the view whether or not to accept first responder status. If |flag| // is true, the view does not accept first responder status and instead @@ -184,14 +179,6 @@ class RenderWidgetHostView { // |flag| is false, the view participates in the key-view chain as normal. virtual void SetTakesFocusOnlyOnMouseDown(bool flag) = 0; - // Display a native control popup menu for WebKit. - virtual void ShowPopupWithItems(gfx::Rect bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector<WebMenuItem>& items, - bool right_aligned) = 0; - // Get the view's position on the screen. virtual gfx::Rect GetWindowRect() = 0; @@ -238,7 +225,7 @@ class RenderWidgetHostView { int32 height, TransportDIB::Handle transport_dib) = 0; virtual void AcceleratedSurfaceBuffersSwapped( - gfx::PluginWindowHandle window) = 0; + gfx::PluginWindowHandle window, uint64 surface_id) = 0; virtual void GpuRenderingStateDidChange() = 0; #endif diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 5f4a843..bbbe456 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -29,16 +29,14 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/renderer_host/backing_store_x.h" -#include "chrome/browser/renderer_host/gpu_view_host.h" #include "chrome/browser/renderer_host/gtk_im_context_wrapper.h" #include "chrome/browser/renderer_host/gtk_key_bindings_handler.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/renderer_host/render_widget_host.h" -#include "chrome/browser/renderer_host/video_layer_x.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/native_web_keyboard_event.h" -#include "gfx/gtk_util.h" +#include "gfx/gtk_preserve_window.h" #include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h" #include "webkit/glue/plugins/webplugin.h" #include "webkit/glue/webaccessibility.h" @@ -71,17 +69,16 @@ using WebKit::WebMouseWheelEvent; class RenderWidgetHostViewGtkWidget { public: static GtkWidget* CreateNewWidget(RenderWidgetHostViewGtk* host_view) { - GtkWidget* widget = gtk_fixed_new(); + GtkWidget* widget = gtk_preserve_window_new(); gtk_widget_set_name(widget, "chrome-render-widget-host-view"); - gtk_fixed_set_has_window(GTK_FIXED(widget), TRUE); // We manually double-buffer in Paint() because Paint() may or may not be // called in repsonse to an "expose-event" signal. gtk_widget_set_double_buffered(widget, FALSE); gtk_widget_set_redraw_on_allocate(widget, FALSE); #if defined(NDEBUG) - gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkWhite); + gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, >k_util::kGdkWhite); #else - gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkGreen); + gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, >k_util::kGdkGreen); #endif // Allow the browser window to be resized freely. gtk_widget_set_size_request(widget, 0, 0); @@ -266,6 +263,10 @@ class RenderWidgetHostViewGtkWidget { if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) return FALSE; + // If we don't have focus already, this mouse click will focus us. + if (!gtk_widget_is_focus(widget)) + host_view->host_->OnMouseActivate(); + // Confirm existing composition text on mouse click events, to make sure // the input caret won't be moved with an ongoing composition session. host_view->im_context_->ConfirmComposition(); @@ -353,9 +354,9 @@ class RenderWidgetHostViewGtkWidget { static gboolean ClientEvent(GtkWidget* widget, GdkEventClient* event, RenderWidgetHostViewGtk* host_view) { - LOG(INFO) << "client event type: " << event->message_type - << " data_format: " << event->data_format - << " data: " << event->data.l; + VLOG(1) << "client event type: " << event->message_type + << " data_format: " << event->data_format + << " data: " << event->data.l; return true; } @@ -471,7 +472,6 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) : host_(widget_host), - enable_gpu_rendering_(false), about_to_validate_and_paint_(false), is_hidden_(false), is_loading_(false), @@ -485,11 +485,6 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) dragged_at_horizontal_edge_(0), dragged_at_vertical_edge_(0) { host_->set_view(this); - - // Enable experimental out-of-process GPU rendering. - CommandLine* command_line = CommandLine::ForCurrentProcess(); - enable_gpu_rendering_ = - command_line->HasSwitch(switches::kEnableGPURendering); } RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { @@ -749,38 +744,11 @@ bool RenderWidgetHostViewGtk::IsPopup() { BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( const gfx::Size& size) { - if (enable_gpu_rendering_) { - // Use a special GPU accelerated backing store. - if (!gpu_view_host_.get()) { - // Here we lazily make the GpuViewHost. This must be allocated when we - // have a native view realized, which happens sometime after creation - // when our owner puts us in the parent window. - DCHECK(GetNativeView()); - XID window_xid = x11_util::GetX11WindowFromGtkWidget(GetNativeView()); - gpu_view_host_.reset(new GpuViewHost(host_, window_xid)); - } - return gpu_view_host_->CreateBackingStore(size); - } - return new BackingStoreX(host_, size, x11_util::GetVisualFromGtkWidget(view_.get()), gtk_widget_get_visual(view_.get())->depth); } -VideoLayer* RenderWidgetHostViewGtk::AllocVideoLayer(const gfx::Size& size) { - if (enable_gpu_rendering_) { - // TODO(scherkus): is it possible for a video layer to be allocated before a - // backing store? - DCHECK(gpu_view_host_.get()) - << "AllocVideoLayer() called before AllocBackingStore()"; - return gpu_view_host_->CreateVideoLayer(size); - } - - return new VideoLayerX(host_, size, - x11_util::GetVisualFromGtkWidget(view_.get()), - gtk_widget_get_visual(view_.get())->depth); -} - void RenderWidgetHostViewGtk::SetBackground(const SkBitmap& background) { RenderWidgetHostView::SetBackground(background); host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); @@ -839,17 +807,6 @@ void RenderWidgetHostViewGtk::ModifyEventForEdgeDragging( } void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { - if (enable_gpu_rendering_) { - // When we're proxying painting, we don't actually display the web page - // ourselves. - if (gpu_view_host_.get()) - gpu_view_host_->OnWindowPainted(); - - // Erase the background. This will prevent a flash of black when resizing - // or exposing the window. White is usually better than black. - return; - } - // If the GPU process is rendering directly into the View, // call the compositor directly. RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); @@ -876,26 +833,11 @@ void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { // period where this object isn't attached to a window but hasn't been // Destroy()ed yet and it receives paint messages... if (window) { - gfx::Rect drop_shadow_area(0, 0, kMaxWindowWidth, - gtk_util::kInfoBarDropShadowHeight); - bool drop_shadow = host_->IsRenderView() && - static_cast<RenderViewHost*>(host_)->delegate()->GetViewDelegate()-> - ShouldDrawDropShadow() && - drop_shadow_area.Intersects(paint_rect); - - if (!visually_deemphasized_ && !drop_shadow) { + if (!visually_deemphasized_) { // In the common case, use XCopyArea. We don't draw more than once, so // we don't need to double buffer. backing_store->XShowRect( paint_rect, x11_util::GetX11WindowFromGtkWidget(view_.get())); - - // Paint the video layer using XCopyArea. - // TODO(scherkus): implement VideoLayerX::CairoShow() for grey - // blending. - VideoLayerX* video_layer = static_cast<VideoLayerX*>( - host_->video_layer()); - if (video_layer) - video_layer->XShow(x11_util::GetX11WindowFromGtkWidget(view_.get())); } else { // If the grey blend is showing, we make two drawing calls. Use double // buffering to prevent flicker. Use CairoShowRect because XShowRect @@ -915,15 +857,9 @@ void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { backing_store->CairoShowRect(damage_rect, GDK_DRAWABLE(window)); cairo_t* cr = gdk_cairo_create(window); - if (visually_deemphasized_) { - gdk_cairo_rectangle(cr, &rect); - cairo_set_source_rgba(cr, 0, 0, 0, 0.7); - cairo_fill(cr); - } - if (drop_shadow) { - gtk_util::DrawTopDropShadowForRenderView( - cr, gfx::Point(), damage_rect); - } + gdk_cairo_rectangle(cr, &rect); + cairo_set_source_rgba(cr, 0, 0, 0, 0.7); + cairo_fill(cr); cairo_destroy(cr); gdk_window_end_paint(window); diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index 099da46..1817569 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -21,7 +21,6 @@ #include "webkit/glue/webcursor.h" class RenderWidgetHost; -class GpuViewHost; class GtkIMContextWrapper; class GtkKeyBindingsHandler; #if !defined(TOOLKIT_VIEWS) @@ -82,7 +81,6 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { virtual void SelectionChanged(const std::string& text); virtual void ShowingContextMenu(bool showing); virtual BackingStore* AllocBackingStore(const gfx::Size& size); - virtual VideoLayer* AllocVideoLayer(const gfx::Size& size); virtual void SetBackground(const SkBitmap& background); virtual void CreatePluginContainer(gfx::PluginWindowHandle id); virtual void DestroyPluginContainer(gfx::PluginWindowHandle id); @@ -138,12 +136,6 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { // The native UI widget. OwnedWidgetGtk view_; - // Cached value of --enable-gpu-rendering for out-of-process painting. - bool enable_gpu_rendering_; - - // Non-NULL when we're doing out-of-process painting. - scoped_ptr<GpuViewHost> gpu_view_host_; - // This is true when we are currently painting and thus should handle extra // paint requests by expanding the invalid rect rather than actually // painting. diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index 45af5c0..154c0c5 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -21,7 +21,6 @@ #include "chrome/common/edit_command.h" #include "third_party/WebKit/WebKit/chromium/public/WebCompositionUnderline.h" #include "webkit/glue/webcursor.h" -#include "webkit/glue/webmenuitem.h" @class AcceleratedPluginView; class RenderWidgetHostViewMac; @@ -207,14 +206,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual void SetTooltipText(const std::wstring& tooltip_text); virtual void SelectionChanged(const std::string& text); virtual BackingStore* AllocBackingStore(const gfx::Size& size); - virtual VideoLayer* AllocVideoLayer(const gfx::Size& size); virtual void SetTakesFocusOnlyOnMouseDown(bool flag); - virtual void ShowPopupWithItems(gfx::Rect bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector<WebMenuItem>& items, - bool right_aligned); virtual gfx::Rect GetWindowRect(); virtual gfx::Rect GetRootWindowRect(); virtual void SetActive(bool active); @@ -251,7 +243,8 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { int32 width, int32 height, TransportDIB::Handle transport_dib); - virtual void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window); + virtual void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window, + uint64 surface_id); virtual void GpuRenderingStateDidChange(); void DrawAcceleratedSurfaceInstance( CGLContextObj context, @@ -265,8 +258,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { void KillSelf(); - void set_parent_view(NSView* parent_view) { parent_view_ = parent_view; } - void SetTextInputActive(bool active); // Sends confirmed plugin IME text back to the renderer. @@ -274,6 +265,14 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { const std::string& selected_text() const { return selected_text_; } + void UpdateRootGpuViewVisibility(bool show_gpu_widget); + + // When rendering transitions from gpu to software, the gpu widget can't be + // hidden until the software backing store has been updated. This method + // checks if the GPU view needs to be hidden and hides it if necessary. It + // should be called after the software backing store has been painted to. + void HandleDelayedGpuViewHiding(); + // These member variables should be private, but the associated ObjC class // needs access to them and can't be made a friend. @@ -328,11 +327,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { bool IsVoiceOverRunning(); // The associated view. This is weak and is inserted into the view hierarchy - // to own this RenderWidgetHostViewMac object unless is_popup_menu_ is true. - // In that case, cocoa_view_ is never inserted into the view hierarchy, so - // the RenderWidgetHostViewMac will treat it as a strong reference and will - // release it when told to destroy (for example, because a pop-up menu has - // closed). + // to own this RenderWidgetHostViewMac object. RenderWidgetHostViewCocoa* cocoa_view_; // The cursor for the page. This is passed up from the renderer. @@ -344,22 +339,20 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { // true if the View is not visible. bool is_hidden_; - // True if the widget is a native popup menu. The renderer code calls this - // an "external popup." - bool is_popup_menu_; - // The text to be shown in the tooltip, supplied by the renderer. std::wstring tooltip_text_; // Factory used to safely scope delayed calls to ShutdownHost(). ScopedRunnableMethodFactory<RenderWidgetHostViewMac> shutdown_factory_; - // Used for positioning a popup menu. - NSView* parent_view_; - // selected text on the renderer. std::string selected_text_; + // When rendering transitions from gpu to software, the gpu widget can't be + // hidden until the software backing store has been updated. This variable is + // set when the gpu widget needs to be hidden once a paint is completed. + bool needs_gpu_visibility_update_after_repaint_; + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); }; diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index ffc4a92..d8cd696 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -41,7 +41,6 @@ #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/plugins/webplugin.h" #include "webkit/glue/webaccessibility.h" -#include "webkit/glue/webmenurunner_mac.h" #import "third_party/mozilla/ComplexTextInputPanel.h" using WebKit::WebInputEvent; @@ -284,9 +283,11 @@ static CVReturn DrawOneAcceleratedPluginCallback( // Called on a background thread. Synchronized via the CGL context lock. CGLLockContext(cglContext_); - // TODO(thakis): Pixel or view coordinates for size? - renderWidgetHostView_->DrawAcceleratedSurfaceInstance( - cglContext_, pluginHandle_, [self cachedSize]); + if (renderWidgetHostView_) { + // TODO(thakis): Pixel or view coordinates for size? + renderWidgetHostView_->DrawAcceleratedSurfaceInstance( + cglContext_, pluginHandle_, [self cachedSize]); + } CGLFlushDrawable(cglContext_); CGLUnlockContext(cglContext_); @@ -408,6 +409,17 @@ static CVReturn DrawOneAcceleratedPluginCallback( [self setCachedSize:newSize]; [super setFrameSize:newSize]; } + +- (BOOL)acceptsFirstResponder { + // Accept first responder if the first responder isn't the RWHVMac. + return [[self window] firstResponder] != [self superview]; +} + +- (BOOL)becomeFirstResponder { + // Delegate first responder to the RWHVMac. + [[self window] makeFirstResponder:[self superview]]; + return YES; +} @end // RenderWidgetHostView -------------------------------------------------------- @@ -438,9 +450,8 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) text_input_type_(WebKit::WebTextInputTypeNone), is_loading_(false), is_hidden_(false), - is_popup_menu_(false), shutdown_factory_(this), - parent_view_(NULL) { + needs_gpu_visibility_update_after_repaint_(false) { // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| goes away. // Since we autorelease it, our caller must put |native_view()| into the view // hierarchy right after calling us. @@ -676,45 +687,53 @@ void RenderWidgetHostViewMac::ImeCancelComposition() { void RenderWidgetHostViewMac::DidUpdateBackingStore( const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, const std::vector<gfx::Rect>& copy_rects) { - if (is_hidden_) - return; - - std::vector<gfx::Rect> rects(copy_rects); - - // Because the findbar might be open, we cannot use scrollRect:by: here. For - // now, simply mark all of scroll rect as dirty. - if (!scroll_rect.IsEmpty()) - rects.push_back(scroll_rect); - - for (size_t i = 0; i < rects.size(); ++i) { - NSRect ns_rect = [cocoa_view_ flipRectToNSRect:rects[i]]; - - if (about_to_validate_and_paint_) { - // As much as we'd like to use -setNeedsDisplayInRect: here, we can't. - // We're in the middle of executing a -drawRect:, and as soon as it - // returns Cocoa will clear its record of what needs display. We instead - // use |performSelector:| to call |setNeedsDisplayInRect:| after returning - // to the main loop, at which point |drawRect:| is no longer on the stack. - DCHECK([NSThread isMainThread]); - if (!call_set_needs_display_in_rect_pending_) { - [cocoa_view_ performSelector:@selector(callSetNeedsDisplayInRect) - withObject:nil - afterDelay:0]; - call_set_needs_display_in_rect_pending_ = true; - invalid_rect_ = ns_rect; + if (!is_hidden_) { + std::vector<gfx::Rect> rects(copy_rects); + + // Because the findbar might be open, we cannot use scrollRect:by: here. For + // now, simply mark all of scroll rect as dirty. + if (!scroll_rect.IsEmpty()) + rects.push_back(scroll_rect); + + for (size_t i = 0; i < rects.size(); ++i) { + NSRect ns_rect = [cocoa_view_ flipRectToNSRect:rects[i]]; + + if (about_to_validate_and_paint_) { + // As much as we'd like to use -setNeedsDisplayInRect: here, we can't. + // We're in the middle of executing a -drawRect:, and as soon as it + // returns Cocoa will clear its record of what needs display. We + // instead use |performSelector:| to call |setNeedsDisplayInRect:| + // after returning to the main loop, at which point |drawRect:| is no + // longer on the stack. + DCHECK([NSThread isMainThread]); + if (!call_set_needs_display_in_rect_pending_) { + [cocoa_view_ performSelector:@selector(callSetNeedsDisplayInRect) + withObject:nil + afterDelay:0]; + call_set_needs_display_in_rect_pending_ = true; + invalid_rect_ = ns_rect; + } else { + // The old invalid rect is probably invalid now, since the view has + // most likely been resized, but there's no harm in dirtying the + // union. In the limit, this becomes equivalent to dirtying the + // whole view. + invalid_rect_ = NSUnionRect(invalid_rect_, ns_rect); + } } else { - // The old invalid rect is probably invalid now, since the view has most - // likely been resized, but there's no harm in dirtying the union. In - // the limit, this becomes equivalent to dirtying the whole view. - invalid_rect_ = NSUnionRect(invalid_rect_, ns_rect); + [cocoa_view_ setNeedsDisplayInRect:ns_rect]; } - } else { - [cocoa_view_ setNeedsDisplayInRect:ns_rect]; } + + if (!about_to_validate_and_paint_) + [cocoa_view_ displayIfNeeded]; } + // If |about_to_validate_and_paint_| is set, then -drawRect: is on the stack + // and it's not allowed to call -setHidden on the accelerated view. In that + // case, -callSetNeedsDisplayInRect: will hide it later. + // If |about_to_validate_and_paint_| is not set, do it now. if (!about_to_validate_and_paint_) - [cocoa_view_ displayIfNeeded]; + HandleDelayedGpuViewHiding(); } void RenderWidgetHostViewMac::RenderViewGone() { @@ -732,37 +751,23 @@ void RenderWidgetHostViewMac::Destroy() { // time Destroy() was called. On the Mac we have to destroy all the popups // ourselves. - if (!is_popup_menu_) { - // Depth-first destroy all popups. Use ShutdownHost() to enforce - // deepest-first ordering. - for (NSView* subview in [cocoa_view_ subviews]) { - if ([subview isKindOfClass:[RenderWidgetHostViewCocoa class]]) { - [static_cast<RenderWidgetHostViewCocoa*>(subview) - renderWidgetHostViewMac]->ShutdownHost(); - } else if ([subview isKindOfClass:[AcceleratedPluginView class]]) { - [static_cast<AcceleratedPluginView*>(subview) - onRenderWidgetHostViewGone]; - } + // Depth-first destroy all popups. Use ShutdownHost() to enforce + // deepest-first ordering. + for (NSView* subview in [cocoa_view_ subviews]) { + if ([subview isKindOfClass:[RenderWidgetHostViewCocoa class]]) { + [static_cast<RenderWidgetHostViewCocoa*>(subview) + renderWidgetHostViewMac]->ShutdownHost(); + } else if ([subview isKindOfClass:[AcceleratedPluginView class]]) { + [static_cast<AcceleratedPluginView*>(subview) + onRenderWidgetHostViewGone]; } - - // We've been told to destroy. - [cocoa_view_ retain]; - [cocoa_view_ removeFromSuperview]; - [cocoa_view_ autorelease]; - } else { - // From the renderer's perspective, the pop-up menu is represented by a - // RenderWidget. The actual Mac implementation uses a native pop-up menu - // and doesn't actually make use of the RenderWidgetHostViewCocoa that - // was allocated to own it in its constructor. When the pop-up menu goes - // away, free the RenderWidgetHostViewCocoa. Its deallocation will result - // in this object's destruction. - - DCHECK([[cocoa_view_ subviews] count] == 0); - DCHECK([cocoa_view_ superview] == nil); - - [cocoa_view_ autorelease]; } + // We've been told to destroy. + [cocoa_view_ retain]; + [cocoa_view_ removeFromSuperview]; + [cocoa_view_ autorelease]; + // We get this call just before |render_widget_host_| deletes // itself. But we are owned by |cocoa_view_|, which may be retained // by some other code. Examples are TabContentsViewMac's @@ -804,89 +809,11 @@ BackingStore* RenderWidgetHostViewMac::AllocBackingStore( return new BackingStoreMac(render_widget_host_, size); } -VideoLayer* RenderWidgetHostViewMac::AllocVideoLayer( - const gfx::Size& size) { - NOTIMPLEMENTED(); - return NULL; -} - // Sets whether or not to accept first responder status. void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; } -// Display a popup menu for WebKit using Cocoa widgets. -void RenderWidgetHostViewMac::ShowPopupWithItems( - gfx::Rect bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector<WebMenuItem>& items, - bool right_aligned) { - is_popup_menu_ = true; - - // Retain the Cocoa view for the duration of the pop-up so that it can't - // be dealloced if my Destroy() method is called while the pop-up's up - // (which would in turn delete me, causing a crash once the -runMenuInView - // call returns. That's what was happening in <http://crbug.com/33250>). - scoped_nsobject<RenderWidgetHostViewCocoa> retainedCocoaView - ([cocoa_view_ retain]); - - NSRect view_rect = [cocoa_view_ bounds]; - NSRect parent_rect = [parent_view_ bounds]; - int y_offset = bounds.y() + bounds.height(); - NSRect position = NSMakeRect(bounds.x(), parent_rect.size.height - y_offset, - bounds.width(), bounds.height()); - - // Display the menu. - scoped_nsobject<WebMenuRunner> menu_runner; - menu_runner.reset([[WebMenuRunner alloc] initWithItems:items - fontSize:item_font_size - rightAligned:right_aligned]); - - { - // Make sure events can be pumped while the menu is up. - MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); - - // One of the events that could be pumped is |window.close()|. - // User-initiated event-tracking loops protect against this by - // setting flags in -[CrApplication sendEvent:], but since - // web-content menus are initiated by IPC message the setup has to - // be done manually. - chrome_application_mac::ScopedSendingEvent sendingEventScoper; - - // Now run a SYNCHRONOUS NESTED EVENT LOOP until the pop-up is finished. - [menu_runner runMenuInView:parent_view_ - withBounds:position - initialIndex:selected_item]; - } - - if (!render_widget_host_) { - // Bad news -- my Destroy() was called while I was off running the menu. - // Return ASAP, and the release of retainedCocoaView will dealloc my NSView, - // which will delete me (whew). - return; - } - - int window_num = [[parent_view_ window] windowNumber]; - NSEvent* event = - webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen], - window_num, item_height, - [menu_runner indexOfSelectedItem], - position, view_rect); - - if ([menu_runner menuItemWasChosen]) { - // Simulate a menu selection event. - const WebMouseEvent& mouse_event = - WebInputEventFactory::mouseEvent(event, cocoa_view_); - render_widget_host_->ForwardMouseEvent(mouse_event); - } else { - // Simulate a menu dismiss event. - NativeWebKeyboardEvent keyboard_event(event); - render_widget_host_->ForwardKeyboardEvent(keyboard_event); - } -} - void RenderWidgetHostViewMac::KillSelf() { if (shutdown_factory_.empty()) { [cocoa_view_ setHidden:YES]; @@ -1000,7 +927,7 @@ void RenderWidgetHostViewMac::AcceleratedSurfaceSetTransportDIB( } void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( - gfx::PluginWindowHandle window) { + gfx::PluginWindowHandle window, uint64 surface_id) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); PluginViewMap::iterator it = plugin_views_.find(window); DCHECK(plugin_views_.end() != it); @@ -1009,7 +936,7 @@ void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( } DCHECK([it->second isKindOfClass:[AcceleratedPluginView class]]); - plugin_container_manager_.SetSurfaceWasPaintedTo(window); + plugin_container_manager_.SetSurfaceWasPaintedTo(window, surface_id); AcceleratedPluginView* view = static_cast<AcceleratedPluginView*>(it->second); // The surface is hidden until its first paint, to not show gargabe. @@ -1018,16 +945,15 @@ void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( [view setSurfaceWasSwapped:YES]; } -void RenderWidgetHostViewMac::GpuRenderingStateDidChange() { - CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); +void RenderWidgetHostViewMac::UpdateRootGpuViewVisibility( + bool show_gpu_widget) { // Plugins are destroyed on page navigate. The compositor layer on the other // hand is created on demand and then stays alive until its renderer process // dies (usually on cross-domain navigation). Instead, only a flag // |is_gpu_rendering_active()| is flipped when the compositor output should be // shown/hidden. // Show/hide the view belonging to the compositor here. - plugin_container_manager_.set_gpu_rendering_active( - GetRenderWidgetHost()->is_gpu_rendering_active()); + plugin_container_manager_.set_gpu_rendering_active(show_gpu_widget); gfx::PluginWindowHandle root_handle = plugin_container_manager_.root_container_handle(); @@ -1039,10 +965,28 @@ void RenderWidgetHostViewMac::GpuRenderingStateDidChange() { } bool visible = plugin_container_manager_.SurfaceShouldBeVisible(root_handle); + [[it->second window] disableScreenUpdatesUntilFlush]; [it->second setHidden:!visible]; } } +void RenderWidgetHostViewMac::HandleDelayedGpuViewHiding() { + if (needs_gpu_visibility_update_after_repaint_) { + UpdateRootGpuViewVisibility(false); + needs_gpu_visibility_update_after_repaint_ = false; + } +} + +void RenderWidgetHostViewMac::GpuRenderingStateDidChange() { + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + if (GetRenderWidgetHost()->is_gpu_rendering_active()) { + UpdateRootGpuViewVisibility( + GetRenderWidgetHost()->is_gpu_rendering_active()); + } else { + needs_gpu_visibility_update_after_repaint_ = true; + } +} + void RenderWidgetHostViewMac::DrawAcceleratedSurfaceInstance( CGLContextObj context, gfx::PluginWindowHandle plugin_handle, @@ -1488,6 +1432,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { return; } + const NSUInteger kCtrlCmdKeyMask = NSControlKeyMask | NSCommandKeyMask; // Only send a corresponding key press event if there is no marked text. if (!hasMarkedText_) { if (!textInserted && textToBeInserted_.length() == 1) { @@ -1499,7 +1444,9 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { event.skip_in_browser = true; widgetHost->ForwardKeyboardEvent(event); } else if ((!textInserted || delayEventUntilAfterImeCompostion) && - editCommands_.empty() && [[theEvent characters] length] > 0) { + [[theEvent characters] length] > 0 && + (([theEvent modifierFlags] & kCtrlCmdKeyMask) || + (hasEditCommands_ && editCommands_.empty()))) { // We don't get insertText: calls if ctrl or cmd is down, or the key event // generates an insert command. So synthesize a keypress event for these // cases, unless the key event generated any other command. @@ -1570,6 +1517,8 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { [self setNeedsDisplayInRect:renderWidgetHostView_->invalid_rect_]; renderWidgetHostView_->call_set_needs_display_in_rect_pending_ = false; renderWidgetHostView_->invalid_rect_ = NSZeroRect; + + renderWidgetHostView_->HandleDelayedGpuViewHiding(); } // Fills with white the parts of the area to the right and bottom for |rect| @@ -1751,6 +1700,16 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { // See http://crbug.com/47209 [self cancelComposition]; + NSNumber* direction = [NSNumber numberWithUnsignedInteger: + [[self window] keyViewSelectionDirection]]; + NSDictionary* userInfo = + [NSDictionary dictionaryWithObject:direction + forKey:kSelectionDirection]; + [[NSNotificationCenter defaultCenter] + postNotificationName:kViewDidBecomeFirstResponder + object:self + userInfo:userInfo]; + return YES; } diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc index da4e99c..014c7fd 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc @@ -18,9 +18,7 @@ #include "base/task.h" #include "base/time.h" #include "chrome/browser/renderer_host/backing_store_x.h" -#include "chrome/browser/renderer_host/gpu_view_host.h" #include "chrome/browser/renderer_host/render_widget_host.h" -#include "chrome/browser/renderer_host/video_layer_x.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/render_messages.h" @@ -61,7 +59,6 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) : host_(host), - enable_gpu_rendering_(false), about_to_validate_and_paint_(false), is_hidden_(false), is_loading_(false), @@ -69,14 +66,10 @@ RenderWidgetHostViewViews::RenderWidgetHostViewViews(RenderWidgetHost* host) visually_deemphasized_(false) { SetFocusable(true); host_->set_view(this); - - // Enable experimental out-of-process GPU rendering. - CommandLine* command_line = CommandLine::ForCurrentProcess(); - enable_gpu_rendering_ = - command_line->HasSwitch(switches::kEnableGPURendering); } RenderWidgetHostViewViews::~RenderWidgetHostViewViews() { + RenderViewGone(); } void RenderWidgetHostViewViews::InitAsChild() { @@ -130,7 +123,7 @@ void RenderWidgetHostViewViews::SetSize(const gfx::Size& size) { if (requested_size_.width() != width || requested_size_.height() != height) { requested_size_ = gfx::Size(width, height); - SetBounds(GetViewBounds()); + SetBounds(x(), y(), requested_size_.width(), requested_size_.height()); host_->WasResized(); } } @@ -163,7 +156,6 @@ void RenderWidgetHostViewViews::Blur() { host_->Blur(); } - bool RenderWidgetHostViewViews::IsShowing() { return IsVisible(); } @@ -233,6 +225,7 @@ void RenderWidgetHostViewViews::DidUpdateBackingStore( } void RenderWidgetHostViewViews::RenderViewGone() { + GetRenderWidgetHost()->ViewDestroyed(); Destroy(); } @@ -266,19 +259,6 @@ bool RenderWidgetHostViewViews::IsPopup() { BackingStore* RenderWidgetHostViewViews::AllocBackingStore( const gfx::Size& size) { - if (enable_gpu_rendering_) { - // Use a special GPU accelerated backing store. - if (!gpu_view_host_.get()) { - // Here we lazily make the GpuViewHost. This must be allocated when we - // have a native view realized, which happens sometime after creation - // when our owner puts us in the parent window. - DCHECK(GetNativeView()); - XID window_xid = x11_util::GetX11WindowFromGtkWidget(GetNativeView()); - gpu_view_host_.reset(new GpuViewHost(host_, window_xid)); - } - return gpu_view_host_->CreateBackingStore(size); - } - return new BackingStoreX(host_, size, x11_util::GetVisualFromGtkWidget(native_view()), gtk_widget_get_visual(native_view())->depth); @@ -288,37 +268,12 @@ gfx::NativeView RenderWidgetHostViewViews::native_view() const { return GetWidget()->GetNativeView(); } -VideoLayer* RenderWidgetHostViewViews::AllocVideoLayer(const gfx::Size& size) { - if (enable_gpu_rendering_) { - // TODO(scherkus): is it possible for a video layer to be allocated before a - // backing store? - DCHECK(gpu_view_host_.get()) - << "AllocVideoLayer() called before AllocBackingStore()"; - return gpu_view_host_->CreateVideoLayer(size); - } - - return new VideoLayerX(host_, size, - x11_util::GetVisualFromGtkWidget(native_view()), - gtk_widget_get_visual(native_view())->depth); -} - void RenderWidgetHostViewViews::SetBackground(const SkBitmap& background) { RenderWidgetHostView::SetBackground(background); host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); } void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { - if (enable_gpu_rendering_) { - // When we're proxying painting, we don't actually display the web page - // ourselves. - if (gpu_view_host_.get()) - gpu_view_host_->OnWindowPainted(); - - // Erase the background. This will prevent a flash of black when resizing - // or exposing the window. White is usually better than black. - return; - } - // Don't do any painting if the GPU process is rendering directly // into the View. RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); @@ -330,7 +285,7 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { DCHECK(!about_to_validate_and_paint_); // TODO(anicolao): get the damage somehow - //invalid_rect_ = damage_rect; + // invalid_rect_ = damage_rect; invalid_rect_ = bounds(); about_to_validate_and_paint_ = true; BackingStoreX* backing_store = static_cast<BackingStoreX*>( @@ -351,15 +306,6 @@ void RenderWidgetHostViewViews::Paint(gfx::Canvas* canvas) { // we don't need to double buffer. backing_store->XShowRect( paint_rect, x11_util::GetX11WindowFromGtkWidget(native_view())); - - // Paint the video layer using XCopyArea. - // TODO(scherkus): implement VideoLayerX::CairoShow() for grey - // blending. - VideoLayerX* video_layer = static_cast<VideoLayerX*>( - host_->video_layer()); - if (video_layer) - video_layer->XShow( - x11_util::GetX11WindowFromGtkWidget(native_view())); } else { // If the grey blend is showing, we make two drawing calls. Use double // buffering to prevent flicker. Use CairoShowRect because XShowRect diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h index 6ba5d4a..0ef343e 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.h +++ b/chrome/browser/renderer_host/render_widget_host_view_views.h @@ -20,7 +20,6 @@ #include "webkit/glue/webcursor.h" class RenderWidgetHost; -class GpuViewHost; struct NativeWebKeyboardEvent; namespace WebKit { @@ -71,7 +70,6 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView, virtual void SelectionChanged(const std::string& text); virtual void ShowingContextMenu(bool showing); virtual BackingStore* AllocBackingStore(const gfx::Size& size); - virtual VideoLayer* AllocVideoLayer(const gfx::Size& size); virtual void SetBackground(const SkBitmap& background); virtual void CreatePluginContainer(gfx::PluginWindowHandle id); virtual void DestroyPluginContainer(gfx::PluginWindowHandle id); @@ -123,12 +121,6 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView, // The model object. RenderWidgetHost* host_; - // Cached value of --enable-gpu-rendering for out-of-process painting. - bool enable_gpu_rendering_; - - // Non-NULL when we're doing out-of-process painting. - scoped_ptr<GpuViewHost> gpu_view_host_; - // This is true when we are currently painting and thus should handle extra // paint requests by expanding the invalid rect rather than actually // painting. diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 0b66f0c..38bbee2 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/resource_bundle.h" +#include "app/win/scoped_prop.h" #include "base/command_line.h" #include "base/i18n/rtl.h" #include "base/metrics/histogram.h" @@ -23,7 +24,6 @@ #include "chrome/browser/plugin_process_host.h" #include "chrome/browser/renderer_host/backing_store.h" #include "chrome/browser/renderer_host/backing_store_win.h" -#include "chrome/browser/renderer_host/gpu_view_host.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/common/chrome_constants.h" @@ -310,13 +310,10 @@ void RenderWidgetHostViewWin::CreateWnd(HWND parent) { // this window. Used by the GPU process to validate window handles it // receives from renderer processes. int renderer_id = render_widget_host_->process()->id(); - SetProp(m_hWnd, - chrome::kChromiumRendererIdProperty, - reinterpret_cast<HANDLE>(renderer_id)); - - // Uncommenting this will enable experimental out-of-process painting. - // Contact brettw for more, - // gpu_view_host_.reset(new GpuViewHost(render_widget_host_, m_hWnd)); + props_.push_back( + new app::win::ScopedProp(m_hWnd, + chrome::kChromiumRendererIdProperty, + reinterpret_cast<HANDLE>(renderer_id))); } /////////////////////////////////////////////////////////////////////////////// @@ -789,17 +786,9 @@ void RenderWidgetHostViewWin::SetTooltipText(const std::wstring& tooltip_text) { BackingStore* RenderWidgetHostViewWin::AllocBackingStore( const gfx::Size& size) { - if (gpu_view_host_.get()) - return gpu_view_host_->CreateBackingStore(size); return new BackingStoreWin(render_widget_host_, size); } -VideoLayer* RenderWidgetHostViewWin::AllocVideoLayer( - const gfx::Size& size) { - NOTIMPLEMENTED(); - return NULL; -} - void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { RenderWidgetHostView::SetBackground(background); Send(new ViewMsg_SetBackground(render_widget_host_->routing_id(), @@ -840,12 +829,15 @@ LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { OnInputLangChange(0, 0); // Marks that window as supporting mouse-wheel messages rerouting so it is // scrolled when under the mouse pointer even if inactive. - views::SetWindowSupportsRerouteMouseWheel(m_hWnd); + props_.push_back(views::SetWindowSupportsRerouteMouseWheel(m_hWnd)); // Save away our HWND in the parent window as a property so that the // accessibility code can find it. - ::SetProp(GetParent(), kViewsNativeHostPropForAccessibility, m_hWnd); - ::SetProp(m_hWnd, kRenderWidgetHostViewKey, - static_cast<RenderWidgetHostView*>(this)); + props_.push_back(new app::win::ScopedProp( + GetParent(), kViewsNativeHostPropForAccessibility, + m_hWnd)); + props_.push_back(new app::win::ScopedProp( + m_hWnd, kRenderWidgetHostViewKey, + static_cast<RenderWidgetHostView*>(this))); return 0; } @@ -876,7 +868,7 @@ void RenderWidgetHostViewWin::OnDestroy() { // sequence as part of the usual cleanup when the plugin instance goes away. EnumChildWindows(m_hWnd, DetachPluginWindowsCallback, NULL); - ::RemoveProp(m_hWnd, kRenderWidgetHostViewKey); + props_.reset(); ResetTooltip(); TrackMouseLeave(false); @@ -885,16 +877,6 @@ void RenderWidgetHostViewWin::OnDestroy() { void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { DCHECK(render_widget_host_->process()->HasConnection()); - if (gpu_view_host_.get()) { - // When we're proxying painting, we don't actually display the web page - // ourselves. We clear it white in case the proxy window isn't visible - // yet we won't show gibberish. - CPaintDC paint_dc(m_hWnd); - FillRect(paint_dc.m_hDC, &paint_dc.m_ps.rcPaint, - static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); - return; - } - // If the GPU process is rendering directly into the View, // call the compositor directly. RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h index 9fbaf11..5d8c680 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.h +++ b/chrome/browser/renderer_host/render_widget_host_view_win.h @@ -15,6 +15,7 @@ #include "base/scoped_comptr_win.h" #include "base/scoped_ptr.h" +#include "base/scoped_vector.h" #include "base/task.h" #include "chrome/browser/accessibility/browser_accessibility_manager.h" #include "chrome/browser/ime_input.h" @@ -23,6 +24,12 @@ #include "chrome/common/notification_registrar.h" #include "webkit/glue/webcursor.h" +namespace app { +namespace win { +class ScopedProp; +} +} + namespace gfx { class Size; class Rect; @@ -34,7 +41,6 @@ class Message; class BackingStore; class RenderWidgetHost; -class GpuViewHost; typedef CWinTraits<WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> RenderWidgetHostHWNDTraits; @@ -149,7 +155,6 @@ class RenderWidgetHostViewWin virtual void Destroy(); virtual void SetTooltipText(const std::wstring& tooltip_text); virtual BackingStore* AllocBackingStore(const gfx::Size& size); - virtual VideoLayer* AllocVideoLayer(const gfx::Size& size); virtual void SetBackground(const SkBitmap& background); virtual bool ContainsNativeView(gfx::NativeView native_view) const; virtual void SetVisuallyDeemphasized(bool deemphasized); @@ -261,10 +266,6 @@ class RenderWidgetHostViewWin // The associated Model. RenderWidgetHost* render_widget_host_; - // If we're doing out-of-process painting, this member will be non-NULL, - // indicating the gpu view we're using for the painting. - scoped_ptr<GpuViewHost> gpu_view_host_; - // The cursor for the page. This is passed up from the renderer. WebCursor current_cursor_; @@ -343,6 +344,8 @@ class RenderWidgetHostViewWin // method. WebKit::WebTextInputType text_input_type_; + ScopedVector<app::win::ScopedProp> props_; + DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewWin); }; diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index a17b12b..6fd669e 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -78,15 +78,6 @@ #include "chrome/browser/renderer_host/offline_resource_handler.h" #endif -// Uncomment to enable logging of request traffic. -// #define LOG_RESOURCE_DISPATCHER_REQUESTS - -#ifdef LOG_RESOURCE_DISPATCHER_REQUESTS -# define RESOURCE_LOG(stuff) LOG(INFO) << stuff -#else -# define RESOURCE_LOG(stuff) -#endif - using base::Time; using base::TimeDelta; using base::TimeTicks; @@ -143,8 +134,8 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, // Check if the renderer is permitted to request the requested URL. if (!policy->CanRequestURL(child_id, request_data.url)) { - LOG(INFO) << "Denied unauthorized request for " << - request_data.url.possibly_invalid_spec(); + VLOG(1) << "Denied unauthorized request for " + << request_data.url.possibly_invalid_spec(); return false; } @@ -449,11 +440,13 @@ void ResourceDispatcherHost::BeginRequest( request->SetExtraRequestHeaders(headers); int load_flags = request_data.load_flags; - // EV certificate verification could be expensive. We don't want to spend - // time performing EV certificate verification on all resources because - // EV status is irrelevant to sub-frames and sub-resources. + // Although EV status is irrelevant to sub-frames and sub-resources, we have + // to perform EV certificate verification on all resources because an HTTP + // keep-alive connection created to load a sub-frame or a sub-resource could + // be reused to load a main frame. + load_flags |= net::LOAD_VERIFY_EV_CERT; if (request_data.resource_type == ResourceType::MAIN_FRAME) { - load_flags |= net::LOAD_VERIFY_EV_CERT | net::LOAD_MAIN_FRAME; + load_flags |= net::LOAD_MAIN_FRAME; } else if (request_data.resource_type == ResourceType::SUB_FRAME) { load_flags |= net::LOAD_SUB_FRAME; } @@ -462,7 +455,7 @@ void ResourceDispatcherHost::BeginRequest( if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) && !ChildProcessSecurityPolicy::GetInstance()-> CanReadRawCookies(child_id)) { - LOG(INFO) << "Denied unathorized request for raw headers"; + VLOG(1) << "Denied unathorized request for raw headers"; load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; } @@ -704,8 +697,8 @@ void ResourceDispatcherHost::BeginDownload( // Check if the renderer is permitted to request the requested URL. if (!ChildProcessSecurityPolicy::GetInstance()-> CanRequestURL(child_id, url)) { - LOG(INFO) << "Denied unauthorized download request for " << - url.possibly_invalid_spec(); + VLOG(1) << "Denied unauthorized download request for " + << url.possibly_invalid_spec(); return; } @@ -716,7 +709,7 @@ void ResourceDispatcherHost::BeginDownload( request_id_--; - scoped_refptr<ResourceHandler> handler = + scoped_refptr<ResourceHandler> handler( new DownloadResourceHandler(this, child_id, route_id, @@ -725,7 +718,7 @@ void ResourceDispatcherHost::BeginDownload( download_file_manager_.get(), request, prompt_for_save_location, - save_info); + save_info)); if (safe_browsing_->enabled()) { handler = CreateSafeBrowsingResourceHandler(handler, child_id, route_id, @@ -733,8 +726,8 @@ void ResourceDispatcherHost::BeginDownload( } if (!URLRequest::IsHandledURL(url)) { - LOG(INFO) << "Download request for unsupported protocol: " << - url.possibly_invalid_spec(); + VLOG(1) << "Download request for unsupported protocol: " + << url.possibly_invalid_spec(); return; } @@ -766,11 +759,11 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, // requests. Does nothing if they are already loaded. PluginService::GetInstance()->LoadChromePlugins(this); - scoped_refptr<ResourceHandler> handler = + scoped_refptr<ResourceHandler> handler( new SaveFileResourceHandler(child_id, route_id, url, - save_file_manager_.get()); + save_file_manager_.get())); request_id_--; bool known_proto = URLRequest::IsHandledURL(url); @@ -876,7 +869,7 @@ void ResourceDispatcherHost::PauseRequest(int child_id, } info->set_pause_count(pause_count); - RESOURCE_LOG("To pause (" << pause << "): " << i->second->url().spec()); + VLOG(1) << "To pause (" << pause << "): " << i->second->url().spec(); // If we're resuming, kick the request to start reading again. Run the read // asynchronously to avoid recursion problems. @@ -1006,7 +999,7 @@ void ResourceDispatcherHost::RemovePendingRequest( void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request, const GURL& new_url, bool* defer_redirect) { - RESOURCE_LOG("OnReceivedRedirect: " << request->url().spec()); + VLOG(1) << "OnReceivedRedirect: " << request->url().spec(); ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); DCHECK(request->status().is_success()); @@ -1014,8 +1007,8 @@ void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request, if (info->process_type() != ChildProcessInfo::PLUGIN_PROCESS && !ChildProcessSecurityPolicy::GetInstance()-> CanRequestURL(info->child_id(), new_url)) { - LOG(INFO) << "Denied unauthorized request for " << - new_url.possibly_invalid_spec(); + VLOG(1) << "Denied unauthorized request for " + << new_url.possibly_invalid_spec(); // Tell the renderer that this request was disallowed. CancelRequestInternal(request, false); @@ -1032,7 +1025,7 @@ void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request, return; } - scoped_refptr<ResourceResponse> response = new ResourceResponse; + scoped_refptr<ResourceResponse> response(new ResourceResponse); PopulateResourceResponse(request, info->replace_extension_localization_templates(), response); if (!info->resource_handler()->OnRequestRedirected(info->request_id(), @@ -1086,7 +1079,7 @@ void ResourceDispatcherHost::OnSSLCertificateError( void ResourceDispatcherHost::OnSetCookie(URLRequest* request, const std::string& cookie_line, bool blocked_by_policy) { - RESOURCE_LOG("OnSetCookie: " << request->url().spec()); + VLOG(1) << "OnSetCookie: " << request->url().spec(); int render_process_id, render_view_id; if (!RenderViewForRequest(request, &render_process_id, &render_view_id)) @@ -1099,10 +1092,10 @@ void ResourceDispatcherHost::OnSetCookie(URLRequest* request, } void ResourceDispatcherHost::OnResponseStarted(URLRequest* request) { - RESOURCE_LOG("OnResponseStarted: " << request->url().spec()); + VLOG(1) << "OnResponseStarted: " << request->url().spec(); ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); if (PauseRequestIfNeeded(info)) { - RESOURCE_LOG("OnResponseStarted pausing: " << request->url().spec()); + VLOG(1) << "OnResponseStarted pausing: " << request->url().spec(); return; } @@ -1118,7 +1111,7 @@ void ResourceDispatcherHost::OnResponseStarted(URLRequest* request) { } else { // Check if the handler paused the request in their OnResponseStarted. if (PauseRequestIfNeeded(info)) { - RESOURCE_LOG("OnResponseStarted pausing2: " << request->url().spec()); + VLOG(1) << "OnResponseStarted pausing2: " << request->url().spec(); return; } @@ -1132,7 +1125,7 @@ void ResourceDispatcherHost::OnResponseStarted(URLRequest* request) { bool ResourceDispatcherHost::CompleteResponseStarted(URLRequest* request) { ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); - scoped_refptr<ResourceResponse> response = new ResourceResponse; + scoped_refptr<ResourceResponse> response(new ResourceResponse); PopulateResourceResponse(request, info->replace_extension_localization_templates(), response); @@ -1176,7 +1169,7 @@ void ResourceDispatcherHost::CancelRequest(int child_id, void ResourceDispatcherHost::CancelRequestInternal(URLRequest* request, bool from_renderer) { - RESOURCE_LOG("CancelRequest: " << request->url().spec()); + VLOG(1) << "CancelRequest: " << request->url().spec(); // WebKit will send us a cancel for downloads since it no longer handles them. // In this case, ignore the cancel since we handle downloads in the browser. @@ -1347,7 +1340,7 @@ void ResourceDispatcherHost::ResumeRequest(const GlobalRequestID& request_id) { if (!info->is_paused()) return; - RESOURCE_LOG("Resuming: " << i->second->url().spec()); + VLOG(1) << "Resuming: " << i->second->url().spec(); info->set_is_paused(false); @@ -1395,7 +1388,7 @@ bool ResourceDispatcherHost::Read(URLRequest* request, int* bytes_read) { void ResourceDispatcherHost::OnReadCompleted(URLRequest* request, int bytes_read) { DCHECK(request); - RESOURCE_LOG("OnReadCompleted: " << request->url().spec()); + VLOG(1) << "OnReadCompleted: " << request->url().spec(); ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); // OnReadCompleted can be called without Read (e.g., for chrome:// URLs). @@ -1404,7 +1397,7 @@ void ResourceDispatcherHost::OnReadCompleted(URLRequest* request, if (PauseRequestIfNeeded(info)) { info->set_paused_read_bytes(bytes_read); - RESOURCE_LOG("OnReadCompleted pausing: " << request->url().spec()); + VLOG(1) << "OnReadCompleted pausing: " << request->url().spec(); return; } @@ -1434,8 +1427,8 @@ void ResourceDispatcherHost::OnReadCompleted(URLRequest* request, if (PauseRequestIfNeeded(info)) { info->set_paused_read_bytes(bytes_read); - RESOURCE_LOG("OnReadCompleted (CompleteRead) pausing: " << - request->url().spec()); + VLOG(1) << "OnReadCompleted (CompleteRead) pausing: " + << request->url().spec(); return; } @@ -1463,7 +1456,7 @@ bool ResourceDispatcherHost::CompleteRead(URLRequest* request, } void ResourceDispatcherHost::OnResponseCompleted(URLRequest* request) { - RESOURCE_LOG("OnResponseCompleted: " << request->url().spec()); + VLOG(1) << "OnResponseCompleted: " << request->url().spec(); ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); // If the load for a main frame has failed, track it in a histogram, diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index bc4ac2b..67cbe92 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -191,10 +191,6 @@ TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) { } #if !defined(OS_MACOSX) -#if defined(OS_WIN) -// http://crbug.com/32048 -#define CrossSiteAfterCrash FLAKY_CrossSiteAfterCrash -#endif // Tests that the onbeforeunload and onunload logic is shortcutted if the old // renderer is gone. In that case, we don't want to wait for the old renderer // to run the handlers. diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index cea0c94..fc8cc12 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -4,13 +4,7 @@ #include "chrome/browser/renderer_host/resource_message_filter.h" -#include "app/clipboard/clipboard.h" -#include "base/callback.h" #include "base/command_line.h" -#if defined(OS_POSIX) -#include "base/file_descriptor_posix.h" -#endif -#include "base/file_path.h" #include "base/file_util.h" #include "base/metrics/histogram.h" #include "base/process_util.h" @@ -21,18 +15,17 @@ #include "base/worker_pool.h" #include "chrome/browser/appcache/appcache_dispatcher_host.h" #include "chrome/browser/automation/automation_resource_message_filter.h" -#include "chrome/browser/browser_about_handler.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/child_process_security_policy.h" #include "chrome/browser/chrome_plugin_browsing_context.h" #include "chrome/browser/clipboard_dispatcher.h" #include "chrome/browser/device_orientation/dispatcher_host.h" -#include "chrome/browser/download/download_file.h" +#include "chrome/browser/download/download_types.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/file_system/file_system_dispatcher_host.h" #include "chrome/browser/file_system/file_system_host_context.h" -#include "chrome/browser/geolocation/geolocation_dispatcher_host.h" +#include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h" #include "chrome/browser/geolocation/geolocation_permission_context.h" #include "chrome/browser/gpu_process_host.h" #include "chrome/browser/host_zoom_map.h" @@ -44,20 +37,18 @@ #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/notifications_prefs_cache.h" -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/plugin_selection_policy.h" -#endif +#include "chrome/browser/platform_util.h" #include "chrome/browser/plugin_service.h" -#include "chrome/browser/plugin_updater.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/printing/print_job_manager.h" +#include "chrome/browser/plugin_process_host.h" #include "chrome/browser/printing/printer_query.h" +#include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/audio_renderer_host.h" #include "chrome/browser/renderer_host/blob_dispatcher_host.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" #include "chrome/browser/renderer_host/database_dispatcher_host.h" #include "chrome/browser/renderer_host/file_utilities_dispatcher_host.h" +#include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/renderer_host/render_view_host_notification_task.h" #include "chrome/browser/renderer_host/render_widget_helper.h" #include "chrome/browser/search_engines/search_provider_install_state_dispatcher_host.h" @@ -67,35 +58,22 @@ #include "chrome/browser/ui_thread_helpers.h" #include "chrome/browser/worker_host/message_port_dispatcher.h" #include "chrome/browser/worker_host/worker_service.h" -#include "chrome/common/child_process_host.h" -#include "chrome/common/chrome_plugin_lib.h" -#include "chrome/common/chrome_plugin_util.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/extensions/extension_message_bundle.h" -#if defined(OS_MACOSX) -#include "chrome/common/font_descriptor_mac.h" -#include "chrome/common/font_loader_mac.h" -#endif #include "chrome/common/notification_service.h" -#include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" #include "chrome/common/url_constants.h" -#include "chrome/common/worker_messages.h" -#include "gfx/native_widget_types.h" +#include "ipc/ipc_channel_handle.h" #include "net/base/cookie_monster.h" -#include "net/base/file_stream.h" #include "net/base/io_buffer.h" #include "net/base/keygen_handler.h" -#include "net/base/load_flags.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" #include "net/disk_cache/disk_cache.h" #include "net/http/http_cache.h" #include "net/http/http_network_layer.h" -#include "net/http/http_transaction_factory.h" #include "net/url_request/url_request_context.h" #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" #include "webkit/glue/context_menu.h" @@ -105,6 +83,23 @@ #include "webkit/glue/webcookie.h" #include "webkit/glue/webkit_glue.h" +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/plugin_selection_policy.h" +#endif +#if defined(OS_MACOSX) +#include "chrome/common/font_descriptor_mac.h" +#include "chrome/common/font_loader_mac.h" +#endif +#if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#endif +#if defined(OS_WIN) +#include "chrome/common/child_process_host.h" +#endif +#if defined(USE_TCMALLOC) +#include "chrome/browser/browser_about_handler.h" +#endif + using net::CookieStore; using WebKit::WebCache; @@ -200,6 +195,48 @@ class ClearCacheCompletion : public net::CompletionCallback { scoped_refptr<ResourceMessageFilter> filter_; }; +class OpenChannelToPluginCallback : public PluginProcessHost::Client { + public: + OpenChannelToPluginCallback(ResourceMessageFilter* filter, + IPC::Message* reply_msg) + : filter_(filter), + reply_msg_(reply_msg) { + } + + virtual int ID() { + return filter_->id(); + } + + virtual bool OffTheRecord() { + return filter_->off_the_record(); + } + + virtual void SetPluginInfo(const WebPluginInfo& info) { + info_ = info; + } + + virtual void OnChannelOpened(const IPC::ChannelHandle& handle) { + WriteReply(handle); + } + + virtual void OnError() { + WriteReply(IPC::ChannelHandle()); + } + + private: + void WriteReply(const IPC::ChannelHandle& handle) { + ViewHostMsg_OpenChannelToPlugin::WriteReplyParams(reply_msg_, + handle, + info_); + filter_->Send(reply_msg_); + delete this; + } + + scoped_refptr<ResourceMessageFilter> filter_; + IPC::Message* reply_msg_; + WebPluginInfo info_; +}; + } // namespace ResourceMessageFilter::ResourceMessageFilter( @@ -239,7 +276,7 @@ ResourceMessageFilter::ResourceMessageFilter( ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_dispatcher_host_( new speech_input::SpeechInputDispatcherHost(this->id()))), ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_dispatcher_host_( - GeolocationDispatcherHost::New( + GeolocationDispatcherHostOld::New( this->id(), profile->GetGeolocationPermissionContext()))), ALLOW_THIS_IN_INITIALIZER_LIST( search_provider_install_state_dispatcher_host_( @@ -463,6 +500,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { OnCheckNotificationPermission) IPC_MESSAGE_HANDLER(ViewHostMsg_GetMimeTypeFromExtension, OnGetMimeTypeFromExtension) + IPC_MESSAGE_HANDLER(ViewHostMsg_RevealFolderInOS, OnRevealFolderInOS) IPC_MESSAGE_HANDLER(ViewHostMsg_GetMimeTypeFromFile, OnGetMimeTypeFromFile) IPC_MESSAGE_HANDLER(ViewHostMsg_GetPreferredExtensionForMimeType, @@ -532,7 +570,27 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { return handled; } -void ResourceMessageFilter::OnDestruct() { +void ResourceMessageFilter::OnRevealFolderInOS(const FilePath& path) { +#if defined(OS_MACOSX) + const BrowserThread::ID kThreadID = BrowserThread::UI; +#else + const BrowserThread::ID kThreadID = BrowserThread::FILE; +#endif + if (!BrowserThread::CurrentlyOn(kThreadID)) { + // Only honor the request if appropriate persmissions are granted. + if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) + BrowserThread::PostTask( + kThreadID, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::OnRevealFolderInOS, path)); + return; + } + + DCHECK(BrowserThread::CurrentlyOn(kThreadID)); + platform_util::OpenItem(path); +} + +void ResourceMessageFilter::OnDestruct() const { BrowserThread::DeleteOnIOThread::Destruct(this); } @@ -787,16 +845,18 @@ void ResourceMessageFilter::OnGetPluginInfoOnFileThread( } void ResourceMessageFilter::OnGotPluginInfo(bool found, - WebPluginInfo info, + const WebPluginInfo& info, const std::string& actual_mime_type, const GURL& policy_url, IPC::Message* reply_msg) { ContentSetting setting = CONTENT_SETTING_DEFAULT; if (found) { - info.enabled = info.enabled && - plugin_service_->PrivatePluginAllowedForURL(info.path, policy_url); + WebPluginInfo info_copy = info; + info_copy.enabled = info_copy.enabled && + plugin_service_->PrivatePluginAllowedForURL(info_copy.path, policy_url); HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); - scoped_ptr<PluginGroup> group(PluginGroup::CopyOrCreatePluginGroup(info)); + scoped_ptr<PluginGroup> group( + PluginGroup::CopyOrCreatePluginGroup(info_copy)); std::string resource = group->identifier(); setting = map->GetContentSetting(policy_url, CONTENT_SETTINGS_TYPE_PLUGINS, @@ -811,7 +871,10 @@ void ResourceMessageFilter::OnGotPluginInfo(bool found, void ResourceMessageFilter::OnOpenChannelToPlugin(const GURL& url, const std::string& mime_type, IPC::Message* reply_msg) { - plugin_service_->OpenChannelToPlugin(this, url, mime_type, reply_msg); + plugin_service_->OpenChannelToPlugin( + url, + mime_type, + new OpenChannelToPluginCallback(this, reply_msg)); } void ResourceMessageFilter::OnLaunchNaCl( @@ -1050,8 +1113,7 @@ void ResourceMessageFilter::OnAllocateSharedMemoryBuffer( uint32 buffer_size, base::SharedMemoryHandle* handle) { base::SharedMemory shared_buf; - shared_buf.Create("", false, false, buffer_size); - if (!shared_buf.Map(buffer_size)) { + if (!shared_buf.CreateAndMapAnonymous(buffer_size)) { *handle = base::SharedMemory::NULLHandle(); NOTREACHED() << "Cannot map shared memory buffer"; return; @@ -1083,7 +1145,7 @@ void ResourceMessageFilter::OnResourceTypeStats( } void ResourceMessageFilter::OnResourceTypeStatsOnUIThread( - WebCache::ResourceTypeStats stats, base::ProcessId renderer_id) { + const WebCache::ResourceTypeStats& stats, base::ProcessId renderer_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); TaskManager::GetInstance()->model()->NotifyResourceTypeStats( renderer_id, stats); @@ -1463,7 +1525,7 @@ void ResourceMessageFilter::OnCacheableMetadataAvailable( http_transaction_factory()->GetCache(); DCHECK(cache); - scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(data.size()); + scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(data.size())); memcpy(buf->data(), &data.front(), data.size()); cache->WriteMetadata( url, base::Time::FromDoubleT(expected_response_time), buf, data.size()); @@ -1500,7 +1562,7 @@ void ResourceMessageFilter::OnKeygen(uint32 key_size_index, return; } - LOG(INFO) << "Dispatching keygen task to worker pool."; + VLOG(1) << "Dispatching keygen task to worker pool."; // Dispatch to worker pool, so we do not block the IO thread. if (!WorkerPool::PostTask( FROM_HERE, diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 97d3992..850306e 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -39,7 +39,7 @@ class DOMStorageDispatcherHost; class FileSystemDispatcherHost; class FileUtilitiesDispatcherHost; struct FontDescriptor; -class GeolocationDispatcherHost; +class GeolocationDispatcherHostOld; class HostZoomMap; class IndexedDBDispatcherHost; class NotificationsPrefsCache; @@ -107,7 +107,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, virtual void OnChannelError(); virtual void OnChannelClosing(); virtual bool OnMessageReceived(const IPC::Message& message); - virtual void OnDestruct(); + virtual void OnDestruct() const; // ResourceDispatcherHost::Receiver methods: virtual bool Send(IPC::Message* message); @@ -188,7 +188,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, const std::string& mime_type, IPC::Message* reply_msg); void OnGotPluginInfo(bool found, - WebPluginInfo info, + const WebPluginInfo& info, const std::string& actual_mime_type, const GURL& policy_url, IPC::Message* reply_msg); @@ -252,6 +252,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnGetWindowRect(gfx::NativeViewId window, IPC::Message* reply); void OnGetRootWindowRect(gfx::NativeViewId window, IPC::Message* reply); #endif + + void OnRevealFolderInOS(const FilePath& path); void OnGetMimeTypeFromExtension(const FilePath::StringType& ext, std::string* mime_type); void OnGetMimeTypeFromFile(const FilePath& file_path, @@ -282,8 +284,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, #endif void OnResourceTypeStats(const WebKit::WebCache::ResourceTypeStats& stats); - static void OnResourceTypeStatsOnUIThread(WebKit::WebCache::ResourceTypeStats, - base::ProcessId renderer_id); + static void OnResourceTypeStatsOnUIThread( + const WebKit::WebCache::ResourceTypeStats&, + base::ProcessId renderer_id); void OnV8HeapStats(int v8_memory_allocated, int v8_memory_used); static void OnV8HeapStatsOnUIThread(int v8_memory_allocated, @@ -479,7 +482,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, speech_input_dispatcher_host_; // Used to handle geolocation-related messages. - scoped_refptr<GeolocationDispatcherHost> geolocation_dispatcher_host_; + scoped_refptr<GeolocationDispatcherHostOld> geolocation_dispatcher_host_; // Used to handle search provider related messages. scoped_ptr<SearchProviderInstallStateDispatcherHost> diff --git a/chrome/browser/renderer_host/resource_request_details.cc b/chrome/browser/renderer_host/resource_request_details.cc new file mode 100644 index 0000000..20a255d --- /dev/null +++ b/chrome/browser/renderer_host/resource_request_details.cc @@ -0,0 +1,54 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/renderer_host/resource_request_details.h" + + +ResourceRequestDetails::ResourceRequestDetails(const URLRequest* request, + int cert_id) + : url_(request->url()), + original_url_(request->original_url()), + method_(request->method()), + referrer_(request->referrer()), + has_upload_(request->has_upload()), + load_flags_(request->load_flags()), + status_(request->status()), + ssl_cert_id_(cert_id), + ssl_cert_status_(request->ssl_info().cert_status) { + const ResourceDispatcherHostRequestInfo* info = + ResourceDispatcherHost::InfoForRequest(request); + DCHECK(info); + resource_type_ = info->resource_type(); + frame_origin_ = info->frame_origin(); + main_frame_origin_ = info->main_frame_origin(); + + // If request is from the worker process on behalf of a renderer, use + // the renderer process id, since it consumes the notification response + // such as ssl state etc. + const WorkerProcessHost::WorkerInstance* worker_instance = + WorkerService::GetInstance()->FindWorkerInstance(info->child_id()); + if (worker_instance) { + DCHECK(!worker_instance->worker_document_set()->IsEmpty()); + const WorkerDocumentSet::DocumentInfoSet& parents = + worker_instance->worker_document_set()->documents(); + // TODO(atwilson): need to notify all associated renderers in the case + // of ssl state change (http://crbug.com/25357). For now, just notify + // the first one (works for dedicated workers and shared workers with + // a single process). + origin_child_id_ = parents.begin()->renderer_id(); + } else { + origin_child_id_ = info->child_id(); + } +} + +ResourceRequestDetails::~ResourceRequestDetails() {} + +ResourceRedirectDetails::ResourceRedirectDetails(const URLRequest* request, + int cert_id, + const GURL& new_url) + : ResourceRequestDetails(request, cert_id), + new_url_(new_url) { +} + +ResourceRedirectDetails::~ResourceRedirectDetails() {} diff --git a/chrome/browser/renderer_host/resource_request_details.h b/chrome/browser/renderer_host/resource_request_details.h index 6af9f85..36f3456 100644 --- a/chrome/browser/renderer_host/resource_request_details.h +++ b/chrome/browser/renderer_host/resource_request_details.h @@ -24,43 +24,9 @@ class URLRequest; // Details about a resource request notification. class ResourceRequestDetails { public: - ResourceRequestDetails(const URLRequest* request, int cert_id) - : url_(request->url()), - original_url_(request->original_url()), - method_(request->method()), - referrer_(request->referrer()), - has_upload_(request->has_upload()), - load_flags_(request->load_flags()), - status_(request->status()), - ssl_cert_id_(cert_id), - ssl_cert_status_(request->ssl_info().cert_status) { - const ResourceDispatcherHostRequestInfo* info = - ResourceDispatcherHost::InfoForRequest(request); - DCHECK(info); - resource_type_ = info->resource_type(); - frame_origin_ = info->frame_origin(); - main_frame_origin_ = info->main_frame_origin(); + ResourceRequestDetails(const URLRequest* request, int cert_id); - // If request is from the worker process on behalf of a renderer, use - // the renderer process id, since it consumes the notification response - // such as ssl state etc. - const WorkerProcessHost::WorkerInstance* worker_instance = - WorkerService::GetInstance()->FindWorkerInstance(info->child_id()); - if (worker_instance) { - DCHECK(!worker_instance->worker_document_set()->IsEmpty()); - const WorkerDocumentSet::DocumentInfoSet& parents = - worker_instance->worker_document_set()->documents(); - // TODO(atwilson): need to notify all associated renderers in the case - // of ssl state change (http://crbug.com/25357). For now, just notify - // the first one (works for dedicated workers and shared workers with - // a single process). - origin_child_id_ = parents.begin()->renderer_id(); - } else { - origin_child_id_ = info->child_id(); - } - } - - virtual ~ResourceRequestDetails() {} + virtual ~ResourceRequestDetails(); const GURL& url() const { return url_; } const GURL& original_url() const { return original_url_; } @@ -97,9 +63,8 @@ class ResourceRedirectDetails : public ResourceRequestDetails { public: ResourceRedirectDetails(const URLRequest* request, int cert_id, - const GURL& new_url) - : ResourceRequestDetails(request, cert_id), - new_url_(new_url) {} + const GURL& new_url); + virtual ~ResourceRedirectDetails(); // The URL to which we are being redirected. const GURL& new_url() const { return new_url_; } diff --git a/chrome/browser/renderer_host/save_file_resource_handler.cc b/chrome/browser/renderer_host/save_file_resource_handler.cc index 38f83bd..d33e205 100644 --- a/chrome/browser/renderer_host/save_file_resource_handler.cc +++ b/chrome/browser/renderer_host/save_file_resource_handler.cc @@ -80,8 +80,8 @@ bool SaveFileResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, bool SaveFileResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { DCHECK(read_buffer_); // We are passing ownership of this buffer to the save file manager. - net::IOBuffer* buffer = NULL; - read_buffer_.swap(&buffer); + scoped_refptr<net::IOBuffer> buffer; + read_buffer_.swap(buffer); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, NewRunnableMethod(save_manager_, @@ -115,3 +115,5 @@ void SaveFileResourceHandler::set_content_length( const std::string& content_length) { base::StringToInt64(content_length, &content_length_); } + +SaveFileResourceHandler::~SaveFileResourceHandler() {} diff --git a/chrome/browser/renderer_host/save_file_resource_handler.h b/chrome/browser/renderer_host/save_file_resource_handler.h index ecd8a93..7475bef 100644 --- a/chrome/browser/renderer_host/save_file_resource_handler.h +++ b/chrome/browser/renderer_host/save_file_resource_handler.h @@ -21,32 +21,33 @@ class SaveFileResourceHandler : public ResourceHandler { const GURL& url, SaveFileManager* manager); - bool OnUploadProgress(int request_id, uint64 position, uint64 size); + // ResourceHandler Implementation: + virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); // Saves the redirected URL to final_url_, we need to use the original // URL to match original request. - bool OnRequestRedirected(int request_id, const GURL& url, - ResourceResponse* response, bool* defer); + virtual bool OnRequestRedirected(int request_id, const GURL& url, + ResourceResponse* response, bool* defer); // Sends the download creation information to the download thread. - bool OnResponseStarted(int request_id, ResourceResponse* response); + virtual bool OnResponseStarted(int request_id, ResourceResponse* response); // Pass-through implementation. - bool OnWillStart(int request_id, const GURL& url, bool* defer); + virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); // Creates a new buffer, which will be handed to the download thread for file // writing and deletion. - bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, - int min_size); + virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, + int min_size); // Passes the buffer to the download file writer. - bool OnReadCompleted(int request_id, int* bytes_read); + virtual bool OnReadCompleted(int request_id, int* bytes_read); - bool OnResponseCompleted(int request_id, - const URLRequestStatus& status, - const std::string& security_info); + virtual bool OnResponseCompleted(int request_id, + const URLRequestStatus& status, + const std::string& security_info); - void OnRequestClosed(); + virtual void OnRequestClosed(); // If the content-length header is not present (or contains something other // than numbers), StringToInt64 returns 0, which indicates 'unknown size' and @@ -58,7 +59,7 @@ class SaveFileResourceHandler : public ResourceHandler { } private: - ~SaveFileResourceHandler() {} + virtual ~SaveFileResourceHandler(); int save_id_; int render_process_id_; diff --git a/chrome/browser/renderer_host/site_instance.cc b/chrome/browser/renderer_host/site_instance.cc index b0f4386..c6a660d 100644 --- a/chrome/browser/renderer_host/site_instance.cc +++ b/chrome/browser/renderer_host/site_instance.cc @@ -190,7 +190,7 @@ GURL SiteInstance::GetEffectiveURL(Profile* profile, const GURL& url) { if (!profile || !profile->GetExtensionsService()) return url; - Extension* extension = + const Extension* extension = profile->GetExtensionsService()->GetExtensionByWebExtent(url); if (extension) { // If the URL is part of an extension's web extent, convert it to an diff --git a/chrome/browser/renderer_host/socket_stream_dispatcher_host.cc b/chrome/browser/renderer_host/socket_stream_dispatcher_host.cc index b99e70d..6fa3fb8 100644 --- a/chrome/browser/renderer_host/socket_stream_dispatcher_host.cc +++ b/chrome/browser/renderer_host/socket_stream_dispatcher_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -69,9 +69,8 @@ void SocketStreamDispatcherHost::OnConnected(net::SocketStream* socket, SocketStreamHost::GetSocketStreamHost(socket); DCHECK(socket_stream_host); int socket_id = socket_stream_host->socket_id(); - DLOG(INFO) << "SocketStreamDispatcherHost::OnConnected socket_id=" - << socket_id - << " max_pending_send_allowed=" << max_pending_send_allowed; + DVLOG(1) << "SocketStreamDispatcherHost::OnConnected socket_id=" << socket_id + << " max_pending_send_allowed=" << max_pending_send_allowed; if (socket_id == chrome_common_net::kNoSocketId) { LOG(ERROR) << "NoSocketId in OnConnected"; return; @@ -88,9 +87,8 @@ void SocketStreamDispatcherHost::OnSentData(net::SocketStream* socket, SocketStreamHost::GetSocketStreamHost(socket); DCHECK(socket_stream_host); int socket_id = socket_stream_host->socket_id(); - DLOG(INFO) << "SocketStreamDispatcherHost::OnSentData socket_id=" - << socket_id - << " amount_sent=" << amount_sent; + DVLOG(1) << "SocketStreamDispatcherHost::OnSentData socket_id=" << socket_id + << " amount_sent=" << amount_sent; if (socket_id == chrome_common_net::kNoSocketId) { LOG(ERROR) << "NoSocketId in OnReceivedData"; return; @@ -107,8 +105,8 @@ void SocketStreamDispatcherHost::OnReceivedData( SocketStreamHost::GetSocketStreamHost(socket); DCHECK(socket_stream_host); int socket_id = socket_stream_host->socket_id(); - DLOG(INFO) << "SocketStreamDispatcherHost::OnReceiveData socket_id=" - << socket_id; + DVLOG(1) << "SocketStreamDispatcherHost::OnReceiveData socket_id=" + << socket_id; if (socket_id == chrome_common_net::kNoSocketId) { LOG(ERROR) << "NoSocketId in OnReceivedData"; return; @@ -124,8 +122,7 @@ void SocketStreamDispatcherHost::OnClose(net::SocketStream* socket) { SocketStreamHost::GetSocketStreamHost(socket); DCHECK(socket_stream_host); int socket_id = socket_stream_host->socket_id(); - DLOG(INFO) << "SocketStreamDispatcherHost::OnClosed socket_id=" - << socket_id; + DVLOG(1) << "SocketStreamDispatcherHost::OnClosed socket_id=" << socket_id; if (socket_id == chrome_common_net::kNoSocketId) { LOG(ERROR) << "NoSocketId in OnClose"; return; @@ -135,8 +132,8 @@ void SocketStreamDispatcherHost::OnClose(net::SocketStream* socket) { // Message handlers called by OnMessageReceived. void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) { - DLOG(INFO) << "SocketStreamDispatcherHost::OnConnect url=" << url - << " socket_id=" << socket_id; + DVLOG(1) << "SocketStreamDispatcherHost::OnConnect url=" << url + << " socket_id=" << socket_id; DCHECK_NE(chrome_common_net::kNoSocketId, socket_id); DCHECK(receiver_); if (LookupHostMap(receiver_->id(), socket_id)) { @@ -148,13 +145,12 @@ void SocketStreamDispatcherHost::OnConnect(const GURL& url, int socket_id) { new SocketStreamHost(this, receiver_, socket_id); AddHostMap(receiver_->id(), socket_id, socket_stream_host); socket_stream_host->Connect(url); - DLOG(INFO) << "SocketStreamDispatcherHost::OnConnect -> " << socket_id; + DVLOG(1) << "SocketStreamDispatcherHost::OnConnect -> " << socket_id; } void SocketStreamDispatcherHost::OnSendData( int socket_id, const std::vector<char>& data) { - DLOG(INFO) << "SocketStreamDispatcherHost::OnSendData socket_id=" - << socket_id; + DVLOG(1) << "SocketStreamDispatcherHost::OnSendData socket_id=" << socket_id; DCHECK(receiver_); SocketStreamHost* socket_stream_host = LookupHostMap(receiver_->id(), socket_id); @@ -170,8 +166,7 @@ void SocketStreamDispatcherHost::OnSendData( } void SocketStreamDispatcherHost::OnCloseReq(int socket_id) { - DLOG(INFO) << "SocketStreamDispatcherHost::OnCloseReq socket_id=" - << socket_id; + DVLOG(1) << "SocketStreamDispatcherHost::OnCloseReq socket_id=" << socket_id; DCHECK(receiver_); SocketStreamHost* socket_stream_host = LookupHostMap(receiver_->id(), socket_id); diff --git a/chrome/browser/renderer_host/socket_stream_host.cc b/chrome/browser/renderer_host/socket_stream_host.cc index 51f7ec3..a6f8ddd 100644 --- a/chrome/browser/renderer_host/socket_stream_host.cc +++ b/chrome/browser/renderer_host/socket_stream_host.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,7 +31,7 @@ SocketStreamHost::SocketStreamHost( receiver_(receiver), socket_id_(socket_id) { DCHECK_NE(socket_id_, chrome_common_net::kNoSocketId); - LOG(INFO) << "SocketStreamHost: socket_id=" << socket_id_; + VLOG(1) << "SocketStreamHost: socket_id=" << socket_id_; } /* static */ @@ -46,15 +46,14 @@ SocketStreamHost::GetSocketStreamHost(net::SocketStream* socket) { } SocketStreamHost::~SocketStreamHost() { - LOG(INFO) << "SocketStreamHost destructed socket_id=" << socket_id_; - if (!receiver_->Send(new ViewMsg_SocketStream_Closed(socket_id_))) { + VLOG(1) << "SocketStreamHost destructed socket_id=" << socket_id_; + if (!receiver_->Send(new ViewMsg_SocketStream_Closed(socket_id_))) LOG(ERROR) << "ViewMsg_SocketStream_Closed failed."; - } socket_->DetachDelegate(); } void SocketStreamHost::Connect(const GURL& url) { - LOG(INFO) << "SocketStreamHost::Connect url=" << url; + VLOG(1) << "SocketStreamHost::Connect url=" << url; socket_ = net::SocketStreamJob::CreateSocketStreamJob(url, delegate_); URLRequestContextGetter* context_getter = Profile::GetDefaultRequestContext(); if (context_getter) @@ -64,17 +63,15 @@ void SocketStreamHost::Connect(const GURL& url) { } bool SocketStreamHost::SendData(const std::vector<char>& data) { - LOG(INFO) << "SocketStreamHost::SendData"; - if (!socket_) - return false; - return socket_->SendData(&data[0], data.size()); + VLOG(1) << "SocketStreamHost::SendData"; + return socket_ && socket_->SendData(&data[0], data.size()); } void SocketStreamHost::Close() { - LOG(INFO) << "SocketStreamHost::Close"; + VLOG(1) << "SocketStreamHost::Close"; if (!socket_) return; - return socket_->Close(); + socket_->Close(); } bool SocketStreamHost::Connected(int max_pending_send_allowed) { diff --git a/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc b/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc index 8fa9b11..2e7c56b 100644 --- a/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc +++ b/chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc @@ -5,6 +5,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/ref_counted.h" +#include "base/stringprintf.h" #include "chrome/browser/browser.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/extensions/extension_error_reporter.h" @@ -28,13 +29,28 @@ class RenderViewHostManagerTest : public InProcessBrowserTest { RenderViewHostManagerTest() { EnableDOMAutomation(); } + + std::string GetFileWithHostAndPortReplacement( + const std::string& original_path, + const net::HostPortPair& host_port_pair) const { + return StringPrintf("%s?replace_orig=%s&replace_new=%s", + original_path.c_str(), + kReplaceText_, + host_port_pair.ToString().c_str()); + } + + private: + static const char* const kReplaceText_; }; +// static +const char* const RenderViewHostManagerTest::kReplaceText_ = + "REPLACE_WITH_HOST_AND_PORT"; + // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer // and target=_blank should create a new SiteInstance. -// Disabled, http://crbug.com/60079. IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, - DISABLED_SwapProcessWithRelNoreferrerAndTargetBlank) { + SwapProcessWithRelNoreferrerAndTargetBlank) { // Start two servers with different sites. ASSERT_TRUE(test_server()->Start()); net::TestServer https_server_( @@ -43,8 +59,11 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ASSERT_TRUE(https_server_.Start()); // Load a page with links that open in a new window. - ui_test_utils::NavigateToURL(browser(), test_server()->GetURL( - "files/click-noreferrer-links.html")); + std::string replacement_path = GetFileWithHostAndPortReplacement( + "files/click-noreferrer-links.html", + https_server_.host_port_pair()); + ui_test_utils::NavigateToURL(browser(), + test_server()->GetURL(replacement_path)); // Get the original SiteInstance for later comparison. scoped_refptr<SiteInstance> orig_site_instance( @@ -76,9 +95,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Test for crbug.com/24447. Following a cross-site link with just // target=_blank should not create a new SiteInstance. -// Disabled, http://crbug.com/60078. IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, - DISABLED_DontSwapProcessWithOnlyTargetBlank) { + DontSwapProcessWithOnlyTargetBlank) { // Start two servers with different sites. ASSERT_TRUE(test_server()->Start()); net::TestServer https_server_( @@ -87,8 +105,11 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ASSERT_TRUE(https_server_.Start()); // Load a page with links that open in a new window. - ui_test_utils::NavigateToURL(browser(), test_server()->GetURL( - "files/click-noreferrer-links.html")); + std::string replacement_path = GetFileWithHostAndPortReplacement( + "files/click-noreferrer-links.html", + https_server_.host_port_pair()); + ui_test_utils::NavigateToURL(browser(), + test_server()->GetURL(replacement_path)); // Get the original SiteInstance for later comparison. scoped_refptr<SiteInstance> orig_site_instance( @@ -120,9 +141,8 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer // and no target=_blank should not create a new SiteInstance. -// Disabled, http://crbug.com/60077. IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, - DISABLED_DontSwapProcessWithOnlyRelNoreferrer) { + DontSwapProcessWithOnlyRelNoreferrer) { // Start two servers with different sites. ASSERT_TRUE(test_server()->Start()); net::TestServer https_server_( @@ -131,8 +151,11 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ASSERT_TRUE(https_server_.Start()); // Load a page with links that open in a new window. - ui_test_utils::NavigateToURL(browser(), test_server()->GetURL( - "files/click-noreferrer-links.html")); + std::string replacement_path = GetFileWithHostAndPortReplacement( + "files/click-noreferrer-links.html", + https_server_.host_port_pair()); + ui_test_utils::NavigateToURL(browser(), + test_server()->GetURL(replacement_path)); // Get the original SiteInstance for later comparison. scoped_refptr<SiteInstance> orig_site_instance( diff --git a/chrome/browser/renderer_host/test/test_backing_store.cc b/chrome/browser/renderer_host/test/test_backing_store.cc index d90c7fd..cf7e7fa 100644 --- a/chrome/browser/renderer_host/test/test_backing_store.cc +++ b/chrome/browser/renderer_host/test/test_backing_store.cc @@ -16,8 +16,7 @@ void TestBackingStore::PaintToBackingStore( RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously) { + const std::vector<gfx::Rect>& copy_rects) { } bool TestBackingStore::CopyFromBackingStore(const gfx::Rect& rect, diff --git a/chrome/browser/renderer_host/test/test_backing_store.h b/chrome/browser/renderer_host/test/test_backing_store.h index f9db76e..d8f257b 100644 --- a/chrome/browser/renderer_host/test/test_backing_store.h +++ b/chrome/browser/renderer_host/test/test_backing_store.h @@ -18,8 +18,7 @@ class TestBackingStore : public BackingStore { virtual void PaintToBackingStore(RenderProcessHost* process, TransportDIB::Id bitmap, const gfx::Rect& bitmap_rect, - const std::vector<gfx::Rect>& copy_rects, - bool* painted_synchronously); + const std::vector<gfx::Rect>& copy_rects); virtual bool CopyFromBackingStore(const gfx::Rect& rect, skia::PlatformCanvas* output); virtual void ScrollBackingStore(int dx, int dy, diff --git a/chrome/browser/renderer_host/test/test_render_view_host.cc b/chrome/browser/renderer_host/test/test_render_view_host.cc index ecc2426..f3988e1 100644 --- a/chrome/browser/renderer_host/test/test_render_view_host.cc +++ b/chrome/browser/renderer_host/test/test_render_view_host.cc @@ -114,12 +114,6 @@ BackingStore* TestRenderWidgetHostView::AllocBackingStore( return new TestBackingStore(rwh_, size); } -VideoLayer* TestRenderWidgetHostView::AllocVideoLayer( - const gfx::Size& size) { - NOTIMPLEMENTED(); - return NULL; -} - #if defined(OS_MACOSX) void TestRenderWidgetHostView::ShowPopupWithItems( @@ -167,7 +161,7 @@ void TestRenderWidgetHostView::AcceleratedSurfaceSetIOSurface( gfx::PluginWindowHandle window, int32 width, int32 height, - uint64 io_surface_identifier) { + uint64 surface_id) { } void TestRenderWidgetHostView::AcceleratedSurfaceSetTransportDIB( @@ -178,7 +172,7 @@ void TestRenderWidgetHostView::AcceleratedSurfaceSetTransportDIB( } void TestRenderWidgetHostView::AcceleratedSurfaceBuffersSwapped( - gfx::PluginWindowHandle window) { + gfx::PluginWindowHandle window, uint64 surface_id) { } void TestRenderWidgetHostView::GpuRenderingStateDidChange() { diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h index e3c9f39..fe58b68 100644 --- a/chrome/browser/renderer_host/test/test_render_view_host.h +++ b/chrome/browser/renderer_host/test/test_render_view_host.h @@ -25,6 +25,7 @@ class NavigationController; class SiteInstance; class TestingProfile; class TestTabContents; +struct WebMenuItem; struct ViewHostMsg_FrameNavigate_Params; // Utility function to initialize ViewHostMsg_NavigateParams_Params @@ -87,7 +88,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void PrepareToDestroy() {} virtual void SetTooltipText(const std::wstring& tooltip_text) {} virtual BackingStore* AllocBackingStore(const gfx::Size& size); - virtual VideoLayer* AllocVideoLayer(const gfx::Size& size); #if defined(OS_MACOSX) virtual void SetTakesFocusOnlyOnMouseDown(bool flag) {} virtual void ShowPopupWithItems(gfx::Rect bounds, @@ -111,13 +111,14 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void AcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window, int32 width, int32 height, - uint64 io_surface_identifier); + uint64 surface_id); virtual void AcceleratedSurfaceSetTransportDIB( gfx::PluginWindowHandle window, int32 width, int32 height, TransportDIB::Handle transport_dib); - virtual void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window); + virtual void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window, + uint64 surface_id); virtual void GpuRenderingStateDidChange(); #endif virtual void SetVisuallyDeemphasized(bool deemphasized) { } diff --git a/chrome/browser/renderer_host/video_layer.cc b/chrome/browser/renderer_host/video_layer.cc deleted file mode 100644 index 1555060..0000000 --- a/chrome/browser/renderer_host/video_layer.cc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/video_layer.h" - -VideoLayer::VideoLayer(RenderWidgetHost* widget, const gfx::Size& size) - : render_widget_host_(widget), - size_(size) { -} - -VideoLayer::~VideoLayer() { -} diff --git a/chrome/browser/renderer_host/video_layer.h b/chrome/browser/renderer_host/video_layer.h deleted file mode 100644 index 0d7d4f8..0000000 --- a/chrome/browser/renderer_host/video_layer.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_H_ -#define CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_H_ -#pragma once - -#include "app/surface/transport_dib.h" -#include "gfx/size.h" - -class RenderProcessHost; -class RenderWidgetHost; - -namespace gfx { -class Rect; -} - -// Represents a layer of YUV data owned by RenderWidgetHost and composited with -// the backing store. VideoLayer is responsible for converting to RGB as -// needed. -class VideoLayer { - public: - virtual ~VideoLayer(); - - RenderWidgetHost* render_widget_host() const { return render_widget_host_; } - const gfx::Size& size() { return size_; } - - // Copy the incoming bitmap into this video layer. |bitmap| contains YUV - // pixel data in YV12 format and must be the same dimensions as this video - // layer. |bitmap_rect| specifies the absolute position and destination size - // of the bitmap on the backing store. - virtual void CopyTransportDIB(RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect) = 0; - - protected: - // Can only be constructed via subclasses. - VideoLayer(RenderWidgetHost* widget, const gfx::Size& size); - - private: - // The owner of this video layer. - RenderWidgetHost* render_widget_host_; - - // The size of the video layer. - gfx::Size size_; - - DISALLOW_COPY_AND_ASSIGN(VideoLayer); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_H_ diff --git a/chrome/browser/renderer_host/video_layer_proxy.cc b/chrome/browser/renderer_host/video_layer_proxy.cc deleted file mode 100644 index 3df1d25..0000000 --- a/chrome/browser/renderer_host/video_layer_proxy.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/video_layer_proxy.h" - -#include "chrome/browser/gpu_process_host_ui_shim.h" -#include "chrome/browser/renderer_host/render_process_host.h" -#include "chrome/common/gpu_messages.h" -#include "gfx/rect.h" - -VideoLayerProxy::VideoLayerProxy(RenderWidgetHost* widget, - const gfx::Size& size, - GpuProcessHostUIShim* process_shim, - int32 routing_id) - : VideoLayer(widget, size), - process_shim_(process_shim), - routing_id_(routing_id) { - process_shim_->AddRoute(routing_id_, this); -} - -VideoLayerProxy::~VideoLayerProxy() { - process_shim_->RemoveRoute(routing_id_); -} - -void VideoLayerProxy::CopyTransportDIB(RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect) { - base::ProcessId process_id; -#if defined(OS_WIN) - process_id = ::GetProcessId(process->GetHandle()); -#elif defined(OS_POSIX) - process_id = process->GetHandle(); -#endif - - if (process_shim_->Send(new GpuMsg_PaintToVideoLayer( - routing_id_, process_id, bitmap, bitmap_rect))) { - } else { - // TODO(scherkus): what to do ?!?! - } -} - -void VideoLayerProxy::OnMessageReceived(const IPC::Message& msg) { - IPC_BEGIN_MESSAGE_MAP(VideoLayerProxy, msg) - IPC_MESSAGE_HANDLER(GpuHostMsg_PaintToVideoLayer_ACK, - OnPaintToVideoLayerACK) - IPC_END_MESSAGE_MAP_EX() -} - -void VideoLayerProxy::OnChannelConnected(int32 peer_pid) { -} - -void VideoLayerProxy::OnChannelError() { -} - -void VideoLayerProxy::OnPaintToVideoLayerACK() { - // TODO(scherkus): we may not need to ACK video layer updates at all. - NOTIMPLEMENTED(); -} diff --git a/chrome/browser/renderer_host/video_layer_proxy.h b/chrome/browser/renderer_host/video_layer_proxy.h deleted file mode 100644 index 4a4cc71..0000000 --- a/chrome/browser/renderer_host/video_layer_proxy.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_PROXY_H_ -#define CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_PROXY_H_ -#pragma once - -#include "chrome/browser/renderer_host/video_layer.h" -#include "ipc/ipc_channel.h" - -class GpuProcessHostUIShim; - -// Proxies YUV video layer data to the GPU process for rendering. -class VideoLayerProxy : public VideoLayer, public IPC::Channel::Listener { - public: - VideoLayerProxy(RenderWidgetHost* widget, const gfx::Size& size, - GpuProcessHostUIShim* process_shim, int32 routing_id); - virtual ~VideoLayerProxy(); - - // VideoLayer implementation. - virtual void CopyTransportDIB(RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect); - - // IPC::Channel::Listener implementation. - virtual void OnMessageReceived(const IPC::Message& message); - virtual void OnChannelConnected(int32 peer_pid); - virtual void OnChannelError(); - - private: - // Called when GPU process has finished painting the video layer. - void OnPaintToVideoLayerACK(); - - // GPU process receiving our proxied requests. - GpuProcessHostUIShim* process_shim_; - - // IPC routing ID to use when communicating with the GPU process. - int32 routing_id_; - - DISALLOW_COPY_AND_ASSIGN(VideoLayerProxy); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_PROXY_H_ diff --git a/chrome/browser/renderer_host/video_layer_x.cc b/chrome/browser/renderer_host/video_layer_x.cc deleted file mode 100644 index 09891b3..0000000 --- a/chrome/browser/renderer_host/video_layer_x.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/renderer_host/video_layer_x.h" - -#include "app/x11_util_internal.h" -#include "chrome/browser/renderer_host/render_process_host.h" -#include "media/base/yuv_convert.h" - - -// Assume that somewhere along the line, someone will do width * height * 4 -// with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = -// 2**29 and floor(sqrt(2**29)) = 23170. - -// Max height and width for layers -static const int kMaxVideoLayerSize = 23170; - -VideoLayerX::VideoLayerX(RenderWidgetHost* widget, - const gfx::Size& size, - void* visual, - int depth) - : VideoLayer(widget, size), - visual_(visual), - depth_(depth), - display_(x11_util::GetXDisplay()), - rgb_frame_size_(0) { - DCHECK(!size.IsEmpty()); - - // Create our pixmap + GC representing an RGB version of a video frame. - pixmap_ = XCreatePixmap(display_, x11_util::GetX11RootWindow(), - size.width(), size.height(), depth_); - pixmap_gc_ = XCreateGC(display_, pixmap_, 0, NULL); - pixmap_bpp_ = x11_util::BitsPerPixelForPixmapDepth(display_, depth_); -} - -VideoLayerX::~VideoLayerX() { - // In unit tests, |display_| may be NULL. - if (!display_) - return; - - XFreePixmap(display_, pixmap_); - XFreeGC(display_, static_cast<GC>(pixmap_gc_)); -} - -void VideoLayerX::CopyTransportDIB(RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect) { - if (!display_) - return; - - if (bitmap_rect.IsEmpty()) - return; - - if (bitmap_rect.size() != size()) { - LOG(ERROR) << "Scaled video layer not supported."; - return; - } - - // Save location and size of destination bitmap. - rgb_rect_ = bitmap_rect; - - const int width = bitmap_rect.width(); - const int height = bitmap_rect.height(); - const size_t new_rgb_frame_size = static_cast<size_t>(width * height * 4); - - if (width <= 0 || width > kMaxVideoLayerSize || - height <= 0 || height > kMaxVideoLayerSize) - return; - - // Lazy allocate |rgb_frame_|. - if (!rgb_frame_.get() || rgb_frame_size_ < new_rgb_frame_size) { - // TODO(scherkus): handle changing dimensions and re-allocating. - CHECK(size() == rgb_rect_.size()); - rgb_frame_.reset(new uint8[new_rgb_frame_size]); - rgb_frame_size_ = new_rgb_frame_size; - } - - TransportDIB* dib = process->GetTransportDIB(bitmap); - if (!dib) - return; - - // Perform colour space conversion. - const uint8* y_plane = reinterpret_cast<uint8*>(dib->memory()); - const uint8* u_plane = y_plane + width * height; - const uint8* v_plane = u_plane + ((width * height) >> 2); - media::ConvertYUVToRGB32(y_plane, - u_plane, - v_plane, - rgb_frame_.get(), - width, - height, - width, - width / 2, - width * 4, - media::YV12); - - // Draw ARGB frame onto our pixmap. - x11_util::PutARGBImage(display_, visual_, depth_, pixmap_, pixmap_gc_, - rgb_frame_.get(), width, height); -} - -void VideoLayerX::XShow(XID target) { - if (rgb_rect_.IsEmpty()) - return; - - XCopyArea(display_, pixmap_, target, static_cast<GC>(pixmap_gc_), - 0, 0, rgb_rect_.width(), rgb_rect_.height(), - rgb_rect_.x(), rgb_rect_.y()); -} diff --git a/chrome/browser/renderer_host/video_layer_x.h b/chrome/browser/renderer_host/video_layer_x.h deleted file mode 100644 index a12c7b4..0000000 --- a/chrome/browser/renderer_host/video_layer_x.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_X_H_ -#define CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_X_H_ -#pragma once - -#include "app/x11_util.h" -#include "base/scoped_ptr.h" -#include "chrome/browser/renderer_host/video_layer.h" -#include "gfx/rect.h" - -// Implements a YUV data layer using X to hold the RGB data. -class VideoLayerX : public VideoLayer { - public: - VideoLayerX(RenderWidgetHost* widget, const gfx::Size& size, void* visual, - int depth); - virtual ~VideoLayerX(); - - // VideoLayer implementation. - virtual void CopyTransportDIB(RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect); - - // Copy from the server-side video layer to the target window. - // Unlike BackingStore, we maintain the absolute position and destination - // size so passing in a rect is not required. - void XShow(XID target); - - private: - // X Visual to get RGB mask information. - void* const visual_; - // Depth of the target window. - int depth_; - // Connection to the X server where this video layer will be displayed. - Display* const display_; - - // Handle to the server side pixmap which is our video layer. - XID pixmap_; - // Graphics context for painting our video layer. - void* pixmap_gc_; - // Server side bits-per-pixel for |pixmap_|. - int pixmap_bpp_; - - // Most recently converted frame stored as 32-bit ARGB. - scoped_array<uint8> rgb_frame_; - size_t rgb_frame_size_; - - // Destination size and absolution position of the converted frame. - gfx::Rect rgb_rect_; - - DISALLOW_COPY_AND_ASSIGN(VideoLayerX); -}; - -#endif // CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_X_H_ diff --git a/chrome/browser/renderer_host/web_cache_manager.cc b/chrome/browser/renderer_host/web_cache_manager.cc index 88baa7b..a9262ed 100644 --- a/chrome/browser/renderer_host/web_cache_manager.cc +++ b/chrome/browser/renderer_host/web_cache_manager.cc @@ -248,7 +248,7 @@ bool WebCacheManager::AttemptTactic( return true; } -void WebCacheManager::AddToStrategy(std::set<int> renderers, +void WebCacheManager::AddToStrategy(const std::set<int>& renderers, AllocationTactic tactic, size_t extra_bytes_to_allocate, AllocationStrategy* strategy) { @@ -304,7 +304,7 @@ void WebCacheManager::EnactStrategy(const AllocationStrategy& strategy) { } } -void WebCacheManager::ClearRendederCache(std::set<int> renderers) { +void WebCacheManager::ClearRendederCache(const std::set<int>& renderers) { std::set<int>::const_iterator iter = renderers.begin(); for (; iter != renderers.end(); ++iter) { RenderProcessHost* host = RenderProcessHost::FromID(*iter); diff --git a/chrome/browser/renderer_host/web_cache_manager.h b/chrome/browser/renderer_host/web_cache_manager.h index 248363e..1bd266b 100644 --- a/chrome/browser/renderer_host/web_cache_manager.h +++ b/chrome/browser/renderer_host/web_cache_manager.h @@ -162,7 +162,7 @@ class WebCacheManager { // For each renderer in |renderers|, computes its allocation according to // |tactic| and add the result to |strategy|. Any |extra_bytes_to_allocate| // is divided evenly among the renderers. - void AddToStrategy(std::set<int> renderers, + void AddToStrategy(const std::set<int>& renderers, AllocationTactic tactic, size_t extra_bytes_to_allocate, AllocationStrategy* strategy); @@ -172,7 +172,7 @@ class WebCacheManager { void EnactStrategy(const AllocationStrategy& strategy); // Inform all |renderers| to clear their cache. - void ClearRendederCache(std::set<int> renderers); + void ClearRendederCache(const std::set<int>& renderers); // Check to see if any active renderers have fallen inactive. void FindInactiveRenderers(); diff --git a/chrome/browser/renderer_host/x509_user_cert_resource_handler.cc b/chrome/browser/renderer_host/x509_user_cert_resource_handler.cc index 1c61bea..9e1cccc 100644 --- a/chrome/browser/renderer_host/x509_user_cert_resource_handler.cc +++ b/chrome/browser/renderer_host/x509_user_cert_resource_handler.cc @@ -103,9 +103,9 @@ bool X509UserCertResourceHandler::OnResponseCompleted( // TODO(gauravsh): Verify that 'request_id' was actually a keygen form post // and only then import the certificate. AssembleResource(); - scoped_refptr<net::X509Certificate> cert = + scoped_refptr<net::X509Certificate> cert( net::X509Certificate::CreateFromBytes(resource_buffer_->data(), - content_length_); + content_length_)); // The handler will run the UI and delete itself when it's finished. new SSLAddCertHandler(request_, cert, render_process_host_id_, render_view_id_); |
