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

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

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

Powered by Google App Engine
This is Rietveld 408576698