Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / base / page_transition_types.h
blob4e54f92e518f88df31b08977c61c92b314c0c25e
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.
5 #ifndef UI_BASE_PAGE_TRANSITION_TYPES_H_
6 #define UI_BASE_PAGE_TRANSITION_TYPES_H_
8 #include "base/basictypes.h"
9 #include "ui/base/ui_base_export.h"
11 namespace ui {
13 // Types of transitions between pages. These are stored in the history
14 // database to separate visits, and are reported by the renderer for page
15 // navigations.
17 // WARNING: don't change these numbers. They are written directly into the
18 // history database, so future versions will need the same values to match
19 // the enums.
21 // A type is made of a core value and a set of qualifiers. A type has one
22 // core value and 0 or or more qualifiers.
24 // A Java counterpart will be generated for this enum.
25 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.base
26 enum PageTransition {
27 // User got to this page by clicking a link on another page.
28 PAGE_TRANSITION_LINK = 0,
30 // User got this page by typing the URL in the URL bar. This should not be
31 // used for cases where the user selected a choice that didn't look at all
32 // like a URL; see GENERATED below.
34 // We also use this for other "explicit" navigation actions.
35 PAGE_TRANSITION_TYPED = 1,
37 // User got to this page through a suggestion in the UI, for example)
38 // through the destinations page.
39 PAGE_TRANSITION_AUTO_BOOKMARK = 2,
41 // This is a subframe navigation. This is any content that is automatically
42 // loaded in a non-toplevel frame. For example, if a page consists of
43 // several frames containing ads, those ad URLs will have this transition
44 // type. The user may not even realize the content in these pages is a
45 // separate frame, so may not care about the URL (see MANUAL below).
46 PAGE_TRANSITION_AUTO_SUBFRAME = 3,
48 // For subframe navigations that are explicitly requested by the user and
49 // generate new navigation entries in the back/forward list. These are
50 // probably more important than frames that were automatically loaded in
51 // the background because the user probably cares about the fact that this
52 // link was loaded.
53 PAGE_TRANSITION_MANUAL_SUBFRAME = 4,
55 // User got to this page by typing in the URL bar and selecting an entry
56 // that did not look like a URL. For example, a match might have the URL
57 // of a Google search result page, but appear like "Search Google for ...".
58 // These are not quite the same as TYPED navigations because the user
59 // didn't type or see the destination URL.
60 // See also KEYWORD.
61 PAGE_TRANSITION_GENERATED = 5,
63 // This is a toplevel navigation. This is any content that is automatically
64 // loaded in a toplevel frame. For example, opening a tab to show the ASH
65 // screen saver, opening the devtools window, opening the NTP after the safe
66 // browsing warning, opening web-based dialog boxes are examples of
67 // AUTO_TOPLEVEL navigations.
68 PAGE_TRANSITION_AUTO_TOPLEVEL = 6,
70 // The user filled out values in a form and submitted it. NOTE that in
71 // some situations submitting a form does not result in this transition
72 // type. This can happen if the form uses script to submit the contents.
73 PAGE_TRANSITION_FORM_SUBMIT = 7,
75 // The user "reloaded" the page, either by hitting the reload button or by
76 // hitting enter in the address bar. NOTE: This is distinct from the
77 // concept of whether a particular load uses "reload semantics" (i.e.
78 // bypasses cached data). For this reason, lots of code needs to pass
79 // around the concept of whether a load should be treated as a "reload"
80 // separately from their tracking of this transition type, which is mainly
81 // used for proper scoring for consumers who care about how frequently a
82 // user typed/visited a particular URL.
84 // SessionRestore and undo tab close use this transition type too.
85 PAGE_TRANSITION_RELOAD = 8,
87 // The url was generated from a replaceable keyword other than the default
88 // search provider. If the user types a keyword (which also applies to
89 // tab-to-search) in the omnibox this qualifier is applied to the transition
90 // type of the generated url. TemplateURLModel then may generate an
91 // additional visit with a transition type of KEYWORD_GENERATED against the
92 // url 'http://' + keyword. For example, if you do a tab-to-search against
93 // wikipedia the generated url has a transition qualifer of KEYWORD, and
94 // TemplateURLModel generates a visit for 'wikipedia.org' with a transition
95 // type of KEYWORD_GENERATED.
96 PAGE_TRANSITION_KEYWORD = 9,
98 // Corresponds to a visit generated for a keyword. See description of
99 // KEYWORD for more details.
100 PAGE_TRANSITION_KEYWORD_GENERATED = 10,
102 // ADDING NEW CORE VALUE? Be sure to update the LAST_CORE and CORE_MASK
103 // values below. Also update CoreTransitionString().
104 PAGE_TRANSITION_LAST_CORE = PAGE_TRANSITION_KEYWORD_GENERATED,
105 PAGE_TRANSITION_CORE_MASK = 0xFF,
107 // Qualifiers
108 // Any of the core values above can be augmented by one or more qualifiers.
109 // These qualifiers further define the transition.
111 // A managed user attempted to visit a URL but was blocked.
112 PAGE_TRANSITION_BLOCKED = 0x00800000,
114 // User used the Forward or Back button to navigate among browsing history.
115 PAGE_TRANSITION_FORWARD_BACK = 0x01000000,
117 // User used the address bar to trigger this navigation.
118 PAGE_TRANSITION_FROM_ADDRESS_BAR = 0x02000000,
120 // User is navigating to the home page.
121 PAGE_TRANSITION_HOME_PAGE = 0x04000000,
123 // The transition originated from an external application; the exact
124 // definition of this is embedder dependent.
125 PAGE_TRANSITION_FROM_API = 0x08000000,
127 // The beginning of a navigation chain.
128 PAGE_TRANSITION_CHAIN_START = 0x10000000,
130 // The last transition in a redirect chain.
131 PAGE_TRANSITION_CHAIN_END = 0x20000000,
133 // Redirects caused by JavaScript or a meta refresh tag on the page.
134 PAGE_TRANSITION_CLIENT_REDIRECT = 0x40000000,
136 // Redirects sent from the server by HTTP headers. It might be nice to
137 // break this out into 2 types in the future, permanent or temporary, if we
138 // can get that information from WebKit.
139 PAGE_TRANSITION_SERVER_REDIRECT = 0x80000000,
141 // Used to test whether a transition involves a redirect.
142 PAGE_TRANSITION_IS_REDIRECT_MASK = 0xC0000000,
144 // General mask defining the bits used for the qualifiers.
145 PAGE_TRANSITION_QUALIFIER_MASK = 0xFFFFFF00,
148 // Compares two PageTransition types ignoring qualifiers. |rhs| is taken to
149 // be a compile time constant, and hence must not contain any qualifiers.
150 UI_BASE_EXPORT bool PageTransitionCoreTypeIs(PageTransition lhs,
151 PageTransition rhs);
153 // Simplifies the provided transition by removing any qualifier
154 UI_BASE_EXPORT PageTransition PageTransitionStripQualifier(
155 PageTransition type);
157 bool PageTransitionIsValidType(int32 type);
159 UI_BASE_EXPORT PageTransition PageTransitionFromInt(int32 type);
161 // Returns true if the given transition is a top-level frame transition, or
162 // false if the transition was for a subframe.
163 UI_BASE_EXPORT bool PageTransitionIsMainFrame(PageTransition type);
165 // Returns whether a transition involves a redirection
166 UI_BASE_EXPORT bool PageTransitionIsRedirect(PageTransition type);
168 // Returns whether a transition is a new navigation (rather than a return
169 // to a previously committed navigation).
170 UI_BASE_EXPORT bool PageTransitionIsNewNavigation(PageTransition type);
172 // Return the qualifier
173 UI_BASE_EXPORT int32 PageTransitionGetQualifier(PageTransition type);
175 // Returns true if the transition can be triggered by the web instead of
176 // through UI or similar.
177 UI_BASE_EXPORT bool PageTransitionIsWebTriggerable(PageTransition type);
179 // Return a string version of the core type values.
180 UI_BASE_EXPORT const char* PageTransitionGetCoreTransitionString(
181 PageTransition type);
183 // TODO(joth): Remove the #if guard here; requires all chrome layer code to
184 // be fixed up not to use operator==
185 #if defined(CONTENT_IMPLEMENTATION)
186 // Declare a dummy class that is intentionally never defined.
187 class DontUseOperatorEquals;
189 // Ban operator== as it's way too easy to forget to strip the qualifiers. Use
190 // PageTransitionCoreTypeIs() instead.
191 DontUseOperatorEquals operator==(PageTransition, PageTransition);
192 DontUseOperatorEquals operator==(PageTransition, int);
193 DontUseOperatorEquals operator==(int, PageTransition);
194 #endif // defined(CONTENT_IMPLEMENTATION)
196 } // namespace ui
198 #endif // UI_BASE_PAGE_TRANSITION_TYPES_H_