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

Unified Diff: content/public/common/page_transition_types.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/common/page_transition_types.h ('k') | content/public/renderer/navigation_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/common/page_transition_types.cc
===================================================================
--- content/public/common/page_transition_types.cc (revision 105162)
+++ content/public/common/page_transition_types.cc (working copy)
@@ -2,35 +2,61 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/page_transition_types.h"
+#include "content/public/common/page_transition_types.h"
#include "base/logging.h"
-// static
-PageTransition::Type PageTransition::FromInt(int32 type) {
- if (!ValidType(type)) {
+namespace content {
+
+PageTransition PageTransitionStripQualifier(PageTransition type) {
+ return static_cast<PageTransition>(type & ~PAGE_TRANSITION_QUALIFIER_MASK);
+}
+
+bool PageTransitionIsValidType(int32 type) {
+ PageTransition t = PageTransitionStripQualifier(
+ static_cast<PageTransition>(type));
+ return (t <= PAGE_TRANSITION_LAST_CORE);
+}
+
+PageTransition PageTransitionFromInt(int32 type) {
+ if (!PageTransitionIsValidType(type)) {
NOTREACHED() << "Invalid transition type " << type;
// Return a safe default so we don't have corrupt data in release mode.
- return LINK;
+ return PAGE_TRANSITION_LINK;
}
- return static_cast<Type>(type);
+ return static_cast<PageTransition>(type);
}
-// static
-const char* PageTransition::CoreTransitionString(Type type) {
- switch (type & PageTransition::CORE_MASK) {
- case 0: return "link";
- case 1: return "typed";
- case 2: return "auto_bookmark";
- case 3: return "auto_subframe";
- case 4: return "manual_subframe";
- case 5: return "generated";
- case 6: return "start_page";
- case 7: return "form_submit";
- case 8: return "reload";
- case 9: return "keyword";
- case 10: return "keyword_generated";
+bool PageTransitionIsMainFrame(PageTransition type) {
+ int32 t = PageTransitionStripQualifier(type);
+ return (t != PAGE_TRANSITION_AUTO_SUBFRAME &&
+ t != PAGE_TRANSITION_MANUAL_SUBFRAME);
+}
+
+bool PageTransitionIsRedirect(PageTransition type) {
+ return (type & PAGE_TRANSITION_IS_REDIRECT_MASK) != 0;
+}
+
+int32 PageTransitionGetQualifier(PageTransition type) {
+ return type & PAGE_TRANSITION_QUALIFIER_MASK;
+}
+
+const char* PageTransitionGetCoreTransitionString(PageTransition type) {
+ switch (type & PAGE_TRANSITION_CORE_MASK) {
+ case PAGE_TRANSITION_LINK: return "link";
+ case PAGE_TRANSITION_TYPED: return "typed";
+ case PAGE_TRANSITION_AUTO_BOOKMARK: return "auto_bookmark";
+ case PAGE_TRANSITION_AUTO_SUBFRAME: return "auto_subframe";
+ case PAGE_TRANSITION_MANUAL_SUBFRAME: return "manual_subframe";
+ case PAGE_TRANSITION_GENERATED: return "generated";
+ case PAGE_TRANSITION_START_PAGE: return "start_page";
+ case PAGE_TRANSITION_FORM_SUBMIT: return "form_submit";
+ case PAGE_TRANSITION_RELOAD: return "reload";
+ case PAGE_TRANSITION_KEYWORD: return "keyword";
+ case PAGE_TRANSITION_KEYWORD_GENERATED: return "keyword_generated";
}
return NULL;
}
+
+} // namespace content
« no previous file with comments | « content/public/common/page_transition_types.h ('k') | content/public/renderer/navigation_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698