Hello nigeltao,

I'd like you to do a code review.  Please execute
        g4 diff -c 11937340

or point your web browser to
        http://mondrian/11937340
(this changelist has been uploaded to Mondrian)

to review the following code:

Change 11937340 by n...@noel-gears on 2009/07/16 14:21:59 *pending*

        For file drag drop, add CPAPI (0.11) method to verify that
        the renderer has permission to access the drop files.
        
        PRESUBMIT=passed
        R=nigeltao
        [email protected]
        DELTA=24  (23 added, 0 deleted, 1 changed)
        OCL=11937340

Affected files ...

... 
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_cr.cc#3 
edit
... 
//depot/googleclient/gears/opensource/third_party/chrome/chrome_plugin_api.h#5 
edit

24 delta lines: 23 added, 0 deleted, 1 changed

Also consider running:
        g4 lint -c 11937340

which verifies that the changelist doesn't introduce new style violations.

If you can't do the review, please let me know as soon as possible.  During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately.  Visit
http://www/eng/code_review.html for more information.

This is a semiautomated message from "g4 mail".  Complaints or suggestions?
Mail [email protected].
Change 11937340 by n...@noel-gears on 2009/07/16 14:21:59 *pending*

        For file drag drop, add CPAPI (0.11) method to verify that
        the renderer has permission to access the drop files.
        
        OCL=11937340

Affected files ...

... 
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_cr.cc#3 
edit
... 
//depot/googleclient/gears/opensource/third_party/chrome/chrome_plugin_api.h#5 
edit

==== 
//depot/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_cr.cc#3 
- 
c:\Users\noel.GOOGLE\src-gears/googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_cr.cc
 ====
# action=edit type=text
--- googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_cr.cc       
2009-07-15 18:14:52.000000000 +1000
+++ googleclient/gears/opensource/gears/desktop/drag_and_drop_utils_cr.cc       
2009-07-21 17:49:35.000000000 +1000
@@ -91,12 +91,25 @@
     return true;
   }
 
+  bool AllowFileDrop(const char *file_drag_data) {
+    if (!BrowserSupportsAllowFileDrop())
+      return false;
+    if (browser().allow_file_drop(g_cpid, context_, file_drag_data))
+      return false;  // Failed.
+    return true;
+  }
+
   ~DragSession() {
     ReleaseTypeAndData();
   }
 
   static bool BrowserSupportsDragDrop() {
     static const CPB_GetDragDataFunc kFunc(browser().get_drag_data);
+    return kFunc != NULL;
+  }
+
+  static bool BrowserSupportsAllowFileDrop() {
+    static const CPB_AllowFileDropFunc kFunc(browser().allow_file_drop);
     return kFunc != NULL;
   }
 
@@ -242,6 +255,8 @@
   std::vector<std::string16> files;
   if (!Tokenize(UTF8ToString16(drag->data()), kDelimiter, &files))
     return false;
+  if (!drag->AllowFileDrop(drag->data()))
+    return false;
 
   LOG16((L"Dragging %lu files\n", files.size()));
   g_drag_files = files.size();
==== 
//depot/googleclient/gears/opensource/third_party/chrome/chrome_plugin_api.h#5 
- 
c:\Users\noel.GOOGLE\src-gears/googleclient/gears/opensource/third_party/chrome/chrome_plugin_api.h
 ====
# action=edit type=text
--- googleclient/gears/opensource/third_party/chrome/chrome_plugin_api.h        
2009-07-15 18:14:52.000000000 +1000
+++ googleclient/gears/opensource/third_party/chrome/chrome_plugin_api.h        
2009-07-16 18:28:07.000000000 +1000
@@ -59,7 +59,7 @@
 // The current version of the API, used by the 'version' field of CPPluginFuncs
 // and CPBrowserFuncs.
 #define CP_MAJOR_VERSION 0
-#define CP_MINOR_VERSION 10
+#define CP_MINOR_VERSION 11
 #define CP_VERSION       ((CP_MAJOR_VERSION << 8) | (CP_MINOR_VERSION))
 
 #define CP_GET_MAJOR_VERSION(version) ((version & 0xff00) >> 8)
@@ -472,6 +472,13 @@
 // HTML5-defined drop effects "move" and "link".
 typedef CPError (STDCALL *CPB_SetDropEffectFunc)(
     CPID id, CPBrowsingContext context, struct NPObject* event, int effect);
+
+// For drag type "Files", the drag data returned by CPB_GetDragDataFunc() is a
+// backspace delimited list of file paths.  Use this routine to pass that data
+// to the browser process to verify that the renderer has permission to access
+// the files.  Returns CPERR_SUCCESS if access is allowed.
+typedef CPError (STDCALL *CPB_AllowFileDropFunc)(
+    CPID id, CPBrowsingContext context, const char* file_drag_data);
 
 // Function table for issuing requests using via the other side's network 
stack.
 // For the plugin, this functions deal with issuing requests through the
@@ -549,6 +556,7 @@
   CPB_OpenFileDialogFunc open_file_dialog;
   CPB_GetDragDataFunc get_drag_data;
   CPB_SetDropEffectFunc set_drop_effect;
+  CPB_AllowFileDropFunc allow_file_drop;
 } CPBrowserFuncs;
 
 

Reply via email to