From fef18e2743a7038531ebb5d4e06100e3067fe276 Mon Sep 17 00:00:00 2001 From: amaitland Date: Thu, 30 Oct 2014 12:07:43 +1000 Subject: [PATCH 01/20] Cleanup Loading and NavState code, there's currently additional calls to both which are slightly confusing (and don't provide any benefit). So simplify by setting SetIsLoading(true) on LoadStart and SetIsLoading(false) on LoadEnd. Then only set NavState in ClientAdapter::OnLoadingStateChange --- CefSharp.Core/Internals/ClientAdapter.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index c6e752993..d42494776 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -62,8 +62,6 @@ namespace CefSharp void ClientAdapter::OnLoadingStateChange(CefRefPtr browser, bool isLoading, bool canGoBack, bool canGoForward) { - _browserControl->SetIsLoading(isLoading); - auto canReload = !isLoading; _browserControl->SetNavState(canGoBack, canGoForward, canReload); } @@ -163,7 +161,6 @@ namespace CefSharp if (frame->IsMain()) { _browserControl->SetIsLoading(true); - _browserControl->SetNavState(false, false, false); } _browserControl->OnFrameLoadStart(StringUtils::ToClr(frame->GetURL()), frame->IsMain()); From c92a26d542052d6a9fbb8f61a38b24b7e7959e12 Mon Sep 17 00:00:00 2001 From: Evgeny Pestov Date: Thu, 30 Oct 2014 11:49:34 +0300 Subject: [PATCH 02/20] Add navigation type to IRequest. --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 5 +++++ CefSharp.Core/Internals/CefRequestWrapper.h | 1 + CefSharp/IRequest.cs | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index 12adc4dfe..720cf00fb 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -96,5 +96,10 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } + + CefSharp::NavigationType CefRequestWrapper::NavigationType::get() + { + return (CefSharp::NavigationType) _wrappedRequest->GetTransitionType(); + } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 6925a284e..2b7196c5f 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -33,6 +33,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } + virtual property CefSharp::NavigationType NavigationType { CefSharp::NavigationType get(); } }; } diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index 33595a3cc..c3da1f52f 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -6,11 +6,22 @@ using System.Collections.Specialized; namespace CefSharp { + public enum NavigationType + { + LinkClicked, + FormSubmitted, + BackForward, + Reload, + FormResubmitted, + Other + }; + public interface IRequest { string Url { get; set; } string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } + NavigationType NavigationType { get; } } } From 37c9b1652c5c6b9c2f23e3113791c3edc6a6df69 Mon Sep 17 00:00:00 2001 From: kropewnicki Date: Mon, 3 Nov 2014 07:14:01 -0500 Subject: [PATCH 03/20] Update ManagedCefBrowserAdapter.h Check if _webBrowserInternal is null before checking if it is Initialized. --- CefSharp.Core/ManagedCefBrowserAdapter.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index a229d326c..308c8cb08 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.h +++ b/CefSharp.Core/ManagedCefBrowserAdapter.h @@ -1,4 +1,4 @@ -// Copyright © 2010-2014 The CefSharp Authors. All rights reserved. +// Copyright © 2010-2014 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. @@ -83,14 +83,17 @@ namespace CefSharp void OnInitialized() { - _webBrowserInternal->OnInitialized(); - - auto address = _address; - - if ( address != nullptr ) - { - LoadUrl(address); - } + if(_webBrowserInternal != nullptr) + { + _webBrowserInternal->OnInitialized(); + + auto address = _address; + + if ( address != nullptr ) + { + LoadUrl(address); + } + } }; void LoadHtml(String^ html, String^ url) From c526f3f09769e2fefd0a2a45bede4d6da3fbb311 Mon Sep 17 00:00:00 2001 From: kropewnicki Date: Mon, 3 Nov 2014 08:30:07 -0500 Subject: [PATCH 04/20] Update ManagedCefBrowserAdapter.h Fix tab format to use spaces instead. --- CefSharp.Core/ManagedCefBrowserAdapter.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index 308c8cb08..f5589ee88 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.h +++ b/CefSharp.Core/ManagedCefBrowserAdapter.h @@ -80,20 +80,19 @@ namespace CefSharp } } - void OnInitialized() { if(_webBrowserInternal != nullptr) - { + { _webBrowserInternal->OnInitialized(); - + auto address = _address; - + if ( address != nullptr ) { LoadUrl(address); } - } + } }; void LoadHtml(String^ html, String^ url) From 4f899d3308e3dbf96d03d83b536749e9058ea9d7 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:04:05 +1000 Subject: [PATCH 05/20] Move NavigationType into it's own class --- CefSharp/CefSharp.csproj | 1 + CefSharp/IRequest.cs | 10 ---------- CefSharp/NavigationType.cs | 12 ++++++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 CefSharp/NavigationType.cs diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index 6d18df6a2..61ceb8695 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -100,6 +100,7 @@ + diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index c3da1f52f..1e61ae601 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -6,16 +6,6 @@ using System.Collections.Specialized; namespace CefSharp { - public enum NavigationType - { - LinkClicked, - FormSubmitted, - BackForward, - Reload, - FormResubmitted, - Other - }; - public interface IRequest { string Url { get; set; } diff --git a/CefSharp/NavigationType.cs b/CefSharp/NavigationType.cs new file mode 100644 index 000000000..a3bd1e137 --- /dev/null +++ b/CefSharp/NavigationType.cs @@ -0,0 +1,12 @@ +namespace CefSharp +{ + public enum NavigationType + { + LinkClicked, + FormSubmitted, + BackForward, + Reload, + FormResubmitted, + Other + }; +} From 8f3e7d7fd5a128508eb5084e2631fe025432f806 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:06:29 +1000 Subject: [PATCH 06/20] Rename NavigationType to TransitionType (keeping inline with Cef API) --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 4 ++-- CefSharp.Core/Internals/CefRequestWrapper.h | 2 +- CefSharp/CefSharp.csproj | 2 +- CefSharp/IRequest.cs | 2 +- CefSharp/{NavigationType.cs => TransitionType.cs} | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename CefSharp/{NavigationType.cs => TransitionType.cs} (80%) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index 720cf00fb..6e9ac98ad 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -97,9 +97,9 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } - CefSharp::NavigationType CefRequestWrapper::NavigationType::get() + CefSharp::TransitionType CefRequestWrapper::NavigationType::get() { - return (CefSharp::NavigationType) _wrappedRequest->GetTransitionType(); + return (CefSharp::TransitionType) _wrappedRequest->GetTransitionType(); } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 2b7196c5f..5e3729229 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -33,7 +33,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } - virtual property CefSharp::NavigationType NavigationType { CefSharp::NavigationType get(); } + virtual property CefSharp::TransitionType NavigationType { CefSharp::TransitionType get(); } }; } diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index 61ceb8695..34d2bc748 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -100,7 +100,7 @@ - + diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index 1e61ae601..b31fb865a 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -12,6 +12,6 @@ namespace CefSharp string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } - NavigationType NavigationType { get; } + TransitionType NavigationType { get; } } } diff --git a/CefSharp/NavigationType.cs b/CefSharp/TransitionType.cs similarity index 80% rename from CefSharp/NavigationType.cs rename to CefSharp/TransitionType.cs index a3bd1e137..d8ddfefd4 100644 --- a/CefSharp/NavigationType.cs +++ b/CefSharp/TransitionType.cs @@ -1,6 +1,6 @@ namespace CefSharp { - public enum NavigationType + public enum TransitionType { LinkClicked, FormSubmitted, From 83b8e68f11f03ae61658dfb7abf8007355c86210 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:07:50 +1000 Subject: [PATCH 07/20] Change to using statement rather than namespace qualified declerations --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 4 ++-- CefSharp.Core/Internals/CefRequestWrapper.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index 6e9ac98ad..ba2164059 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -97,9 +97,9 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } - CefSharp::TransitionType CefRequestWrapper::NavigationType::get() + TransitionType CefRequestWrapper::NavigationType::get() { - return (CefSharp::TransitionType) _wrappedRequest->GetTransitionType(); + return (TransitionType) _wrappedRequest->GetTransitionType(); } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 5e3729229..1b530225d 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -9,6 +9,7 @@ using namespace System; using namespace System::Collections::Specialized; +using namespace CefSharp; namespace CefSharp { @@ -33,7 +34,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } - virtual property CefSharp::TransitionType NavigationType { CefSharp::TransitionType get(); } + virtual property TransitionType NavigationType { TransitionType get(); } }; } From 88dd428e1af30f322b0da49d609e49e7af96c14c Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:09:45 +1000 Subject: [PATCH 08/20] Rename NavigationType property to TransitionType --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 4 ++-- CefSharp.Core/Internals/CefRequestWrapper.h | 3 +-- CefSharp/IRequest.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index ba2164059..fbf2d450a 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -97,9 +97,9 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } - TransitionType CefRequestWrapper::NavigationType::get() + TransitionType CefRequestWrapper::TransitionType::get() { - return (TransitionType) _wrappedRequest->GetTransitionType(); + return (CefSharp::TransitionType) _wrappedRequest->GetTransitionType(); } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 1b530225d..eecb3d00e 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -34,8 +34,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } - virtual property TransitionType NavigationType { TransitionType get(); } - + virtual property TransitionType TransitionType { CefSharp::TransitionType get(); } }; } } diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index b31fb865a..a18b7b6f6 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -12,6 +12,6 @@ namespace CefSharp string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } - TransitionType NavigationType { get; } + TransitionType TransitionType { get; } } } From e86f46099d2d26c81bea033ad4db8ed506a8bb3c Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:42:15 +1000 Subject: [PATCH 09/20] Add xml comment to TransitionType --- CefSharp/IRequest.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index a18b7b6f6..050029baf 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -12,6 +12,11 @@ namespace CefSharp string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } + + /// + /// Get the transition type for this request. + /// Applies to requests that represent a main frame or sub-frame navigation. + /// TransitionType TransitionType { get; } } } From 67d30f31aa27dcefd6a108de3372e35eefa265b6 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:43:51 +1000 Subject: [PATCH 10/20] Change TransitionType to an unit enum Add [Falgs] attribute as TransitionType can have multiple values Import values from cef_transition_type_t (cef_types.h) Rename some of the values (slightly friendlier names) --- CefSharp/TransitionType.cs | 102 ++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 8 deletions(-) diff --git a/CefSharp/TransitionType.cs b/CefSharp/TransitionType.cs index d8ddfefd4..f289a1f45 100644 --- a/CefSharp/TransitionType.cs +++ b/CefSharp/TransitionType.cs @@ -1,12 +1,98 @@ -namespace CefSharp +using System; + +namespace CefSharp { - public enum TransitionType + [Flags] + public enum TransitionType : uint { - LinkClicked, - FormSubmitted, - BackForward, - Reload, - FormResubmitted, - Other + /// + /// Source is a link click or the JavaScript window.open function. This is + /// also the default value for requests like sub-resource loads that are not navigations. + /// + LinkClicked = 0, + + /// + /// Source is some other "explicit" navigation action such as creating a new + /// browser or using the LoadURL function. This is also the default value + /// for navigations where the actual type is unknown. + /// + Explicit = 1, + + /// + /// Source 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. + /// + AutoSubFrame = 3, + + /// + /// Source is a subframe navigation explicitly requested by the user that will + /// 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. + /// + ManualSubFrame = 4, + + /// + /// Source is a form submission by the user. NOTE: In some situations + /// submitting a form does not result in this transition type. This can happen + /// if the form uses a script to submit the contents. + /// + FormSubmit = 7, + + /// + /// Source is a "reload" of the page via the Reload function or by re-visiting + /// the same URL. NOTE: This is distinct from the concept of whether a + /// particular load uses "reload semantics" (i.e. bypasses cached data). + /// + Reload = 8, + + /// + /// General mask defining the bits used for the source values. + /// + SourceMask = 0xFF, + + /// + /// Attempted to visit a URL but was blocked. + /// + Blocked = 0x00800000, + + /// + /// Used the Forward or Back function to navigate among browsing history. + /// + ForwardBack = 0x01000000, + + /// + /// The beginning of a navigation chain. + /// + ChainStart = 0x10000000, + + /// + /// The last transition in a redirect chain. + /// + ChainEnd = 0x20000000, + + /// + /// Redirects caused by JavaScript or a meta refresh tag on the page. + /// + CliendRedirect = 0x40000000, + + /// + /// Redirects sent from the server by HTTP headers. + /// + ServerRedirect = 0x80000000, + + /// + /// Used to test whether a transition involves a redirect. + /// + IsRedirect = 0xC0000000, + + /// + /// General mask defining the bits used for the qualifiers. + /// + QualifierMask = 0xFFFFFF00 }; } From 358bb5c310a0399e762a9821b2f8ab96f7ae7fd9 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:48:30 +1000 Subject: [PATCH 11/20] Add license disclaimer --- CefSharp/TransitionType.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CefSharp/TransitionType.cs b/CefSharp/TransitionType.cs index f289a1f45..04b6007ec 100644 --- a/CefSharp/TransitionType.cs +++ b/CefSharp/TransitionType.cs @@ -1,4 +1,8 @@ -using System; +// Copyright © 2010-2014 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using System; namespace CefSharp { From e67d3a6f28dd39bc49c196f6391ca159dc3431ed Mon Sep 17 00:00:00 2001 From: Evgeny Pestov Date: Thu, 30 Oct 2014 11:49:34 +0300 Subject: [PATCH 12/20] Add navigation type to IRequest. --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 5 +++++ CefSharp.Core/Internals/CefRequestWrapper.h | 1 + CefSharp/IRequest.cs | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index 12adc4dfe..720cf00fb 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -96,5 +96,10 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } + + CefSharp::NavigationType CefRequestWrapper::NavigationType::get() + { + return (CefSharp::NavigationType) _wrappedRequest->GetTransitionType(); + } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 6925a284e..2b7196c5f 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -33,6 +33,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } + virtual property CefSharp::NavigationType NavigationType { CefSharp::NavigationType get(); } }; } diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index 33595a3cc..c3da1f52f 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -6,11 +6,22 @@ using System.Collections.Specialized; namespace CefSharp { + public enum NavigationType + { + LinkClicked, + FormSubmitted, + BackForward, + Reload, + FormResubmitted, + Other + }; + public interface IRequest { string Url { get; set; } string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } + NavigationType NavigationType { get; } } } From 74bdc0ad205ceaca408fc982d0c1ee2b82a4fa22 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:04:05 +1000 Subject: [PATCH 13/20] Move NavigationType into it's own class --- CefSharp/CefSharp.csproj | 1 + CefSharp/IRequest.cs | 10 ---------- CefSharp/NavigationType.cs | 12 ++++++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 CefSharp/NavigationType.cs diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index 1a2b963eb..e3acd5bf8 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -108,6 +108,7 @@ + diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index c3da1f52f..1e61ae601 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -6,16 +6,6 @@ using System.Collections.Specialized; namespace CefSharp { - public enum NavigationType - { - LinkClicked, - FormSubmitted, - BackForward, - Reload, - FormResubmitted, - Other - }; - public interface IRequest { string Url { get; set; } diff --git a/CefSharp/NavigationType.cs b/CefSharp/NavigationType.cs new file mode 100644 index 000000000..a3bd1e137 --- /dev/null +++ b/CefSharp/NavigationType.cs @@ -0,0 +1,12 @@ +namespace CefSharp +{ + public enum NavigationType + { + LinkClicked, + FormSubmitted, + BackForward, + Reload, + FormResubmitted, + Other + }; +} From fe6013fb3bdb15ed9bf873716a62dcf0fffd2573 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:06:29 +1000 Subject: [PATCH 14/20] Rename NavigationType to TransitionType (keeping inline with Cef API) --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 4 ++-- CefSharp.Core/Internals/CefRequestWrapper.h | 2 +- CefSharp/CefSharp.csproj | 2 +- CefSharp/IRequest.cs | 2 +- CefSharp/{NavigationType.cs => TransitionType.cs} | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename CefSharp/{NavigationType.cs => TransitionType.cs} (80%) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index 720cf00fb..6e9ac98ad 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -97,9 +97,9 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } - CefSharp::NavigationType CefRequestWrapper::NavigationType::get() + CefSharp::TransitionType CefRequestWrapper::NavigationType::get() { - return (CefSharp::NavigationType) _wrappedRequest->GetTransitionType(); + return (CefSharp::TransitionType) _wrappedRequest->GetTransitionType(); } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 2b7196c5f..5e3729229 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -33,7 +33,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } - virtual property CefSharp::NavigationType NavigationType { CefSharp::NavigationType get(); } + virtual property CefSharp::TransitionType NavigationType { CefSharp::TransitionType get(); } }; } diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index e3acd5bf8..ee5c7b180 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -108,7 +108,7 @@ - + diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index 1e61ae601..b31fb865a 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -12,6 +12,6 @@ namespace CefSharp string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } - NavigationType NavigationType { get; } + TransitionType NavigationType { get; } } } diff --git a/CefSharp/NavigationType.cs b/CefSharp/TransitionType.cs similarity index 80% rename from CefSharp/NavigationType.cs rename to CefSharp/TransitionType.cs index a3bd1e137..d8ddfefd4 100644 --- a/CefSharp/NavigationType.cs +++ b/CefSharp/TransitionType.cs @@ -1,6 +1,6 @@ namespace CefSharp { - public enum NavigationType + public enum TransitionType { LinkClicked, FormSubmitted, From 62eb330f53e5416aaf6d8fe2dcc80c94ffa70dd6 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:07:50 +1000 Subject: [PATCH 15/20] Change to using statement rather than namespace qualified declerations --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 4 ++-- CefSharp.Core/Internals/CefRequestWrapper.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index 6e9ac98ad..ba2164059 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -97,9 +97,9 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } - CefSharp::TransitionType CefRequestWrapper::NavigationType::get() + TransitionType CefRequestWrapper::NavigationType::get() { - return (CefSharp::TransitionType) _wrappedRequest->GetTransitionType(); + return (TransitionType) _wrappedRequest->GetTransitionType(); } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 5e3729229..1b530225d 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -9,6 +9,7 @@ using namespace System; using namespace System::Collections::Specialized; +using namespace CefSharp; namespace CefSharp { @@ -33,7 +34,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } - virtual property CefSharp::TransitionType NavigationType { CefSharp::TransitionType get(); } + virtual property TransitionType NavigationType { TransitionType get(); } }; } From 41bfa38f2db274647e817aafdd714fa1b0587e96 Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:09:45 +1000 Subject: [PATCH 16/20] Rename NavigationType property to TransitionType --- CefSharp.Core/Internals/CefRequestWrapper.cpp | 4 ++-- CefSharp.Core/Internals/CefRequestWrapper.h | 3 +-- CefSharp/IRequest.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index ba2164059..fbf2d450a 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -97,9 +97,9 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } - TransitionType CefRequestWrapper::NavigationType::get() + TransitionType CefRequestWrapper::TransitionType::get() { - return (TransitionType) _wrappedRequest->GetTransitionType(); + return (CefSharp::TransitionType) _wrappedRequest->GetTransitionType(); } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 1b530225d..eecb3d00e 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.h +++ b/CefSharp.Core/Internals/CefRequestWrapper.h @@ -34,8 +34,7 @@ namespace CefSharp virtual property String^ Method { String^ get(); } virtual property String^ Body { String^ get(); } virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); } - virtual property TransitionType NavigationType { TransitionType get(); } - + virtual property TransitionType TransitionType { CefSharp::TransitionType get(); } }; } } diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index b31fb865a..a18b7b6f6 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -12,6 +12,6 @@ namespace CefSharp string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } - TransitionType NavigationType { get; } + TransitionType TransitionType { get; } } } From dece1de8448f35ba1da0432346bd39891238115d Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:42:15 +1000 Subject: [PATCH 17/20] Add xml comment to TransitionType --- CefSharp/IRequest.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index a18b7b6f6..050029baf 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -12,6 +12,11 @@ namespace CefSharp string Method { get; } string Body { get; } NameValueCollection Headers { get; set; } + + /// + /// Get the transition type for this request. + /// Applies to requests that represent a main frame or sub-frame navigation. + /// TransitionType TransitionType { get; } } } From dd5b713ad9a824f5be91caddfdb039ac4e4ed1af Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:43:51 +1000 Subject: [PATCH 18/20] Change TransitionType to an unit enum Add [Falgs] attribute as TransitionType can have multiple values Import values from cef_transition_type_t (cef_types.h) Rename some of the values (slightly friendlier names) --- CefSharp/TransitionType.cs | 102 ++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 8 deletions(-) diff --git a/CefSharp/TransitionType.cs b/CefSharp/TransitionType.cs index d8ddfefd4..f289a1f45 100644 --- a/CefSharp/TransitionType.cs +++ b/CefSharp/TransitionType.cs @@ -1,12 +1,98 @@ -namespace CefSharp +using System; + +namespace CefSharp { - public enum TransitionType + [Flags] + public enum TransitionType : uint { - LinkClicked, - FormSubmitted, - BackForward, - Reload, - FormResubmitted, - Other + /// + /// Source is a link click or the JavaScript window.open function. This is + /// also the default value for requests like sub-resource loads that are not navigations. + /// + LinkClicked = 0, + + /// + /// Source is some other "explicit" navigation action such as creating a new + /// browser or using the LoadURL function. This is also the default value + /// for navigations where the actual type is unknown. + /// + Explicit = 1, + + /// + /// Source 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. + /// + AutoSubFrame = 3, + + /// + /// Source is a subframe navigation explicitly requested by the user that will + /// 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. + /// + ManualSubFrame = 4, + + /// + /// Source is a form submission by the user. NOTE: In some situations + /// submitting a form does not result in this transition type. This can happen + /// if the form uses a script to submit the contents. + /// + FormSubmit = 7, + + /// + /// Source is a "reload" of the page via the Reload function or by re-visiting + /// the same URL. NOTE: This is distinct from the concept of whether a + /// particular load uses "reload semantics" (i.e. bypasses cached data). + /// + Reload = 8, + + /// + /// General mask defining the bits used for the source values. + /// + SourceMask = 0xFF, + + /// + /// Attempted to visit a URL but was blocked. + /// + Blocked = 0x00800000, + + /// + /// Used the Forward or Back function to navigate among browsing history. + /// + ForwardBack = 0x01000000, + + /// + /// The beginning of a navigation chain. + /// + ChainStart = 0x10000000, + + /// + /// The last transition in a redirect chain. + /// + ChainEnd = 0x20000000, + + /// + /// Redirects caused by JavaScript or a meta refresh tag on the page. + /// + CliendRedirect = 0x40000000, + + /// + /// Redirects sent from the server by HTTP headers. + /// + ServerRedirect = 0x80000000, + + /// + /// Used to test whether a transition involves a redirect. + /// + IsRedirect = 0xC0000000, + + /// + /// General mask defining the bits used for the qualifiers. + /// + QualifierMask = 0xFFFFFF00 }; } From a43948857c84b963ca057192a274e046db017eee Mon Sep 17 00:00:00 2001 From: amaitland Date: Tue, 4 Nov 2014 12:48:30 +1000 Subject: [PATCH 19/20] Add license disclaimer --- CefSharp/TransitionType.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CefSharp/TransitionType.cs b/CefSharp/TransitionType.cs index f289a1f45..04b6007ec 100644 --- a/CefSharp/TransitionType.cs +++ b/CefSharp/TransitionType.cs @@ -1,4 +1,8 @@ -using System; +// Copyright © 2010-2014 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using System; namespace CefSharp { From a76ada3b1842dce83b912cb0bc9a7b6659bf06dd Mon Sep 17 00:00:00 2001 From: amaitland Date: Thu, 30 Oct 2014 12:07:43 +1000 Subject: [PATCH 20/20] Cleanup Loading and NavState code, there's currently additional calls to both which are slightly confusing (and don't provide any benefit). So simplify by setting SetIsLoading(true) on LoadStart and SetIsLoading(false) on LoadEnd. Then only set NavState in ClientAdapter::OnLoadingStateChange --- CefSharp.Core/Internals/ClientAdapter.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index 69d4ba4c6..f18449c9e 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -66,8 +66,6 @@ namespace CefSharp void ClientAdapter::OnLoadingStateChange(CefRefPtr browser, bool isLoading, bool canGoBack, bool canGoForward) { - _browserControl->SetIsLoading(isLoading); - auto canReload = !isLoading; _browserControl->SetNavState(canGoBack, canGoForward, canReload); } @@ -168,7 +166,6 @@ namespace CefSharp if (frame->IsMain()) { _browserControl->SetIsLoading(true); - _browserControl->SetNavState(false, false, false); } _browserControl->OnFrameLoadStart(StringUtils::ToClr(frame->GetURL()), frame->IsMain());