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