| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
| 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE | 16 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE |
| 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 23 * SUCH DAMAGE. | 23 * SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "web/ExternalDateTimeChooser.h" | 26 #include "web/ExternalDateTimeChooser.h" |
| 27 | 27 |
| 28 #include "core/InputTypeNames.h" | 28 #include "core/InputTypeNames.h" |
| 29 #include "core/html/forms/DateTimeChooserClient.h" | 29 #include "core/html/forms/DateTimeChooserClient.h" |
| 30 #include "core/page/ChromeClient.h" |
| 30 #include "platform/RuntimeEnabledFeatures.h" | 31 #include "platform/RuntimeEnabledFeatures.h" |
| 31 #include "platform/wtf/text/AtomicString.h" | 32 #include "platform/wtf/text/AtomicString.h" |
| 32 #include "public/web/WebDateTimeChooserCompletion.h" | 33 #include "public/web/WebDateTimeChooserCompletion.h" |
| 33 #include "public/web/WebDateTimeChooserParams.h" | 34 #include "public/web/WebDateTimeChooserParams.h" |
| 34 #include "public/web/WebViewClient.h" | 35 #include "public/web/WebViewClient.h" |
| 35 #include "web/ChromeClientImpl.h" | |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class WebDateTimeChooserCompletionImpl : public WebDateTimeChooserCompletion { | 39 class WebDateTimeChooserCompletionImpl : public WebDateTimeChooserCompletion { |
| 40 public: | 40 public: |
| 41 WebDateTimeChooserCompletionImpl(ExternalDateTimeChooser* chooser) | 41 WebDateTimeChooserCompletionImpl(ExternalDateTimeChooser* chooser) |
| 42 : chooser_(chooser) {} | 42 : chooser_(chooser) {} |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 void DidChooseValue(double value) override { | 45 void DidChooseValue(double value) override { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 DateTimeChooser::Trace(visitor); | 62 DateTimeChooser::Trace(visitor); |
| 63 } | 63 } |
| 64 | 64 |
| 65 ExternalDateTimeChooser::ExternalDateTimeChooser(DateTimeChooserClient* client) | 65 ExternalDateTimeChooser::ExternalDateTimeChooser(DateTimeChooserClient* client) |
| 66 : client_(client) { | 66 : client_(client) { |
| 67 DCHECK(!RuntimeEnabledFeatures::inputMultipleFieldsUIEnabled()); | 67 DCHECK(!RuntimeEnabledFeatures::inputMultipleFieldsUIEnabled()); |
| 68 DCHECK(client); | 68 DCHECK(client); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ExternalDateTimeChooser* ExternalDateTimeChooser::Create( | 71 ExternalDateTimeChooser* ExternalDateTimeChooser::Create( |
| 72 ChromeClientImpl* chrome_client, | 72 ChromeClient* chrome_client, |
| 73 WebViewClient* web_view_client, | 73 WebViewClient* web_view_client, |
| 74 DateTimeChooserClient* client, | 74 DateTimeChooserClient* client, |
| 75 const DateTimeChooserParameters& parameters) { | 75 const DateTimeChooserParameters& parameters) { |
| 76 DCHECK(chrome_client); | 76 DCHECK(chrome_client); |
| 77 ExternalDateTimeChooser* chooser = new ExternalDateTimeChooser(client); | 77 ExternalDateTimeChooser* chooser = new ExternalDateTimeChooser(client); |
| 78 if (!chooser->OpenDateTimeChooser(chrome_client, web_view_client, parameters)) | 78 if (!chooser->OpenDateTimeChooser(chrome_client, web_view_client, parameters)) |
| 79 chooser = nullptr; | 79 chooser = nullptr; |
| 80 return chooser; | 80 return chooser; |
| 81 } | 81 } |
| 82 | 82 |
| 83 static WebDateTimeInputType ToWebDateTimeInputType(const AtomicString& source) { | 83 static WebDateTimeInputType ToWebDateTimeInputType(const AtomicString& source) { |
| 84 if (source == InputTypeNames::date) | 84 if (source == InputTypeNames::date) |
| 85 return kWebDateTimeInputTypeDate; | 85 return kWebDateTimeInputTypeDate; |
| 86 if (source == InputTypeNames::datetime) | 86 if (source == InputTypeNames::datetime) |
| 87 return kWebDateTimeInputTypeDateTime; | 87 return kWebDateTimeInputTypeDateTime; |
| 88 if (source == InputTypeNames::datetime_local) | 88 if (source == InputTypeNames::datetime_local) |
| 89 return kWebDateTimeInputTypeDateTimeLocal; | 89 return kWebDateTimeInputTypeDateTimeLocal; |
| 90 if (source == InputTypeNames::month) | 90 if (source == InputTypeNames::month) |
| 91 return kWebDateTimeInputTypeMonth; | 91 return kWebDateTimeInputTypeMonth; |
| 92 if (source == InputTypeNames::time) | 92 if (source == InputTypeNames::time) |
| 93 return kWebDateTimeInputTypeTime; | 93 return kWebDateTimeInputTypeTime; |
| 94 if (source == InputTypeNames::week) | 94 if (source == InputTypeNames::week) |
| 95 return kWebDateTimeInputTypeWeek; | 95 return kWebDateTimeInputTypeWeek; |
| 96 return kWebDateTimeInputTypeNone; | 96 return kWebDateTimeInputTypeNone; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool ExternalDateTimeChooser::OpenDateTimeChooser( | 99 bool ExternalDateTimeChooser::OpenDateTimeChooser( |
| 100 ChromeClientImpl* chrome_client, | 100 ChromeClient* chrome_client, |
| 101 WebViewClient* web_view_client, | 101 WebViewClient* web_view_client, |
| 102 const DateTimeChooserParameters& parameters) { | 102 const DateTimeChooserParameters& parameters) { |
| 103 if (!web_view_client) | 103 if (!web_view_client) |
| 104 return false; | 104 return false; |
| 105 | 105 |
| 106 WebDateTimeChooserParams web_params; | 106 WebDateTimeChooserParams web_params; |
| 107 web_params.type = ToWebDateTimeInputType(parameters.type); | 107 web_params.type = ToWebDateTimeInputType(parameters.type); |
| 108 web_params.anchor_rect_in_screen = parameters.anchor_rect_in_screen; | 108 web_params.anchor_rect_in_screen = parameters.anchor_rect_in_screen; |
| 109 web_params.double_value = parameters.double_value; | 109 web_params.double_value = parameters.double_value; |
| 110 web_params.suggestions = parameters.suggestions; | 110 web_params.suggestions = parameters.suggestions; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 DateTimeChooserClient* client = client_; | 155 DateTimeChooserClient* client = client_; |
| 156 client_ = nullptr; | 156 client_ = nullptr; |
| 157 client->DidEndChooser(); | 157 client->DidEndChooser(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 AXObject* ExternalDateTimeChooser::RootAXObject() { | 160 AXObject* ExternalDateTimeChooser::RootAXObject() { |
| 161 return nullptr; | 161 return nullptr; |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |