| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/application/application_runner_chromium.h" | 5 #include "mojo/application/application_runner_chromium.h" |
| 6 #include "mojo/public/c/system/main.h" | 6 #include "mojo/public/c/system/main.h" |
| 7 #include "mojo/public/cpp/application/application_connection.h" | 7 #include "mojo/public/cpp/application/application_connection.h" |
| 8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
| 9 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 10 #include "services/prediction/dictionary_service.h" |
| 10 #include "services/prediction/prediction_service_impl.h" | 11 #include "services/prediction/prediction_service_impl.h" |
| 12 #include "services/prediction/touch_position_correction.h" |
| 11 | 13 |
| 12 namespace prediction { | 14 namespace prediction { |
| 13 | 15 |
| 14 PredictionServiceImpl::PredictionServiceImpl( | 16 PredictionServiceImpl::PredictionServiceImpl( |
| 15 mojo::InterfaceRequest<PredictionService> request) | 17 mojo::InterfaceRequest<PredictionService> request) |
| 16 : strong_binding_(this, request.Pass()) { | 18 : strong_binding_(this, request.Pass()) { |
| 19 touch_position_correction = new TouchPositionCorrection(); |
| 20 |
| 21 // Hardcoded qwerty keyboard proximity settings, parameters are: |
| 22 // locale, grid_width, grid_height, min_width, height, most_common_key_width, |
| 23 // most_common_key_height, sorted_keys, touch_position_correction |
| 24 proximity_settings = new ProximityInfoService("en", 32, 16, 348, 174, 29, 58, |
| 25 touch_position_correction); |
| 26 |
| 27 dictionary_service = new DictionaryService(); |
| 17 } | 28 } |
| 18 | 29 |
| 19 PredictionServiceImpl::~PredictionServiceImpl() { | 30 PredictionServiceImpl::~PredictionServiceImpl() { |
| 31 delete dictionary_service; |
| 32 delete touch_position_correction; |
| 33 delete proximity_settings; |
| 20 } | 34 } |
| 21 | 35 |
| 22 // PredictionService implementation | 36 // PredictionService implementation |
| 23 void PredictionServiceImpl::SetSettings(SettingsPtr settings) { | |
| 24 stored_settings_.correction_enabled = settings->correction_enabled; | |
| 25 stored_settings_.block_potentially_offensive = | |
| 26 settings->block_potentially_offensive; | |
| 27 stored_settings_.space_aware_gesture_enabled = | |
| 28 settings->space_aware_gesture_enabled; | |
| 29 } | |
| 30 | |
| 31 // only predict "cat" no matter what prediction_info | |
| 32 // has for now | |
| 33 void PredictionServiceImpl::GetPredictionList( | 37 void PredictionServiceImpl::GetPredictionList( |
| 34 PredictionInfoPtr prediction_info, | 38 PredictionInfoPtr prediction_info, |
| 35 const GetPredictionListCallback& callback) { | 39 const GetPredictionListCallback& callback) { |
| 36 mojo::String cat = "cat"; | 40 mojo::Array<mojo::String> prediction_list = |
| 37 mojo::Array<mojo::String> prediction_list; | 41 dictionary_service->GetDictionarySuggestion(prediction_info.Pass(), |
| 38 prediction_list.push_back(cat); | 42 proximity_settings); |
| 39 callback.Run(prediction_list.Pass()); | 43 callback.Run(prediction_list.Pass()); |
| 40 } | 44 } |
| 41 | 45 |
| 42 PredictionServiceDelegate::PredictionServiceDelegate() { | 46 PredictionServiceDelegate::PredictionServiceDelegate() { |
| 43 } | 47 } |
| 44 | 48 |
| 45 PredictionServiceDelegate::~PredictionServiceDelegate() { | 49 PredictionServiceDelegate::~PredictionServiceDelegate() { |
| 46 } | 50 } |
| 47 | 51 |
| 48 // mojo::ApplicationDelegate implementation | 52 // mojo::ApplicationDelegate implementation |
| (...skipping 10 matching lines...) Expand all Loading... |
| 59 new PredictionServiceImpl(request.Pass()); | 63 new PredictionServiceImpl(request.Pass()); |
| 60 } | 64 } |
| 61 | 65 |
| 62 } // namespace prediction | 66 } // namespace prediction |
| 63 | 67 |
| 64 MojoResult MojoMain(MojoHandle application_request) { | 68 MojoResult MojoMain(MojoHandle application_request) { |
| 65 mojo::ApplicationRunnerChromium runner( | 69 mojo::ApplicationRunnerChromium runner( |
| 66 new prediction::PredictionServiceDelegate()); | 70 new prediction::PredictionServiceDelegate()); |
| 67 return runner.Run(application_request); | 71 return runner.Run(application_request); |
| 68 } | 72 } |
| OLD | NEW |