2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file view_logic_geolocation_support.cpp
18 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
21 #include "view_logic_geolocation_support.h"
23 #include <dpl/log/log.h>
24 #include <dpl/wrt-dao-ro/global_config.h>
25 #include <dpl/wrt-dao-ro/widget_dao_read_only.h>
26 #include <dpl/wrt-dao-ro/common_dao_types.h>
27 #include <popup-runner/PopupInvoker.h>
28 #include <view_logic_security_support.h>
31 const char * const GEOLOCATION_ASK_TITLE = "location info";
32 const char * const GEOLOCATION_ASK_MSG =
33 "Application requests your current location. Do you allow it?";
36 namespace ViewModule {
37 namespace GeolocationSupport {
39 bool askUserForPermission()
41 return Wrt::Popup::PopupInvoker().askYesNo(
42 GEOLOCATION_ASK_TITLE,
46 bool checkRequestedStateOfGeolocationFeature(WrtDB::WidgetDAOReadOnlyPtr dao)
48 WrtDB::DbWidgetFeature geolocationFeature;
49 geolocationFeature.name = DPL::FromASCIIString(
50 WrtDB::GlobalConfig::GetW3CGeolocationFeatureName() );
52 auto features = dao->getFeaturesList();
54 auto it = features.find(geolocationFeature);
56 if ( it != features.end() )
59 LogInfo("Feature rejected by ACE");
68 bool getLocalizationState(const DPL::String& tizenId, bool enableHighAccuracy)
70 LogDebug ("Get localization state");
72 WrtDB::WidgetDAOReadOnlyPtr dao(new WrtDB::WidgetDAOReadOnly(tizenId));
74 if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP)
76 return askUserForPermission();
79 return checkRequestedStateOfGeolocationFeature(dao) &&
80 ViewModule::SecuritySupport::geolocationACECheck(tizenId,
84 bool getGeolocationModuleState(const DPL::String& tizenId)
86 LogDebug ("Get geolocation state");
88 WrtDB::WidgetDAOReadOnlyPtr dao(new WrtDB::WidgetDAOReadOnly(tizenId));
90 if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP)
92 LogInfo("Geolocation enable for tizen app");
96 return checkRequestedStateOfGeolocationFeature(dao);
99 } // namespace GeolocationSupport
100 } // namespace ViewModule