[M108 Migration] Segregate InputPicker into ewk independent base classes
[platform/framework/web/chromium-efl.git] / wrt / src / browser / wrt_input_picker.cc
1 // Copyright 2019 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
5 #include "wrt/src/browser/wrt_input_picker.h"
6
7 #include "content/browser/web_contents/web_contents_impl.h"
8
9 namespace wrt {
10
11 WRTInputPicker::WRTInputPicker(content::WebContents* web_contents,
12                                Evas_Object* evas_object,
13                                content::DateTimeChooserEfl* date_time_chooser)
14     : content::InputPickerBase(web_contents, evas_object, date_time_chooser),
15       web_contents_(web_contents) {}
16
17 void WRTInputPicker::ExecuteEditCommand(const char* command,
18                                         const char* value) {
19   if (!command || !web_contents_)
20     return;
21
22   content::WebContentsImpl* wc =
23       static_cast<content::WebContentsImpl*>(web_contents_);
24   if (!wc)
25     return;
26
27   if (auto* input_handler = wc->GetFocusedFrameWidgetInputHandler()) {
28     absl::optional<std::u16string> optional_value;
29     optional_value = value ? absl::make_optional(base::ASCIIToUTF16(value))
30                            : absl::nullopt;
31     input_handler->ExecuteEditCommand(std::string(command), optional_value);
32   }
33 }
34
35 }  // namespace wrt