Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / renderer / renderer_clipboard_client.cc
index 9c47463..1e2953e 100644 (file)
@@ -7,6 +7,7 @@
 #include "content/renderer/renderer_clipboard_client.h"
 
 #include "base/memory/shared_memory.h"
+#include "base/numerics/safe_math.h"
 #include "base/strings/string16.h"
 #include "content/common/clipboard_messages.h"
 #include "content/public/renderer/content_renderer_client.h"
@@ -22,11 +23,11 @@ namespace {
 class RendererClipboardWriteContext : public ClipboardClient::WriteContext {
  public:
   RendererClipboardWriteContext();
-  virtual ~RendererClipboardWriteContext();
-  virtual void WriteBitmapFromPixels(ui::Clipboard::ObjectMap* objects,
-                                     const void* pixels,
-                                     const gfx::Size& size) OVERRIDE;
-  virtual void Flush(const ui::Clipboard::ObjectMap& objects) OVERRIDE;
+  ~RendererClipboardWriteContext() override;
+  void WriteBitmapFromPixels(ui::Clipboard::ObjectMap* objects,
+                             const void* pixels,
+                             const gfx::Size& size) override;
+  void Flush(const ui::Clipboard::ObjectMap& objects) override;
 
  private:
   scoped_ptr<base::SharedMemory> shared_buf_;
@@ -49,7 +50,13 @@ void RendererClipboardWriteContext::WriteBitmapFromPixels(
   if (shared_buf_)
     return;
 
-  uint32 buf_size = 4 * size.width() * size.height();
+  base::CheckedNumeric<uint32> checked_buf_size = 4;
+  checked_buf_size *= size.width();
+  checked_buf_size *= size.height();
+  if (!checked_buf_size.IsValid())
+    return;
+
+  uint32 buf_size = checked_buf_size.ValueOrDie();
 
   // Allocate a shared memory buffer to hold the bitmap bits.
   shared_buf_.reset(ChildThread::current()->AllocateSharedMemory(buf_size));
@@ -107,10 +114,9 @@ uint64 RendererClipboardClient::GetSequenceNumber(ui::ClipboardType type) {
   return sequence_number;
 }
 
-bool RendererClipboardClient::IsFormatAvailable(
-    const ui::Clipboard::FormatType& format,
-    ui::ClipboardType type) {
-  bool result;
+bool RendererClipboardClient::IsFormatAvailable(content::ClipboardFormat format,
+                                                ui::ClipboardType type) {
+  bool result = false;
   RenderThreadImpl::current()->Send(
       new ClipboardHostMsg_IsFormatAvailable(format, type, &result));
   return result;
@@ -134,12 +140,6 @@ void RendererClipboardClient::ReadText(ui::ClipboardType type,
       new ClipboardHostMsg_ReadText(type, result));
 }
 
-void RendererClipboardClient::ReadAsciiText(ui::ClipboardType type,
-                                            std::string* result) {
-  RenderThreadImpl::current()->Send(
-      new ClipboardHostMsg_ReadAsciiText(type, result));
-}
-
 void RendererClipboardClient::ReadHTML(ui::ClipboardType type,
                                        base::string16* markup,
                                        GURL* url, uint32* fragment_start,
@@ -156,7 +156,7 @@ void RendererClipboardClient::ReadRTF(ui::ClipboardType type,
 void RendererClipboardClient::ReadImage(ui::ClipboardType type,
                                         std::string* data) {
   base::SharedMemoryHandle image_handle;
-  uint32 image_size;
+  uint32 image_size = 0;
   RenderThreadImpl::current()->Send(
       new ClipboardHostMsg_ReadImage(type, &image_handle, &image_size));
   if (base::SharedMemory::IsHandleValid(image_handle)) {
@@ -173,12 +173,6 @@ void RendererClipboardClient::ReadCustomData(ui::ClipboardType clipboard_type,
       new ClipboardHostMsg_ReadCustomData(clipboard_type, type, data));
 }
 
-void RendererClipboardClient::ReadData(const ui::Clipboard::FormatType& format,
-                                       std::string* data) {
-  RenderThreadImpl::current()->Send(
-      new ClipboardHostMsg_ReadData(format, data));
-}
-
 ClipboardClient::WriteContext* RendererClipboardClient::CreateWriteContext() {
   return new RendererClipboardWriteContext;
 }