Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / components / view_manager / type_converters.cc
blob4f0d6ae83572f4d2ba75439fd0a0f6c17012c4f0
1 // Copyright 2015 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.
5 #include "components/view_manager/type_converters.h"
7 #include "base/basictypes.h"
8 #include "base/macros.h"
10 namespace mojo {
12 #define TEXT_INPUT_TYPE_ASSERT(NAME) \
13 COMPILE_ASSERT(static_cast<int32>(TEXT_INPUT_TYPE_##NAME) == \
14 static_cast<int32>(ui::TEXT_INPUT_TYPE_##NAME), \
15 text_input_type_should_match)
16 TEXT_INPUT_TYPE_ASSERT(NONE);
17 TEXT_INPUT_TYPE_ASSERT(TEXT);
18 TEXT_INPUT_TYPE_ASSERT(PASSWORD);
19 TEXT_INPUT_TYPE_ASSERT(SEARCH);
20 TEXT_INPUT_TYPE_ASSERT(EMAIL);
21 TEXT_INPUT_TYPE_ASSERT(NUMBER);
22 TEXT_INPUT_TYPE_ASSERT(TELEPHONE);
23 TEXT_INPUT_TYPE_ASSERT(URL);
24 TEXT_INPUT_TYPE_ASSERT(DATE);
25 TEXT_INPUT_TYPE_ASSERT(DATE_TIME);
26 TEXT_INPUT_TYPE_ASSERT(DATE_TIME_LOCAL);
27 TEXT_INPUT_TYPE_ASSERT(MONTH);
28 TEXT_INPUT_TYPE_ASSERT(TIME);
29 TEXT_INPUT_TYPE_ASSERT(WEEK);
30 TEXT_INPUT_TYPE_ASSERT(TEXT_AREA);
31 TEXT_INPUT_TYPE_ASSERT(LAST);
33 #define TEXT_INPUT_FLAG_ASSERT(NAME) \
34 COMPILE_ASSERT(static_cast<int32>(TEXT_INPUT_FLAG_##NAME) == \
35 static_cast<int32>(ui::TEXT_INPUT_FLAG_##NAME), \
36 text_input_flag_should_match)
37 TEXT_INPUT_FLAG_ASSERT(NONE);
38 TEXT_INPUT_FLAG_ASSERT(AUTO_COMPLETE_ON);
39 TEXT_INPUT_FLAG_ASSERT(AUTO_COMPLETE_OFF);
40 TEXT_INPUT_FLAG_ASSERT(AUTO_CORRECT_ON);
41 TEXT_INPUT_FLAG_ASSERT(AUTO_CORRECT_OFF);
42 TEXT_INPUT_FLAG_ASSERT(SPELL_CHECK_ON);
43 TEXT_INPUT_FLAG_ASSERT(SPELL_CHECK_OFF);
44 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_NONE);
45 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_CHARACTERS);
46 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_WORDS);
47 TEXT_INPUT_FLAG_ASSERT(AUTO_CAPITALIZE_SENTENCES);
48 TEXT_INPUT_FLAG_ASSERT(ALL);
50 // static
51 ui::TextInputType TypeConverter<ui::TextInputType, TextInputType>::Convert(
52 const TextInputType& input) {
53 return static_cast<ui::TextInputType>(input);
56 // static
57 ui::TextInputState
58 TypeConverter<ui::TextInputState, TextInputStatePtr>::Convert(
59 const TextInputStatePtr& input) {
60 return ui::TextInputState(ConvertTo<ui::TextInputType>(input->type),
61 input->flags,
62 input->text.To<std::string>(),
63 input->selection_start,
64 input->selection_end,
65 input->composition_start,
66 input->composition_end,
67 input->can_compose_inline);
70 } // namespace mojo