Home | History | Annotate | Download | only in common
      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 CONTENT_PUBLIC_COMMON_PAGE_TRANSITION_TYPES_H_
      6 #define CONTENT_PUBLIC_COMMON_PAGE_TRANSITION_TYPES_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "content/common/content_export.h"
     10 
     11 namespace content {
     12 
     13 enum PageTransition {
     14 
     15 #define PAGE_TRANSITION(label, value) PAGE_TRANSITION_ ## label = value,
     16 #include "content/public/common/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 CONTENT_EXPORT bool PageTransitionCoreTypeIs(PageTransition lhs,
     24                                              PageTransition rhs);
     25 
     26 // Simplifies the provided transition by removing any qualifier
     27 CONTENT_EXPORT PageTransition PageTransitionStripQualifier(
     28     PageTransition type);
     29 
     30 bool PageTransitionIsValidType(int32 type);
     31 
     32 CONTENT_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 CONTENT_EXPORT bool PageTransitionIsMainFrame(PageTransition type);
     37 
     38 // Returns whether a transition involves a redirection
     39 CONTENT_EXPORT bool PageTransitionIsRedirect(PageTransition type);
     40 
     41 // Return the qualifier
     42 CONTENT_EXPORT int32 PageTransitionGetQualifier(PageTransition type);
     43 
     44 // Returns true if the transition can be triggered by the web instead of
     45 // through UI or similar.
     46 CONTENT_EXPORT bool PageTransitionIsWebTriggerable(PageTransition type);
     47 
     48 // Return a string version of the core type values.
     49 CONTENT_EXPORT const char* PageTransitionGetCoreTransitionString(
     50     PageTransition type);
     51 
     52 // TODO(joth): Remove the #if guard here; requires all chrome layer code to
     53 // be fixed up not to use operator==
     54 #if defined(CONTENT_IMPLEMENTATION)
     55 // Declare a dummy class that is intentionally never defined.
     56 class DontUseOperatorEquals;
     57 
     58 // Ban operator== as it's way too easy to forget to strip the qualifiers. Use
     59 // PageTransitionCoreTypeIs() instead.
     60 DontUseOperatorEquals operator==(PageTransition, PageTransition);
     61 DontUseOperatorEquals operator==(PageTransition, int);
     62 DontUseOperatorEquals operator==(int, PageTransition);
     63 #endif  // defined(CONTENT_IMPLEMENTATION)
     64 
     65 }  // namespace content
     66 
     67 #endif  // CONTENT_PUBLIC_COMMON_PAGE_TRANSITION_TYPES_H_
     68