Add support for excluding individual paths (matching a pattern) from the banned CPP functions check

Also add shell_browser_main.cc to the list of excluded paths for the ScopedAllowIO object. This file does the setup for layout tests which requires a fair number of IO.

BUG=none
[email protected]

Review URL: https://codereview.chromium.org/11419182

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169657 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index e9c4212..515b48c 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -129,6 +129,7 @@
        'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
       ),
       False,
+      (),
     ),
     (
       'ScopedAllowIO',
@@ -137,6 +138,9 @@
        'pool or the FILE thread instead.',
       ),
       True,
+      (
+        r"^content[\\\/]shell[\\\/]shell_browser_main\.cc$",
+      ),
     ),
     (
       'FilePathWatcher::Delegate',
@@ -145,6 +149,7 @@
        'interface instead.',
       ),
       False,
+      (),
     ),
     (
       'browser::FindAnyBrowser',
@@ -154,6 +159,7 @@
        'id. Talk to robertshield@ for more information.',
       ),
       True,
+      (),
     ),
     (
       'browser::FindOrCreateTabbedBrowser',
@@ -163,6 +169,7 @@
        'id. Talk to robertshield@ for more information.',
       ),
       True,
+      (),
     ),
     (
       'browser::FindTabbedBrowserDeprecated',
@@ -172,6 +179,7 @@
        'id. Talk to robertshield@ for more information.',
       ),
       True,
+      (),
     ),
     (
       'RunAllPending()',
@@ -180,6 +188,7 @@
        'to RunUntilIdle',
       ),
       True,
+      (),
     ),
 )
 
@@ -343,7 +352,15 @@
   file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm', '.h'))
   for f in input_api.AffectedFiles(file_filter=file_filter):
     for line_num, line in f.ChangedContents():
-      for func_name, message, error in _BANNED_CPP_FUNCTIONS:
+      for func_name, message, error, excluded_paths in _BANNED_CPP_FUNCTIONS:
+        def IsBlacklisted(affected_file, blacklist):
+          local_path = affected_file.LocalPath()
+          for item in blacklist:
+            if input_api.re.match(item, local_path):
+              return True
+          return False
+        if IsBlacklisted(f, excluded_paths):
+          continue
         if func_name in line:
           problems = warnings;
           if error: