Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: content/renderer/renderer_date_time_picker_impl.cc

Issue 11418295: Use WebCore:DateTimeChooser for date/time form types instead of considering them text fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/renderer_date_time_picker_impl.h"
6
7 #include "content/common/view_messages.h"
8 #include "content/renderer/render_view_impl.h"
9
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDateTimeChooserCom pletion.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDateTimeChooserPar ams.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
13
14 namespace content {
15
16 using WebKit::WebString;
17
18 RendererDateTimePickerImpl::RendererDateTimePickerImpl(
19 RenderViewImpl* sender,
20 const WebKit::WebDateTimeChooserParams& params,
21 WebKit::WebDateTimeChooserCompletion* completion)
22 : RenderViewObserver(sender),
23 chooser_params_(params),
24 chooser_completion_(completion) {
25 }
26
27 RendererDateTimePickerImpl::~RendererDateTimePickerImpl() {
28 }
29
30 bool RendererDateTimePickerImpl::Open() {
31 ViewHostMsg_TextInputState_Params p;
32 p.type = ExtractType(chooser_params_);
33 p.value = chooser_params_.currentValue.utf8();
34 p.show_ime_if_needed = true;
35 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p));
36 return true;
37 }
38
39 bool RendererDateTimePickerImpl::OnMessageReceived(
40 const IPC::Message& message) {
41 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(RendererDateTimePickerImpl, message)
43 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceAll, OnReplaceDateTime)
44 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClear)
45 IPC_MESSAGE_UNHANDLED(handled = false)
46 IPC_END_MESSAGE_MAP()
47 return handled;
48 }
49
50 void RendererDateTimePickerImpl::OnReplaceDateTime(string16 new_date) {
51 if (chooser_completion_) {
52 chooser_completion_->didChooseValue(new_date);
53 }
54 }
55
56 void RendererDateTimePickerImpl::OnClear() {
57 if (chooser_completion_ != NULL) {
bulach 2012/12/03 20:23:03 nit: like 51, s/!= NULL// also, both here and abo
Miguel Garcia 2012/12/04 10:40:43 Done.
58 chooser_completion_->didCancelChooser();
59 }
60 }
61
62 //static
63 ui::TextInputType RendererDateTimePickerImpl::ExtractType(
64 const WebKit::WebDateTimeChooserParams& source) {
65 // See the description of WebDateTimeChooserParams#type. The format
66 // is passed as a string so we decode it here.
67
68 // TODO(miguelg) Once https://bugs.webkit.org/show_bug.cgi?id=103746
69 // makes it into chromium this can be simplified.
70 static const WebString date = "date";
bulach 2012/12/03 20:23:03 nargh! :) can't have non-POD statics, they're nast
Miguel Garcia 2012/12/04 10:40:43 Argh sorry about that. I'll replace this 100% befo
Miguel Garcia 2012/12/04 11:20:13 yay! The WebKit change landed so I am using an enu
71 static const WebString date_time = "datetime";
72 static const WebString date_time_local = "datetime-local";
73 static const WebString month = "month";
74 static const WebString time = "time";
75 static const WebString week = "week";
76
77 if (source.type.equals(WebString::fromUTF8("date")))
78 return ui::TEXT_INPUT_TYPE_DATE;
79 if (source.type.equals(WebString::fromUTF8("datetime")))
80 return ui::TEXT_INPUT_TYPE_DATE_TIME;
81 if (source.type.equals(WebString::fromUTF8("datetime-local")))
82 return ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL;
83 if (source.type.equals(WebString::fromUTF8("month")))
84 return ui::TEXT_INPUT_TYPE_MONTH;
85 if (source.type.equals(WebString::fromUTF8("time")))
86 return ui::TEXT_INPUT_TYPE_TIME;
87 if (source.type.equals(WebString::fromUTF8("week")))
88 return ui::TEXT_INPUT_TYPE_WEEK;
bulach 2012/12/03 20:23:03 nit: wrong indentation on all "return" clauses
Miguel Garcia 2012/12/04 10:40:43 Done.
89 return ui::TEXT_INPUT_TYPE_NONE;
90 }
91
92 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698