diff options
author | Sylvain Defresne <sdefresne@chromium.org> | 2014-09-19 12:19:35 +0200 |
---|---|---|
committer | Sylvain Defresne <sdefresne@chromium.org> | 2014-09-19 10:20:45 +0000 |
commit | c6ccc77dc9c080d83e400dc12205bb805a25ac71 (patch) | |
tree | 8050f444606ddb8eae0297b52676cb2e01e6f8db /ui | |
parent | 80ced42d624a1eec8e8a2f0c0c760ab576d65ead (diff) | |
download | chromium_src-c6ccc77dc9c080d83e400dc12205bb805a25ac71.zip chromium_src-c6ccc77dc9c080d83e400dc12205bb805a25ac71.tar.gz chromium_src-c6ccc77dc9c080d83e400dc12205bb805a25ac71.tar.bz2 |
Move PageTransition from //content/public/common to //ui/base
Move PageTransition enumeration from //content/public/common to //ui/base
so that it can be used by iOS and layered components that are used on iOS.
BUG=372373
R=avi@chromium.org, ben@chromium.org, wfh@chromium.org
TBR=ben, nasko
Review URL: https://codereview.chromium.org/562603002
Cr-Commit-Position: refs/heads/master@{#295686}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/android/BUILD.gn | 11 | ||||
-rw-r--r-- | ui/android/java/PageTransitionTypes.template | 12 | ||||
-rw-r--r-- | ui/android/ui_android.gyp | 13 | ||||
-rw-r--r-- | ui/app_list/demo/app_list_demo_views.cc | 2 | ||||
-rw-r--r-- | ui/base/BUILD.gn | 3 | ||||
-rw-r--r-- | ui/base/page_transition_types.cc | 89 | ||||
-rw-r--r-- | ui/base/page_transition_types.h | 71 | ||||
-rw-r--r-- | ui/base/page_transition_types_list.h | 137 | ||||
-rw-r--r-- | ui/base/ui_base.gyp | 3 | ||||
-rw-r--r-- | ui/keyboard/keyboard_controller_proxy.cc | 2 | ||||
-rw-r--r-- | ui/views/controls/webview/webview.cc | 2 |
11 files changed, 342 insertions, 3 deletions
diff --git a/ui/android/BUILD.gn b/ui/android/BUILD.gn index e1774d5..4f3a706 100644 --- a/ui/android/BUILD.gn +++ b/ui/android/BUILD.gn @@ -13,6 +13,16 @@ java_cpp_enum("java_enums_srcjar") { ] } +java_cpp_template("page_transition_types_srcjar") { + package_name = "org/chromium/ui/base" + sources = [ + "java/PageTransitionTypes.template", + ] + inputs = [ + "../base/page_transition_types_list.h", + ] +} + java_strings_grd("ui_strings_grd") { grd_file = "java/strings/android_ui_strings.grd" outputs = [ @@ -113,5 +123,6 @@ android_library("ui_java") { ] srcjar_deps = [ ":java_enums_srcjar", + ":page_transition_types_srcjar", ] } diff --git a/ui/android/java/PageTransitionTypes.template b/ui/android/java/PageTransitionTypes.template new file mode 100644 index 0000000..d2f12f8 --- /dev/null +++ b/ui/android/java/PageTransitionTypes.template @@ -0,0 +1,12 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.ui.base; + +public class PageTransitionTypes { +#define PAGE_TRANSITION(label, value) public static final int \ + PAGE_TRANSITION_ ## label = value; +#include "ui/base/page_transition_types_list.h" +#undef PAGE_TRANSITION +} diff --git a/ui/android/ui_android.gyp b/ui/android/ui_android.gyp index 5b8a786..bb0d0f5 100644 --- a/ui/android/ui_android.gyp +++ b/ui/android/ui_android.gyp @@ -16,6 +16,18 @@ 'includes': [ '../../build/android/java_cpp_enum.gypi' ], }, { + 'target_name': 'page_transition_types_java', + 'type': 'none', + 'sources': [ + 'java/PageTransitionTypes.template', + ], + 'variables': { + 'package_name': 'org/chromium/ui/base', + 'template_deps': ['../base/page_transition_types_list.h'], + }, + 'includes': [ '../../build/android/java_cpp_template.gypi' ], + }, + { 'target_name': 'window_open_disposition_java', 'type': 'none', 'variables': { @@ -35,6 +47,7 @@ 'dependencies': [ '../../base/base.gyp:base_java', 'bitmap_format_java', + 'page_transition_types_java', 'ui_strings_grd', 'window_open_disposition_java', ], diff --git a/ui/app_list/demo/app_list_demo_views.cc b/ui/app_list/demo/app_list_demo_views.cc index 71a2251..58e939a 100644 --- a/ui/app_list/demo/app_list_demo_views.cc +++ b/ui/app_list/demo/app_list_demo_views.cc @@ -97,7 +97,7 @@ views::View* DemoAppListViewDelegate::CreateStartPageWebView( content::WebContents::CreateParams(browser_context_))); web_contents_->GetController().LoadURL(GURL("http://www.google.com/"), content::Referrer(), - content::PAGE_TRANSITION_AUTO_TOPLEVEL, + ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); views::WebView* web_view = new views::WebView( web_contents_->GetBrowserContext()); diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn index e41abf6..2ac985f 100644 --- a/ui/base/BUILD.gn +++ b/ui/base/BUILD.gn @@ -187,6 +187,9 @@ component("base") { "models/tree_node_model.h", "nine_image_painter_factory.cc", "nine_image_painter_factory.h", + "page_transition_types.cc", + "page_transition_types.h", + "page_transition_types_list.h", "resource/data_pack.cc", "resource/data_pack.h", "resource/resource_bundle.cc", diff --git a/ui/base/page_transition_types.cc b/ui/base/page_transition_types.cc new file mode 100644 index 0000000..0bd86f6 --- /dev/null +++ b/ui/base/page_transition_types.cc @@ -0,0 +1,89 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/base/page_transition_types.h" + +#include "base/logging.h" + +namespace ui { + +bool PageTransitionCoreTypeIs(PageTransition lhs, + PageTransition rhs) { + // Expect the rhs to be a compile time constant without qualifiers. + 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 a safe default so we don't have corrupt data in release mode. + 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; +} + +bool PageTransitionIsNewNavigation(PageTransition type) { + return (type & PAGE_TRANSITION_FORWARD_BACK) == 0 && + !PageTransitionCoreTypeIs(type, PAGE_TRANSITION_RELOAD); +} + +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; +} + +} // namespace ui diff --git a/ui/base/page_transition_types.h b/ui/base/page_transition_types.h new file mode 100644 index 0000000..3ca67c5 --- /dev/null +++ b/ui/base/page_transition_types.h @@ -0,0 +1,71 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_BASE_PAGE_TRANSITION_TYPES_H_ +#define UI_BASE_PAGE_TRANSITION_TYPES_H_ + +#include "base/basictypes.h" +#include "ui/base/ui_base_export.h" + +namespace ui { + +enum PageTransition { + +#define PAGE_TRANSITION(label, value) PAGE_TRANSITION_ ## label = value, +#include "ui/base/page_transition_types_list.h" +#undef PAGE_TRANSITION + +}; + +// Compares two PageTransition types ignoring qualifiers. |rhs| is taken to +// be a compile time constant, and hence must not contain any qualifiers. +UI_BASE_EXPORT bool PageTransitionCoreTypeIs(PageTransition lhs, + PageTransition rhs); + +// Simplifies the provided transition by removing any qualifier +UI_BASE_EXPORT PageTransition PageTransitionStripQualifier( + PageTransition type); + +bool PageTransitionIsValidType(int32 type); + +UI_BASE_EXPORT PageTransition PageTransitionFromInt(int32 type); + +// Returns true if the given transition is a top-level frame transition, or +// false if the transition was for a subframe. +UI_BASE_EXPORT bool PageTransitionIsMainFrame(PageTransition type); + +// Returns whether a transition involves a redirection +UI_BASE_EXPORT bool PageTransitionIsRedirect(PageTransition type); + +// Returns whether a transition is a new navigation (rather than a return +// to a previously committed navigation). +UI_BASE_EXPORT bool PageTransitionIsNewNavigation(PageTransition type); + +// Return the qualifier +UI_BASE_EXPORT int32 PageTransitionGetQualifier(PageTransition type); + +// Returns true if the transition can be triggered by the web instead of +// through UI or similar. +UI_BASE_EXPORT bool PageTransitionIsWebTriggerable(PageTransition type); + +// Return a string version of the core type values. +UI_BASE_EXPORT const char* PageTransitionGetCoreTransitionString( + PageTransition type); + +// TODO(joth): Remove the #if guard here; requires all chrome layer code to +// be fixed up not to use operator== +#if defined(CONTENT_IMPLEMENTATION) +// Declare a dummy class that is intentionally never defined. +class DontUseOperatorEquals; + +// Ban operator== as it's way too easy to forget to strip the qualifiers. Use +// PageTransitionCoreTypeIs() instead. +DontUseOperatorEquals operator==(PageTransition, PageTransition); +DontUseOperatorEquals operator==(PageTransition, int); +DontUseOperatorEquals operator==(int, PageTransition); +#endif // defined(CONTENT_IMPLEMENTATION) + +} // namespace ui + +#endif // UI_BASE_PAGE_TRANSITION_TYPES_H_ diff --git a/ui/base/page_transition_types_list.h b/ui/base/page_transition_types_list.h new file mode 100644 index 0000000..be67334 --- /dev/null +++ b/ui/base/page_transition_types_list.h @@ -0,0 +1,137 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Intentionally no include guards because this file is meant to be included +// inside a macro to generate enum values. + +// Types of transitions between pages. These are stored in the history +// database to separate visits, and are reported by the renderer for page +// navigations. +// +// WARNING: don't change these numbers. They are written directly into the +// history database, so future versions will need the same values to match +// the enums. +// +// A type is made of a core value and a set of qualifiers. A type has one +// core value and 0 or or more qualifiers. + +// User got to this page by clicking a link on another page. +PAGE_TRANSITION(LINK, 0) + +// User got this page by typing the URL in the URL bar. This should not be +// used for cases where the user selected a choice that didn't look at all +// like a URL; see GENERATED below. +// +// We also use this for other "explicit" navigation actions. +PAGE_TRANSITION(TYPED, 1) + +// User got to this page through a suggestion in the UI, for example) +// through the destinations page. +PAGE_TRANSITION(AUTO_BOOKMARK, 2) + +// This is a subframe navigation. This is any content that is automatically +// loaded in a non-toplevel frame. For example, if a page consists of +// several frames containing ads, those ad URLs will have this transition +// type. The user may not even realize the content in these pages is a +// separate frame, so may not care about the URL (see MANUAL below). +PAGE_TRANSITION(AUTO_SUBFRAME, 3) + +// For subframe navigations that are explicitly requested by the user and +// generate new navigation entries in the back/forward list. These are +// probably more important than frames that were automatically loaded in +// the background because the user probably cares about the fact that this +// link was loaded. +PAGE_TRANSITION(MANUAL_SUBFRAME, 4) + +// User got to this page by typing in the URL bar and selecting an entry +// that did not look like a URL. For example, a match might have the URL +// of a Google search result page, but appear like "Search Google for ...". +// These are not quite the same as TYPED navigations because the user +// didn't type or see the destination URL. +// See also KEYWORD. +PAGE_TRANSITION(GENERATED, 5) + +// This is a toplevel navigation. This is any content that is automatically +// loaded in a toplevel frame. For example, opening a tab to show the ASH +// screen saver, opening the devtools window, opening the NTP after the safe +// browsing warning, opening web-based dialog boxes are examples of +// AUTO_TOPLEVEL navigations. +PAGE_TRANSITION(AUTO_TOPLEVEL, 6) + +// The user filled out values in a form and submitted it. NOTE that in +// some situations submitting a form does not result in this transition +// type. This can happen if the form uses script to submit the contents. +PAGE_TRANSITION(FORM_SUBMIT, 7) + +// The user "reloaded" the page, either by hitting the reload button or by +// hitting enter in the address bar. NOTE: This is distinct from the +// concept of whether a particular load uses "reload semantics" (i.e. +// bypasses cached data). For this reason, lots of code needs to pass +// around the concept of whether a load should be treated as a "reload" +// separately from their tracking of this transition type, which is mainly +// used for proper scoring for consumers who care about how frequently a +// user typed/visited a particular URL. +// +// SessionRestore and undo tab close use this transition type too. +PAGE_TRANSITION(RELOAD, 8) + +// The url was generated from a replaceable keyword other than the default +// search provider. If the user types a keyword (which also applies to +// tab-to-search) in the omnibox this qualifier is applied to the transition +// type of the generated url. TemplateURLModel then may generate an +// additional visit with a transition type of KEYWORD_GENERATED against the +// url 'http://' + keyword. For example, if you do a tab-to-search against +// wikipedia the generated url has a transition qualifer of KEYWORD, and +// TemplateURLModel generates a visit for 'wikipedia.org' with a transition +// type of KEYWORD_GENERATED. +PAGE_TRANSITION(KEYWORD, 9) + +// Corresponds to a visit generated for a keyword. See description of +// KEYWORD for more details. +PAGE_TRANSITION(KEYWORD_GENERATED, 10) + +// ADDING NEW CORE VALUE? Be sure to update the LAST_CORE and CORE_MASK +// values below. Also update CoreTransitionString(). +PAGE_TRANSITION(LAST_CORE, PAGE_TRANSITION_KEYWORD_GENERATED) +PAGE_TRANSITION(CORE_MASK, 0xFF) + +// Qualifiers +// Any of the core values above can be augmented by one or more qualifiers. +// These qualifiers further define the transition. + +// A managed user attempted to visit a URL but was blocked. +PAGE_TRANSITION(BLOCKED, 0x00800000) + +// User used the Forward or Back button to navigate among browsing history. +PAGE_TRANSITION(FORWARD_BACK, 0x01000000) + +// User used the address bar to trigger this navigation. +PAGE_TRANSITION(FROM_ADDRESS_BAR, 0x02000000) + +// User is navigating to the home page. +PAGE_TRANSITION(HOME_PAGE, 0x04000000) + +// The transition originated from an external application; the exact definition +// of this is embedder dependent. +PAGE_TRANSITION(FROM_API, 0x08000000) + +// The beginning of a navigation chain. +PAGE_TRANSITION(CHAIN_START, 0x10000000) + +// The last transition in a redirect chain. +PAGE_TRANSITION(CHAIN_END, 0x20000000) + +// Redirects caused by JavaScript or a meta refresh tag on the page. +PAGE_TRANSITION(CLIENT_REDIRECT, 0x40000000) + +// Redirects sent from the server by HTTP headers. It might be nice to +// break this out into 2 types in the future, permanent or temporary, if we +// can get that information from WebKit. +PAGE_TRANSITION(SERVER_REDIRECT, 0x80000000) + +// Used to test whether a transition involves a redirect. +PAGE_TRANSITION(IS_REDIRECT_MASK, 0xC0000000) + +// General mask defining the bits used for the qualifiers. +PAGE_TRANSITION(QUALIFIER_MASK, 0xFFFFFF00) diff --git a/ui/base/ui_base.gyp b/ui/base/ui_base.gyp index d2abb03..96cb8d9 100644 --- a/ui/base/ui_base.gyp +++ b/ui/base/ui_base.gyp @@ -290,6 +290,9 @@ 'models/tree_node_model.h', 'nine_image_painter_factory.cc', 'nine_image_painter_factory.h', + 'page_transition_types.cc', + 'page_transition_types.h', + 'page_transition_types_list.h', 'resource/data_pack.cc', 'resource/data_pack.h', 'resource/resource_bundle.cc', diff --git a/ui/keyboard/keyboard_controller_proxy.cc b/ui/keyboard/keyboard_controller_proxy.cc index 097b0d62..1b3e86a 100644 --- a/ui/keyboard/keyboard_controller_proxy.cc +++ b/ui/keyboard/keyboard_controller_proxy.cc @@ -106,7 +106,7 @@ void KeyboardControllerProxy::LoadContents(const GURL& url) { url, content::Referrer(), SINGLETON_TAB, - content::PAGE_TRANSITION_AUTO_TOPLEVEL, + ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false); keyboard_contents_->OpenURL(params); } diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc index e788500..f1f12d0 100644 --- a/ui/views/controls/webview/webview.cc +++ b/ui/views/controls/webview/webview.cc @@ -80,7 +80,7 @@ void WebView::SetEmbedFullscreenWidgetMode(bool enable) { void WebView::LoadInitialURL(const GURL& url) { GetWebContents()->GetController().LoadURL( - url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, + url, content::Referrer(), ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); } |