Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Side by Side Diff: content/common/page_transition_types.h

Issue 8253002: Move PageTransition into content namespace. While I'm touching all these files, I've also updated... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/common_param_traits.h ('k') | content/common/page_transition_types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 CONTENT_COMMON_PAGE_TRANSITION_TYPES_H_
6 #define CONTENT_COMMON_PAGE_TRANSITION_TYPES_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "content/common/content_export.h"
11
12 // This class is for scoping only.
13 class CONTENT_EXPORT PageTransition {
14 public:
15 // Types of transitions between pages. These are stored in the history
16 // database to separate visits, and are reported by the renderer for page
17 // navigations.
18 //
19 // WARNING: don't change these numbers. They are written directly into the
20 // history database, so future versions will need the same values to match
21 // the enums.
22 //
23 // A type is made of a core value and a set of qualifiers. A type has one
24 // core value and 0 or or more qualifiers.
25 enum TypeEnum {
26 // User got to this page by clicking a link on another page.
27 LINK = 0,
28
29 // User got this page by typing the URL in the URL bar. This should not be
30 // used for cases where the user selected a choice that didn't look at all
31 // like a URL; see GENERATED below.
32 //
33 // We also use this for other "explicit" navigation actions.
34 TYPED = 1,
35
36 // User got to this page through a suggestion in the UI, for example,
37 // through the destinations page.
38 AUTO_BOOKMARK = 2,
39
40 // This is a subframe navigation. This is any content that is automatically
41 // loaded in a non-toplevel frame. For example, if a page consists of
42 // several frames containing ads, those ad URLs will have this transition
43 // type. The user may not even realize the content in these pages is a
44 // separate frame, so may not care about the URL (see MANUAL below).
45 AUTO_SUBFRAME = 3,
46
47 // For subframe navigations that are explicitly requested by the user and
48 // generate new navigation entries in the back/forward list. These are
49 // probably more important than frames that were automatically loaded in
50 // the background because the user probably cares about the fact that this
51 // link was loaded.
52 MANUAL_SUBFRAME = 4,
53
54 // User got to this page by typing in the URL bar and selecting an entry
55 // that did not look like a URL. For example, a match might have the URL
56 // of a Google search result page, but appear like "Search Google for ...".
57 // These are not quite the same as TYPED navigations because the user
58 // didn't type or see the destination URL.
59 // See also KEYWORD.
60 GENERATED = 5,
61
62 // The page was specified in the command line or is the start page.
63 START_PAGE = 6,
64
65 // The user filled out values in a form and submitted it. NOTE that in
66 // some situations submitting a form does not result in this transition
67 // type. This can happen if the form uses script to submit the contents.
68 FORM_SUBMIT = 7,
69
70 // The user "reloaded" the page, either by hitting the reload button or by
71 // hitting enter in the address bar. NOTE: This is distinct from the
72 // concept of whether a particular load uses "reload semantics" (i.e.
73 // bypasses cached data). For this reason, lots of code needs to pass
74 // around the concept of whether a load should be treated as a "reload"
75 // separately from their tracking of this transition type, which is mainly
76 // used for proper scoring for consumers who care about how frequently a
77 // user typed/visited a particular URL.
78 //
79 // SessionRestore and undo tab close use this transition type too.
80 RELOAD = 8,
81
82 // The url was generated from a replaceable keyword other than the default
83 // search provider. If the user types a keyword (which also applies to
84 // tab-to-search) in the omnibox this qualifier is applied to the transition
85 // type of the generated url. TemplateURLModel then may generate an
86 // additional visit with a transition type of KEYWORD_GENERATED against the
87 // url 'http://' + keyword. For example, if you do a tab-to-search against
88 // wikipedia the generated url has a transition qualifer of KEYWORD, and
89 // TemplateURLModel generates a visit for 'wikipedia.org' with a transition
90 // type of KEYWORD_GENERATED.
91 KEYWORD = 9,
92
93 // Corresponds to a visit generated for a keyword. See description of
94 // KEYWORD for more details.
95 KEYWORD_GENERATED = 10,
96
97 // ADDING NEW CORE VALUE? Be sure to update the LAST_CORE and CORE_MASK
98 // values below. Also update CoreTransitionString().
99 LAST_CORE = KEYWORD_GENERATED,
100 CORE_MASK = 0xFF,
101
102 // Qualifiers
103 // Any of the core values above can be augmented by one or more qualifiers.
104 // These qualifiers further define the transition.
105
106 // User used the Forward or Back button to navigate among browsing history.
107 FORWARD_BACK = 0x01000000,
108
109 // User used the address bar to trigger this navigation.
110 FROM_ADDRESS_BAR = 0x02000000,
111
112 // User is navigating to the home page.
113 HOME_PAGE = 0x04000000,
114
115 // The beginning of a navigation chain.
116 CHAIN_START = 0x10000000,
117
118 // The last transition in a redirect chain.
119 CHAIN_END = 0x20000000,
120
121 // Redirects caused by JavaScript or a meta refresh tag on the page.
122 CLIENT_REDIRECT = 0x40000000,
123
124 // Redirects sent from the server by HTTP headers. It might be nice to
125 // break this out into 2 types in the future, permanent or temporary, if we
126 // can get that information from WebKit.
127 SERVER_REDIRECT = 0x80000000,
128
129 // Used to test whether a transition involves a redirect.
130 IS_REDIRECT_MASK = 0xC0000000,
131
132 // General mask defining the bits used for the qualifiers.
133 QUALIFIER_MASK = 0xFFFFFF00
134 };
135
136 // The type used for the bitfield.
137 typedef unsigned int Type;
138
139 static bool ValidType(int32 type) {
140 Type t = StripQualifier(static_cast<Type>(type));
141 return (t <= LAST_CORE);
142 }
143
144 static Type FromInt(int32 type);
145
146 // Returns true if the given transition is a top-level frame transition, or
147 // false if the transition was for a subframe.
148 static bool IsMainFrame(Type type) {
149 int32 t = StripQualifier(type);
150 return (t != AUTO_SUBFRAME && t != MANUAL_SUBFRAME);
151 }
152
153 // Returns whether a transition involves a redirection
154 static bool IsRedirect(Type type) {
155 return (type & IS_REDIRECT_MASK) != 0;
156 }
157
158 // Simplifies the provided transition by removing any qualifier
159 static Type StripQualifier(Type type) {
160 return static_cast<Type>(type & ~QUALIFIER_MASK);
161 }
162
163 // Return the qualifier
164 static int32 GetQualifier(Type type) {
165 return type & QUALIFIER_MASK;
166 }
167
168 // Return a string version of the core type values.
169 static const char* CoreTransitionString(Type type);
170 };
171
172 #endif // CONTENT_COMMON_PAGE_TRANSITION_TYPES_H_
OLDNEW
« no previous file with comments | « content/common/common_param_traits.h ('k') | content/common/page_transition_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698