mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
701d391c59
Added license headers on new files. Remove sync version of GetZoomLevel on ManagedCefBrowserAdapter. Updated callers to call GetZoomLevelAsync() but in a blocking sync manner. Added CurrentlyOn/EnsureOn static methods to CefTaskScheduler.
32 lines
924 B
C++
32 lines
924 B
C++
// Copyright © 2010-2015 The CefSharp Project. All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "Stdafx.h"
|
|
#include "Cef.h"
|
|
|
|
double ManagedCefBrowserAdapter::GetZoomLevel()
|
|
{
|
|
CefTaskScheduler::EnsureOn(TID_UI, "ManagedCefBrowserAdapter::GetZoomLevel");
|
|
|
|
auto browser = _clientAdapter->GetCefBrowser();
|
|
|
|
if (browser != nullptr)
|
|
{
|
|
auto host = browser->GetHost();
|
|
return host->GetZoomLevel();
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
Task<double>^ ManagedCefBrowserAdapter::GetZoomLevelAsync()
|
|
{
|
|
if (CefCurrentlyOn(TID_UI))
|
|
{
|
|
TaskCompletionSource<double>^ taskSource = gcnew TaskCompletionSource<double>();
|
|
taskSource->SetResult(GetZoomLevel());
|
|
return taskSource->Task;
|
|
}
|
|
return Cef::UIThreadTaskFactory->StartNew(gcnew Func<double>(this, &ManagedCefBrowserAdapter::GetZoomLevel));
|
|
}
|