1f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// found in the LICENSE file.
4f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "media/cdm/key_system_names.h"
6f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
7f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include <string>
8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace media {
10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)const char kClearKey[] = "org.w3.clearkey";
12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)const char kExternalClearKey[] = "org.chromium.externalclearkey";
13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
14f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)static bool IsParentKeySystemOf(const std::string& parent_key_system,
15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                                const std::string& key_system) {
16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  std::string prefix = parent_key_system + '.';
17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  return key_system.substr(0, prefix.size()) == prefix;
18f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}
19f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
20f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)bool IsExternalClearKey(const std::string& key_system) {
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  return key_system == kExternalClearKey ||
22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)         IsParentKeySystemOf(kExternalClearKey, key_system);
23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}
24f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}  // namespace media
26