OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/renderer_date_time_picker.h" | 5 #include "content/renderer/renderer_date_time_picker.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
| 9 #include "content/renderer/date_time_suggestion_builder.h" |
9 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
10 #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h" | 11 #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h" |
11 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" | 12 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" |
12 #include "third_party/WebKit/public/web/WebDateTimeInputType.h" | 13 #include "third_party/WebKit/public/web/WebDateTimeInputType.h" |
13 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
14 | 15 |
15 using blink::WebString; | 16 using blink::WebString; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 RendererDateTimePicker::~RendererDateTimePicker() { | 55 RendererDateTimePicker::~RendererDateTimePicker() { |
55 } | 56 } |
56 | 57 |
57 bool RendererDateTimePicker::Open() { | 58 bool RendererDateTimePicker::Open() { |
58 ViewHostMsg_DateTimeDialogValue_Params message; | 59 ViewHostMsg_DateTimeDialogValue_Params message; |
59 message.dialog_type = ToTextInputType(chooser_params_.type); | 60 message.dialog_type = ToTextInputType(chooser_params_.type); |
60 message.dialog_value = chooser_params_.doubleValue; | 61 message.dialog_value = chooser_params_.doubleValue; |
61 message.minimum = chooser_params_.minimum; | 62 message.minimum = chooser_params_.minimum; |
62 message.maximum = chooser_params_.maximum; | 63 message.maximum = chooser_params_.maximum; |
63 message.step = chooser_params_.step; | 64 message.step = chooser_params_.step; |
| 65 for (size_t i = 0; i < chooser_params_.suggestions.size(); i++) { |
| 66 message.suggestions.push_back( |
| 67 DateTimeSuggestionBuilder::Build(chooser_params_.suggestions[i])); |
| 68 } |
64 Send(new ViewHostMsg_OpenDateTimeDialog(routing_id(), message)); | 69 Send(new ViewHostMsg_OpenDateTimeDialog(routing_id(), message)); |
65 return true; | 70 return true; |
66 } | 71 } |
67 | 72 |
68 bool RendererDateTimePicker::OnMessageReceived( | 73 bool RendererDateTimePicker::OnMessageReceived( |
69 const IPC::Message& message) { | 74 const IPC::Message& message) { |
70 bool handled = true; | 75 bool handled = true; |
71 IPC_BEGIN_MESSAGE_MAP(RendererDateTimePicker, message) | 76 IPC_BEGIN_MESSAGE_MAP(RendererDateTimePicker, message) |
72 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceDateTime, OnReplaceDateTime) | 77 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceDateTime, OnReplaceDateTime) |
73 IPC_MESSAGE_HANDLER(ViewMsg_CancelDateTimeDialog, OnCancel) | 78 IPC_MESSAGE_HANDLER(ViewMsg_CancelDateTimeDialog, OnCancel) |
(...skipping 12 matching lines...) Expand all Loading... |
86 | 91 |
87 void RendererDateTimePicker::OnCancel() { | 92 void RendererDateTimePicker::OnCancel() { |
88 if (chooser_completion_) | 93 if (chooser_completion_) |
89 chooser_completion_->didCancelChooser(); | 94 chooser_completion_->didCancelChooser(); |
90 #if defined(OS_ANDROID) | 95 #if defined(OS_ANDROID) |
91 static_cast<RenderViewImpl*>(render_view())->DismissDateTimeDialog(); | 96 static_cast<RenderViewImpl*>(render_view())->DismissDateTimeDialog(); |
92 #endif | 97 #endif |
93 } | 98 } |
94 | 99 |
95 } // namespace content | 100 } // namespace content |
OLD | NEW |