Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / renderer / renderer_clipboard_client.cc
index acbc6cd..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;
@@ -120,27 +126,22 @@ void RendererClipboardClient::Clear(ui::ClipboardType type) {
   RenderThreadImpl::current()->Send(new ClipboardHostMsg_Clear(type));
 }
 
-void RendererClipboardClient::ReadAvailableTypes(ui::ClipboardType type,
-                                                 std::vector<string16>* types,
-                                                 bool* contains_filenames) {
+void RendererClipboardClient::ReadAvailableTypes(
+    ui::ClipboardType type,
+    std::vector<base::string16>* types,
+    bool* contains_filenames) {
   RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadAvailableTypes(
       type, types, contains_filenames));
 }
 
 void RendererClipboardClient::ReadText(ui::ClipboardType type,
-                                       string16* result) {
+                                       base::string16* result) {
   RenderThreadImpl::current()->Send(
       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,
-                                       string16* markup,
+                                       base::string16* markup,
                                        GURL* url, uint32* fragment_start,
                                        uint32* fragment_end) {
   RenderThreadImpl::current()->Send(new ClipboardHostMsg_ReadHTML(
@@ -155,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)) {
@@ -166,18 +167,12 @@ void RendererClipboardClient::ReadImage(ui::ClipboardType type,
 }
 
 void RendererClipboardClient::ReadCustomData(ui::ClipboardType clipboard_type,
-                                             const string16& type,
-                                             string16* data) {
+                                             const base::string16& type,
+                                             base::string16* data) {
   RenderThreadImpl::current()->Send(
       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;
 }