forked from firka/flutter
Add support for VIEW intents to SkyShell.
This was landed on the skyshell branch and I forgot to pull it over: https://codereview.chromium.org/946583003 TBR=abarth@chromium.org Review URL: https://codereview.chromium.org/954893002
This commit is contained in:
@@ -19,6 +19,11 @@
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="sky" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -109,6 +109,10 @@ public class PlatformView extends SurfaceView {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void loadUrl(String url) {
|
||||
mViewportObserver.loadUrl(url);
|
||||
}
|
||||
|
||||
private void attach() {
|
||||
Core core = CoreImpl.getInstance();
|
||||
Pair<ViewportObserver.Proxy, InterfaceRequest<ViewportObserver>> result =
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
package org.domokit.sky.shell;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
@@ -18,7 +20,17 @@ public class SkyShellActivity extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
String url = "https://domokit.github.io/home";
|
||||
Intent intent = getIntent();
|
||||
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
Uri skyUri = intent.getData();
|
||||
Uri httpsUri = skyUri.buildUpon().scheme("https").build();
|
||||
url = httpsUri.toString();
|
||||
}
|
||||
|
||||
SkyMain.ensureInitialized(getApplicationContext());
|
||||
setContentView(new PlatformView(this));
|
||||
PlatformView view = new PlatformView(this);
|
||||
setContentView(view);
|
||||
view.loadUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,11 +39,6 @@ void Engine::Init(mojo::ScopedMessagePipeHandle service_provider) {
|
||||
platform_impl_.reset(new PlatformImpl(
|
||||
mojo::MakeProxy<mojo::ServiceProvider>(service_provider.Pass())));
|
||||
blink::initialize(platform_impl_.get());
|
||||
|
||||
web_view_ = blink::WebView::create(this);
|
||||
web_view_->setMainFrame(blink::WebLocalFrame::create(this));
|
||||
web_view_->mainFrame()->load(
|
||||
GURL("http://domokit.github.io/sky/examples/spinning-square.sky"));
|
||||
}
|
||||
|
||||
void Engine::BeginFrame(base::TimeTicks frame_time) {
|
||||
@@ -76,8 +71,15 @@ void Engine::OnViewportMetricsChanged(int width, int height,
|
||||
float device_pixel_ratio) {
|
||||
physical_size_.SetSize(width, height);
|
||||
device_pixel_ratio_ = device_pixel_ratio;
|
||||
web_view_->setDeviceScaleFactor(device_pixel_ratio);
|
||||
gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio);
|
||||
if (web_view_)
|
||||
UpdateWebViewSize();
|
||||
}
|
||||
|
||||
void Engine::UpdateWebViewSize()
|
||||
{
|
||||
CHECK(web_view_);
|
||||
web_view_->setDeviceScaleFactor(device_pixel_ratio_);
|
||||
gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio_);
|
||||
// FIXME: We should be able to set the size of the WebView in floating point
|
||||
// because its in logical pixels.
|
||||
web_view_->resize(blink::WebSize(size.width(), size.height()));
|
||||
@@ -91,6 +93,13 @@ void Engine::OnInputEvent(InputEventPtr event) {
|
||||
web_view_->handleInputEvent(*web_event);
|
||||
}
|
||||
|
||||
void Engine::LoadURL(const mojo::String& url) {
|
||||
web_view_ = blink::WebView::create(this);
|
||||
web_view_->setMainFrame(blink::WebLocalFrame::create(this));
|
||||
UpdateWebViewSize();
|
||||
web_view_->mainFrame()->load(GURL(url));
|
||||
}
|
||||
|
||||
void Engine::initializeLayerTreeView() {
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,14 @@ class Engine : public UIDelegate,
|
||||
void OnViewportMetricsChanged(int width, int height,
|
||||
float device_pixel_ratio) override;
|
||||
void OnInputEvent(InputEventPtr event) override;
|
||||
void LoadURL(const mojo::String& url) override;
|
||||
|
||||
// WebViewClient methods:
|
||||
void initializeLayerTreeView() override;
|
||||
void scheduleVisualUpdate() override;
|
||||
|
||||
void UpdateWebViewSize();
|
||||
|
||||
scoped_ptr<PlatformImpl> platform_impl_;
|
||||
scoped_ptr<Animator> animator_;
|
||||
blink::WebView* web_view_;
|
||||
|
||||
Reference in New Issue
Block a user