Commit 3dd7e357 authored by Reka Norman's avatar Reka Norman Committed by Commit Bot

[App Management] Add FakePageHandler

This CL adds a fake page handler to the app management page which is used when
accessing chrome://apps?fakeBackend=true.

Bug: 906508
Change-Id: Ib92a66a45b312efd14b5fb038d7cc506944dd716
Reviewed-on: https://chromium-review.googlesource.com/c/1360034
Commit-Queue: calamity <calamity@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#614293}
parent 2b2cd20b
...@@ -220,6 +220,7 @@ ...@@ -220,6 +220,7 @@
<include name="IDR_APP_MANAGEMENT_APP_JS" file="resources\app_management\app.js" type="BINDATA" /> <include name="IDR_APP_MANAGEMENT_APP_JS" file="resources\app_management\app.js" type="BINDATA" />
<include name="IDR_APP_MANAGEMENT_BROWSER_PROXY_HTML" file="resources\app_management\browser_proxy.html" type="BINDATA" /> <include name="IDR_APP_MANAGEMENT_BROWSER_PROXY_HTML" file="resources\app_management\browser_proxy.html" type="BINDATA" />
<include name="IDR_APP_MANAGEMENT_BROWSER_PROXY_JS" file="resources\app_management\browser_proxy.js" type="BINDATA" /> <include name="IDR_APP_MANAGEMENT_BROWSER_PROXY_JS" file="resources\app_management\browser_proxy.js" type="BINDATA" />
<include name="IDR_APP_MANAGEMENT_FAKE_PAGE_HANDLER_JS" file="resources\app_management\fake_page_handler.js" type="BINDATA" />
<include name="IDR_APP_MANAGEMENT_INDEX_HTML" file="resources\app_management\index.html" type="BINDATA" /> <include name="IDR_APP_MANAGEMENT_INDEX_HTML" file="resources\app_management\index.html" type="BINDATA" />
<include name="IDR_APP_MANAGEMENT_MAIN_VIEW_HTML" file="resources\app_management\main_view.html" type="BINDATA" /> <include name="IDR_APP_MANAGEMENT_MAIN_VIEW_HTML" file="resources\app_management\main_view.html" type="BINDATA" />
<include name="IDR_APP_MANAGEMENT_MAIN_VIEW_JS" file="resources\app_management\main_view.js" type="BINDATA" /> <include name="IDR_APP_MANAGEMENT_MAIN_VIEW_JS" file="resources\app_management\main_view.js" type="BINDATA" />
......
...@@ -9,6 +9,7 @@ js_type_check("closure_compile") { ...@@ -9,6 +9,7 @@ js_type_check("closure_compile") {
deps = [ deps = [
":app", ":app",
":browser_proxy", ":browser_proxy",
":fake_page_handler",
":main_view", ":main_view",
] ]
} }
...@@ -23,6 +24,7 @@ js_library("app") { ...@@ -23,6 +24,7 @@ js_library("app") {
js_library("browser_proxy") { js_library("browser_proxy") {
deps = [ deps = [
":externs", ":externs",
":fake_page_handler",
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr",
] ]
} }
...@@ -36,6 +38,13 @@ js_library("externs") { ...@@ -36,6 +38,13 @@ js_library("externs") {
] ]
} }
js_library("fake_page_handler") {
deps = [
":externs",
"//ui/webui/resources/js:cr",
]
}
js_library("main_view") { js_library("main_view") {
deps = [] deps = []
} }
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<script src="browser_proxy.js"></script> <script src="browser_proxy.js"></script>
<script src="fake_page_handler.js"></script>
<script src="chrome://resources/js/mojo_bindings_lite.js"></script> <script src="chrome://resources/js/mojo_bindings_lite.js"></script>
<script src="app_management.mojom-lite.js"></script> <script src="app_management.mojom-lite.js"></script>
...@@ -7,11 +7,21 @@ cr.define('app_management', function() { ...@@ -7,11 +7,21 @@ cr.define('app_management', function() {
constructor() { constructor() {
/** @type {appManagement.mojom.PageCallbackRouter} */ /** @type {appManagement.mojom.PageCallbackRouter} */
this.callbackRouter = new appManagement.mojom.PageCallbackRouter(); this.callbackRouter = new appManagement.mojom.PageCallbackRouter();
/** @type {appManagement.mojom.PageHandlerProxy} */
this.handler = new appManagement.mojom.PageHandlerProxy(); /** @type {appManagement.mojom.PageHandlerInterface} */
const factory = appManagement.mojom.PageHandlerFactory.getProxy(); this.handler = null;
factory.createPageHandler(
this.callbackRouter.createProxy(), this.handler.createRequest()); const urlParams = new URLSearchParams(window.location.search);
const useFake = urlParams.get('fakeBackend');
if (useFake) {
this.handler = new app_management.FakePageHandler(
this.callbackRouter.createProxy());
} else {
this.handler = new appManagement.mojom.PageHandlerProxy();
const factory = appManagement.mojom.PageHandlerFactory.getProxy();
factory.createPageHandler(
this.callbackRouter.createProxy(), this.handler.createRequest());
}
} }
} }
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('app_management', function() {
/** @implements {appManagement.mojom.PageHandlerInterface} */
class FakePageHandler {
constructor(page) {
/** @type {appManagement.mojom.PageInterface} */
this.page = page;
}
getApps() {
this.page.onAppsAdded(['asdfghjkl']);
}
}
return {FakePageHandler: FakePageHandler};
});
...@@ -33,6 +33,8 @@ content::WebUIDataSource* CreateAppManagementUIHTMLSource(Profile* profile) { ...@@ -33,6 +33,8 @@ content::WebUIDataSource* CreateAppManagementUIHTMLSource(Profile* profile) {
IDR_APP_MANAGEMENT_BROWSER_PROXY_HTML); IDR_APP_MANAGEMENT_BROWSER_PROXY_HTML);
source->AddResourcePath("browser_proxy.js", source->AddResourcePath("browser_proxy.js",
IDR_APP_MANAGEMENT_BROWSER_PROXY_JS); IDR_APP_MANAGEMENT_BROWSER_PROXY_JS);
source->AddResourcePath("fake_page_handler.js",
IDR_APP_MANAGEMENT_FAKE_PAGE_HANDLER_JS);
source->AddResourcePath("main_view.html", IDR_APP_MANAGEMENT_MAIN_VIEW_HTML); source->AddResourcePath("main_view.html", IDR_APP_MANAGEMENT_MAIN_VIEW_HTML);
source->AddResourcePath("main_view.js", IDR_APP_MANAGEMENT_MAIN_VIEW_JS); source->AddResourcePath("main_view.js", IDR_APP_MANAGEMENT_MAIN_VIEW_JS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment