Pepper_47_C++_interfaces
extension_system_samsung_tizen.cc
Go to the documentation of this file.
1 // Copyright 2016 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 namespace {
8 const char kCheckPrivilegeOperationName[] = "check_ace_privilege";
9 const char kGetWindowIdOperationName[] = "get_window_id";
10 const char kSetIMERecommendedWordsName[] = "set_ime_recommended_words";
11 const char kSetIMERecommendedWordsTypeName[] = "set_ime_recommended_words_type";
12 } // namespace
13 
14 namespace pp {
16  const InstanceHandle& instance)
17  : ExtensionSystemSamsung(instance) {}
18 
20 
22  if (!privilege.is_string())
23  return false;
24  std::string privilege_string = privilege.AsString();
25  std::map<std::string, bool>::iterator it =
26  privileges_result_.find(privilege_string);
27  if (it != privileges_result_.end())
28  return it->second;
29  Var call_result = GenericSyncCall(kCheckPrivilegeOperationName, privilege);
30  bool has_privilege = false;
31  if (call_result.is_bool())
32  has_privilege = call_result.AsBool();
33  privileges_result_[privilege_string] = has_privilege;
34  return has_privilege;
35 }
36 
38  Var call_result = GenericSyncCall(kSetIMERecommendedWordsName, words);
39  if (call_result.is_bool())
40  return call_result.AsBool();
41  return false;
42 }
43 
45  bool should_enable) {
46  Var enable_var(should_enable);
47  Var call_result =
48  GenericSyncCall(kSetIMERecommendedWordsTypeName, enable_var);
49  if (call_result.is_bool())
50  return call_result.AsBool();
51  return false;
52 }
53 
55  // The 'dummy' variable is not used, but needed because of the signature
56  // of the get_window_id operation.
57  Var call_result = GenericSyncCall(kGetWindowIdOperationName, pp::Var());
58  if (call_result.is_number())
59  return call_result.AsInt();
60  return -1;
61 }
62 } // namespace pp
bool is_number() const
Definition: var.h:169
std::string AsString() const
Definition: var.cc:250
bool is_string() const
Definition: var.h:123
bool AsBool() const
Definition: var.cc:224
int32_t GetWindowId()
GetWindowId() returns the X window Id for the current window.
int32_t AsInt() const
Definition: var.cc:232
Var GenericSyncCall(const Var &operation_name, const Var &operation_data)
A generic type used for passing data types between the module and the page.
Definition: var.h:21
bool is_bool() const
Definition: var.h:118
ExtensionSystemSamsungTizen(const InstanceHandle &instance)