diff --git a/CefSharp.Core/Internals/CefRequestWrapper.cpp b/CefSharp.Core/Internals/CefRequestWrapper.cpp index 12adc4dfe..fbf2d450a 100644 --- a/CefSharp.Core/Internals/CefRequestWrapper.cpp +++ b/CefSharp.Core/Internals/CefRequestWrapper.cpp @@ -96,5 +96,10 @@ namespace CefSharp _wrappedRequest->SetHeaderMap(hm); } + + TransitionType CefRequestWrapper::TransitionType::get() + { + return (CefSharp::TransitionType) _wrappedRequest->GetTransitionType(); + } } } diff --git a/CefSharp.Core/Internals/CefRequestWrapper.h b/CefSharp.Core/Internals/CefRequestWrapper.h index 6925a284e..eecb3d00e 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 TransitionType TransitionType { CefSharp::TransitionType get(); } }; } } diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index 5393b104a..5e21ec21a 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -67,8 +67,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); } @@ -169,7 +167,6 @@ namespace CefSharp if (frame->IsMain()) { _browserControl->SetIsLoading(true); - _browserControl->SetNavState(false, false, false); } _browserControl->OnFrameLoadStart(StringUtils::ToClr(frame->GetURL()), frame->IsMain()); diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index ef8848842..eecb2478b 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. @@ -87,21 +87,24 @@ namespace CefSharp cefFrame->LoadURL(StringUtils::ToNative(address)); } } - + void OnAfterBrowserCreated(int browserId) { _browserProcessServiceHost = gcnew BrowserProcessServiceHost(_javaScriptObjectRepository, Process::GetCurrentProcess()->Id, browserId); _browserProcessServiceHost->Open(); - _webBrowserInternal->OnInitialized(); - - auto address = _address; - - if (address != nullptr) + if(_webBrowserInternal != nullptr) { - LoadUrl(address); + _webBrowserInternal->OnInitialized(); + + auto address = _address; + + if (address != nullptr) + { + LoadUrl(address); + } } - }; + } void LoadHtml(String^ html, String^ url) { diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index cead85d64..5bef8c830 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -109,6 +109,7 @@ + diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index 33595a3cc..050029baf 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -12,5 +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; } } } diff --git a/CefSharp/TransitionType.cs b/CefSharp/TransitionType.cs new file mode 100644 index 000000000..04b6007ec --- /dev/null +++ b/CefSharp/TransitionType.cs @@ -0,0 +1,102 @@ +// 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 +{ + [Flags] + public enum TransitionType : uint + { + /// + /// 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 + }; +}