import json


def GetChromiumOwnedAddedDeps(input_api):
  """Return list of deps that were added into chromium owned deps list."""

  chromium_owned_deps_list_source = lambda x: (
    input_api.FilterSourceFile(x,
                               white_list=('THIRD_PARTY_CHROMIUM_DEPS.json',),
                               black_list=(r'^_',)))

  chromium_owned_deps_list = input_api.AffectedFiles(
      file_filter=chromium_owned_deps_list_source)
  modified_deps_file = next(iter(chromium_owned_deps_list), None)
  if not modified_deps_file:
    return []
  if modified_deps_file.Action() != 'M':
    return []
  prev_json = json.loads('\n'.join(modified_deps_file.OldContents()))
  new_json = json.loads('\n'.join(modified_deps_file.NewContents()))
  prev_deps_set = set(prev_json.get('dependencies', []))
  new_deps_set = set(new_json.get('dependencies', []))
  return list(new_deps_set.difference(prev_deps_set))