提交 8aa3caf3 编写于 作者: E Eric Seidel

Make SkyView vs. WebView controlable via url path

We're currently in a transition between using main.sky and main.dart
files as our main() entry point for Sky applications.

This CL makes this runtime controlable by path name.  If it finds
a .dart in the path name it will use SkyView, otherwise it will
fall back to the existing WebView codepath.

SkyView does not expose a window object and much of the existing
Sky Engine is not initialized when main() is run.  Clients should
be transitioning away from main.sky towards main.dart in the near
future, however main.dart is probably not ready for general
consumption at this point.

R=ianh@google.com

Review URL: https://codereview.chromium.org/1152313002
上级 0928b28f
......@@ -37,6 +37,8 @@
#include "sky/engine/public/web/WebPageVisibilityState.h"
#include "sky/engine/public/web/WebWidget.h"
class GURL;
namespace blink {
class WebFrame;
......@@ -48,6 +50,9 @@ struct WebPoint;
class WebView : public WebWidget {
public:
// I've added this here so that it dies when WebView does. :)
static bool shouldUseWebView(const GURL& url);
// Initialization ------------------------------------------------------
// Creates a WebView that is NOT yet initialized. You will need to
......
......@@ -83,6 +83,7 @@
#include "sky/engine/wtf/CurrentTime.h"
#include "sky/engine/wtf/RefPtr.h"
#include "sky/engine/wtf/TemporaryChange.h"
#include "url/gurl.h"
// Get rid of WTF's pow define so we can use std::pow.
#undef pow
......@@ -92,6 +93,20 @@ namespace blink {
// WebView ----------------------------------------------------------------
bool WebView::shouldUseWebView(const GURL& url)
{
std::string filename = url.ExtractFileName();
int hashStart = filename.find('#');
if (hashStart != -1)
filename.resize(hashStart);
int queryStart = filename.find('?');
if (queryStart != -1)
filename.resize(queryStart);
// For now .dart indicates we should use SkyView. Eventually we'll
// use SkyView for all urls regardless of file extension.
return !EndsWith(filename, ".dart", false);
}
WebView* WebView::create(WebViewClient* client)
{
// Pass the WebViewImpl's self-reference to the caller.
......
......@@ -171,13 +171,14 @@ void Engine::OnInputEvent(InputEventPtr event) {
}
void Engine::LoadURL(const mojo::String& url) {
// Enable SkyView here.
if (false) {
if (!WebView::shouldUseWebView(responseURL)) {
sky_view_ = blink::SkyView::Create(this);
sky_view_->Load(GURL(url));
return;
}
LOG(WARNING) << ".sky support is deprecated, please use .dart for main()";
// Something bad happens if you try to call WebView::close and replace
// the webview. So for now we just load into the existing one. :/
if (!web_view_)
......
......@@ -158,21 +158,24 @@ void DocumentView::OnEmbed(
void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) {
// TODO(aa): Need to figure out how shutdown works.
}
void DocumentView::Load(mojo::URLResponsePtr response) {
// Enable SkyView here.
if (false) {
GURL responseURL(response->url);
if (!blink::WebView::shouldUseWebView(responseURL)) {
sky_view_ = blink::SkyView::Create(this);
initializeLayerTreeView();
sky_view_->Load(GURL(response->url), response.Pass());
sky_view_->Load(responseURL, response.Pass());
return;
}
if (!RuntimeFlags::Get().testing())
LOG(WARNING) << ".sky support is deprecated, please use .dart for main()";
web_view_ = blink::WebView::create(this);
ConfigureSettings(web_view_->settings());
web_view_->setMainFrame(blink::WebLocalFrame::create(this));
web_view_->mainFrame()->loadFromDataPipeWithURL(
response->body.Pass(), GURL(response->url));
response->body.Pass(), responseURL);
}
void DocumentView::initializeLayerTreeView() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册