- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / search_types.h
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 #ifndef CHROME_COMMON_SEARCH_TYPES_H_
6 #define CHROME_COMMON_SEARCH_TYPES_H_
7
8 // The Mode structure encodes the visual states encountered when interacting
9 // with the NTP and the Omnibox.
10 struct SearchMode {
11   // The visual state that applies to the current interaction.
12   enum Type {
13     // The default state means anything but the following states.
14     MODE_DEFAULT,
15
16     // On the NTP page and the NTP is ready to be displayed.
17     MODE_NTP,
18
19     // The Omnibox is modified in some way, either on the NTP or not.
20     MODE_SEARCH_SUGGESTIONS,
21
22     // On a search results page.
23     MODE_SEARCH_RESULTS,
24   };
25
26   // The kind of page from which the user initiated the current search.
27   enum Origin {
28     // The user is searching from some random page.
29     ORIGIN_DEFAULT = 0,
30
31     // The user is searching from the NTP.
32     ORIGIN_NTP,
33
34     // The user is searching from a search results page.
35     ORIGIN_SEARCH,
36   };
37
38   SearchMode() : mode(MODE_DEFAULT), origin(ORIGIN_DEFAULT) {
39   }
40
41   SearchMode(Type in_mode, Origin in_origin)
42       : mode(in_mode),
43         origin(in_origin) {
44   }
45
46   bool operator==(const SearchMode& rhs) const {
47     return mode == rhs.mode && origin == rhs.origin;
48   }
49
50   bool operator!=(const SearchMode& rhs) const {
51     return !(*this == rhs);
52   }
53
54   bool is_default() const {
55     return mode == MODE_DEFAULT;
56   }
57
58   bool is_ntp() const {
59     return mode == MODE_NTP;
60   }
61
62   bool is_search() const {
63     return mode == MODE_SEARCH_SUGGESTIONS || mode == MODE_SEARCH_RESULTS;
64   }
65
66   bool is_search_results() const {
67     return mode == MODE_SEARCH_RESULTS;
68   }
69
70   bool is_search_suggestions() const {
71     return mode == MODE_SEARCH_SUGGESTIONS;
72   }
73
74   bool is_origin_default() const {
75     return origin == ORIGIN_DEFAULT;
76   }
77
78   bool is_origin_search() const {
79     return origin == ORIGIN_SEARCH;
80   }
81
82   bool is_origin_ntp() const {
83     return origin == ORIGIN_NTP;
84   }
85
86   Type mode;
87   Origin origin;
88 };
89
90 #endif  // CHROME_COMMON_SEARCH_TYPES_H_