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

Side by Side Diff: content/renderer/android/renderer_date_time_picker.cc

Issue 1474533004: Merge the DateTimeSuggestionBuilder in to the file that uses it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/date_time_suggestion_builder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/android/renderer_date_time_picker.h" 5 #include "content/renderer/android/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/date_time_suggestion.h"
8 #include "content/common/view_messages.h" 9 #include "content/common/view_messages.h"
9 #include "content/renderer/date_time_suggestion_builder.h"
10 #include "content/renderer/render_view_impl.h" 10 #include "content/renderer/render_view_impl.h"
11 #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h" 11 #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h"
12 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" 12 #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h"
13 #include "third_party/WebKit/public/web/WebDateTimeInputType.h" 13 #include "third_party/WebKit/public/web/WebDateTimeInputType.h"
14 #include "third_party/WebKit/public/web/WebDateTimeSuggestion.h"
14 #include "ui/base/ime/text_input_type.h" 15 #include "ui/base/ime/text_input_type.h"
15 16
16 using blink::WebString; 17 using blink::WebString;
17 18
18 namespace content { 19 namespace content {
19 20
21 namespace {
22
23 // Converts a |blink::WebDateTimeSuggestion| structure to |DateTimeSuggestion|.
24 DateTimeSuggestion ToDateTimeSuggestion(
25 const blink::WebDateTimeSuggestion& suggestion) {
26 DateTimeSuggestion result;
27 result.value = suggestion.value;
28 result.localized_value = suggestion.localizedValue;
29 result.label = suggestion.label;
30 return result;
31 }
32
33 } // namespace
34
20 static ui::TextInputType ToTextInputType(int type) { 35 static ui::TextInputType ToTextInputType(int type) {
21 switch (type) { 36 switch (type) {
22 case blink::WebDateTimeInputTypeDate: 37 case blink::WebDateTimeInputTypeDate:
23 return ui::TEXT_INPUT_TYPE_DATE; 38 return ui::TEXT_INPUT_TYPE_DATE;
24 break; 39 break;
25 case blink::WebDateTimeInputTypeDateTime: 40 case blink::WebDateTimeInputTypeDateTime:
26 return ui::TEXT_INPUT_TYPE_DATE_TIME; 41 return ui::TEXT_INPUT_TYPE_DATE_TIME;
27 break; 42 break;
28 case blink::WebDateTimeInputTypeDateTimeLocal: 43 case blink::WebDateTimeInputTypeDateTimeLocal:
29 return ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL; 44 return ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL;
(...skipping 27 matching lines...) Expand all
57 72
58 bool RendererDateTimePicker::Open() { 73 bool RendererDateTimePicker::Open() {
59 ViewHostMsg_DateTimeDialogValue_Params message; 74 ViewHostMsg_DateTimeDialogValue_Params message;
60 message.dialog_type = ToTextInputType(chooser_params_.type); 75 message.dialog_type = ToTextInputType(chooser_params_.type);
61 message.dialog_value = chooser_params_.doubleValue; 76 message.dialog_value = chooser_params_.doubleValue;
62 message.minimum = chooser_params_.minimum; 77 message.minimum = chooser_params_.minimum;
63 message.maximum = chooser_params_.maximum; 78 message.maximum = chooser_params_.maximum;
64 message.step = chooser_params_.step; 79 message.step = chooser_params_.step;
65 for (size_t i = 0; i < chooser_params_.suggestions.size(); i++) { 80 for (size_t i = 0; i < chooser_params_.suggestions.size(); i++) {
66 message.suggestions.push_back( 81 message.suggestions.push_back(
67 DateTimeSuggestionBuilder::Build(chooser_params_.suggestions[i])); 82 ToDateTimeSuggestion(chooser_params_.suggestions[i]));
68 } 83 }
69 Send(new ViewHostMsg_OpenDateTimeDialog(routing_id(), message)); 84 Send(new ViewHostMsg_OpenDateTimeDialog(routing_id(), message));
70 return true; 85 return true;
71 } 86 }
72 87
73 bool RendererDateTimePicker::OnMessageReceived( 88 bool RendererDateTimePicker::OnMessageReceived(
74 const IPC::Message& message) { 89 const IPC::Message& message) {
75 bool handled = true; 90 bool handled = true;
76 IPC_BEGIN_MESSAGE_MAP(RendererDateTimePicker, message) 91 IPC_BEGIN_MESSAGE_MAP(RendererDateTimePicker, message)
77 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceDateTime, OnReplaceDateTime) 92 IPC_MESSAGE_HANDLER(ViewMsg_ReplaceDateTime, OnReplaceDateTime)
78 IPC_MESSAGE_HANDLER(ViewMsg_CancelDateTimeDialog, OnCancel) 93 IPC_MESSAGE_HANDLER(ViewMsg_CancelDateTimeDialog, OnCancel)
79 IPC_MESSAGE_UNHANDLED(handled = false) 94 IPC_MESSAGE_UNHANDLED(handled = false)
80 IPC_END_MESSAGE_MAP() 95 IPC_END_MESSAGE_MAP()
81 return handled; 96 return handled;
82 } 97 }
83 98
84 void RendererDateTimePicker::OnReplaceDateTime(double value) { 99 void RendererDateTimePicker::OnReplaceDateTime(double value) {
85 if (chooser_completion_) 100 if (chooser_completion_)
86 chooser_completion_->didChooseValue(value); 101 chooser_completion_->didChooseValue(value);
87 static_cast<RenderViewImpl*>(render_view())->DismissDateTimeDialog(); 102 static_cast<RenderViewImpl*>(render_view())->DismissDateTimeDialog();
88 } 103 }
89 104
90 void RendererDateTimePicker::OnCancel() { 105 void RendererDateTimePicker::OnCancel() {
91 if (chooser_completion_) 106 if (chooser_completion_)
92 chooser_completion_->didCancelChooser(); 107 chooser_completion_->didCancelChooser();
93 static_cast<RenderViewImpl*>(render_view())->DismissDateTimeDialog(); 108 static_cast<RenderViewImpl*>(render_view())->DismissDateTimeDialog();
94 } 109 }
95 110
96 } // namespace content 111 } // namespace content
OLDNEW
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/date_time_suggestion_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698