This source file includes following definitions.
- PageTransitionCoreTypeIs
- PageTransitionStripQualifier
- PageTransitionIsValidType
- PageTransitionFromInt
- PageTransitionIsMainFrame
- PageTransitionIsRedirect
- PageTransitionGetQualifier
- PageTransitionIsWebTriggerable
- PageTransitionGetCoreTransitionString
#include "content/public/common/page_transition_types.h"
#include "base/logging.h"
namespace content {
bool PageTransitionCoreTypeIs(PageTransition lhs,
PageTransition rhs) {
DCHECK(PageTransitionGetQualifier(rhs) == 0 &&
PageTransitionIsValidType(rhs));
return implicit_cast<int>(PageTransitionStripQualifier(lhs)) ==
implicit_cast<int>(PageTransitionStripQualifier(rhs));
}
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 PAGE_TRANSITION_LINK;
}
return static_cast<PageTransition>(type);
}
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;
}
bool PageTransitionIsWebTriggerable(PageTransition type) {
int32 t = PageTransitionStripQualifier(type);
switch (t) {
case PAGE_TRANSITION_LINK:
case PAGE_TRANSITION_AUTO_SUBFRAME:
case PAGE_TRANSITION_MANUAL_SUBFRAME:
case PAGE_TRANSITION_FORM_SUBMIT:
return true;
}
return false;
}
const char* PageTransitionGetCoreTransitionString(PageTransition type) {
int32 t = PageTransitionStripQualifier(type);
switch (t) {
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_AUTO_TOPLEVEL: return "auto_toplevel";
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;
}
}