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 "base/basictypes.h" 9 #include "ui/base/ui_base_export.h" 10 11 namespace ui { 12 13 enum PageTransition { 14 15 #define PAGE_TRANSITION(label, value) PAGE_TRANSITION_ ## label = value, 16 #include "ui/base/page_transition_types_list.h" 17 #undef PAGE_TRANSITION 18 19 }; 20 21 // Compares two PageTransition types ignoring qualifiers. |rhs| is taken to 22 // be a compile time constant, and hence must not contain any qualifiers. 23 UI_BASE_EXPORT bool PageTransitionCoreTypeIs(PageTransition lhs, 24 PageTransition rhs); 25 26 // Simplifies the provided transition by removing any qualifier 27 UI_BASE_EXPORT PageTransition PageTransitionStripQualifier( 28 PageTransition type); 29 30 bool PageTransitionIsValidType(int32 type); 31 32 UI_BASE_EXPORT PageTransition PageTransitionFromInt(int32 type); 33 34 // Returns true if the given transition is a top-level frame transition, or 35 // false if the transition was for a subframe. 36 UI_BASE_EXPORT bool PageTransitionIsMainFrame(PageTransition type); 37 38 // Returns whether a transition involves a redirection 39 UI_BASE_EXPORT bool PageTransitionIsRedirect(PageTransition type); 40 41 // Returns whether a transition is a new navigation (rather than a return 42 // to a previously committed navigation). 43 UI_BASE_EXPORT bool PageTransitionIsNewNavigation(PageTransition type); 44 45 // Return the qualifier 46 UI_BASE_EXPORT int32 PageTransitionGetQualifier(PageTransition type); 47 48 // Returns true if the transition can be triggered by the web instead of 49 // through UI or similar. 50 UI_BASE_EXPORT bool PageTransitionIsWebTriggerable(PageTransition type); 51 52 // Return a string version of the core type values. 53 UI_BASE_EXPORT const char* PageTransitionGetCoreTransitionString( 54 PageTransition type); 55 56 // TODO(joth): Remove the #if guard here; requires all chrome layer code to 57 // be fixed up not to use operator== 58 #if defined(CONTENT_IMPLEMENTATION) 59 // Declare a dummy class that is intentionally never defined. 60 class DontUseOperatorEquals; 61 62 // Ban operator== as it's way too easy to forget to strip the qualifiers. Use 63 // PageTransitionCoreTypeIs() instead. 64 DontUseOperatorEquals operator==(PageTransition, PageTransition); 65 DontUseOperatorEquals operator==(PageTransition, int); 66 DontUseOperatorEquals operator==(int, PageTransition); 67 #endif // defined(CONTENT_IMPLEMENTATION) 68 69 } // namespace ui 70 71 #endif // UI_BASE_PAGE_TRANSITION_TYPES_H_ 72