Shaka Player Embedded
navigator.cc
Go to the documentation of this file.
1 // Copyright 2016 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/js/navigator.h"
16 
17 #include <utility>
18 
21 #include "src/js/js_error.h"
22 
23 namespace shaka {
24 namespace js {
25 
27 // \cond Doxygen_Skip
28 Navigator::~Navigator() {}
29 // \endcond Doxygen_Skip
30 
32  std::string key_system,
33  std::vector<eme::MediaKeySystemConfiguration> configs) {
34  // 1. If keySystem is the empty string, return a promise rejected with a
35  // newly created TypeError.
36  if (key_system.empty()) {
37  return Promise::Rejected(
38  JsError::TypeError("The keySystem parameter is empty."));
39  }
40 
41  // 2. If supportedConfigurations is empty, return a promise rejected with a
42  // newly created TypeError.
43  if (configs.empty()) {
44  return Promise::Rejected(
45  JsError::TypeError("The configuration parameter is empty."));
46  }
47 
48  // NA: 3. Let document be the calling context's Document.
49  // NA: 4. Let origin be the origin of document.
50 
51  // 5. Let promise be a new Promise.
52  Promise promise = Promise::PendingPromise();
53 
54  // 6. Run the following steps in parallel:
56  TaskPriority::Internal, "search eme registry",
57  eme::SearchRegistry(promise, std::move(key_system), std::move(configs)));
58 
59  // 7. Return promise.
60  return promise;
61 }
62 
63 
65  AddReadOnlyProperty("appName", &Navigator::app_name);
66  AddReadOnlyProperty("appCodeName", &Navigator::app_code_name);
67  AddReadOnlyProperty("appVersion", &Navigator::app_version);
68  AddReadOnlyProperty("platform", &Navigator::platform);
69  AddReadOnlyProperty("product", &Navigator::product);
70  AddReadOnlyProperty("productSub", &Navigator::product_sub);
71  AddReadOnlyProperty("vendor", &Navigator::vendor);
72  AddReadOnlyProperty("vendorSub", &Navigator::vendor_sub);
73  AddReadOnlyProperty("userAgent", &Navigator::user_agent);
74 
75  AddMemberFunction("requestMediaKeySystemAccess",
77 }
79 
80 } // namespace js
81 } // namespace shaka
const std::string vendor_sub
Definition: navigator.h:60
const std::string product
Definition: navigator.h:57
const std::string vendor
Definition: navigator.h:59
const std::string app_code_name
Definition: navigator.h:54
static Promise Rejected(const js::JsError &error)
Definition: promise.h:77
const std::string app_version
Definition: navigator.h:55
std::shared_ptr< ThreadEvent< impl::RetOf< Func > > > AddInternalTask(TaskPriority priority, const std::string &name, Func &&callback)
Definition: task_runner.h:219
const std::string product_sub
Definition: navigator.h:58
static Promise PendingPromise()
Definition: promise.h:54
const std::string platform
Definition: navigator.h:56
static JsError TypeError(const std::string &message)
Definition: js_error.cc:81
Promise RequestMediaKeySystemAccess(std::string key_system, std::vector< eme::MediaKeySystemConfiguration > configs)
Definition: navigator.cc:31
const std::string app_name
Definition: navigator.h:53
const std::string user_agent
Definition: navigator.h:61
TaskRunner * MainThread()