-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cast2Class] Add page handler for enterprise casting WebUI.
Stub implementation for the WebUI and page handler, to ensure we have the mojom, WebUI, and page handler communicating correctly. Additionally, add ChromeOS EDU team as OWNERS of the enterprise casting resources folder. Bug: b/193421383 Change-Id: I346203207f657b0ab1755cf46677749d6a916684 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3064083 Reviewed-by: calamity <calamity@chromium.org> Reviewed-by: Brian Malcolm <bmalcolm@chromium.org> Reviewed-by: Sam McNally <sammc@chromium.org> Commit-Queue: Benjamin Zielinski <bzielinski@google.com> Cr-Commit-Position: refs/heads/master@{#909038}
- Loading branch information
Benjamin Zielinski
authored and
Chromium LUCI CQ
committed
Aug 5, 2021
1 parent
2d63471
commit 2424a7a
Showing
13 changed files
with
230 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gbj@google.com | ||
bmalcolm@chromium.org | ||
bzielinski@google.com | ||
jacqueli@google.com |
31 changes: 31 additions & 0 deletions
31
chrome/browser/resources/chromeos/enterprise_casting/browser_proxy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2021 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. | ||
|
||
import {PageCallbackRouter, PageHandlerFactory, PageHandlerRemote} from './enterprise_casting.mojom-webui.js'; | ||
|
||
export class BrowserProxy { | ||
callbackRouter: PageCallbackRouter; | ||
handler: PageHandlerRemote; | ||
|
||
constructor() { | ||
this.callbackRouter = new PageCallbackRouter(); | ||
|
||
this.handler = new PageHandlerRemote(); | ||
|
||
const factory = PageHandlerFactory.getRemote(); | ||
factory.createPageHandler( | ||
this.callbackRouter.$.bindNewPipeAndPassRemote(), | ||
this.handler.$.bindNewPipeAndPassReceiver()); | ||
} | ||
|
||
static getInstance(): BrowserProxy { | ||
return instance || (instance = new BrowserProxy()); | ||
} | ||
|
||
static setInstance(obj: BrowserProxy) { | ||
instance = obj; | ||
} | ||
} | ||
|
||
let instance: BrowserProxy|null = null; |
3 changes: 3 additions & 0 deletions
3
chrome/browser/resources/chromeos/enterprise_casting/enterprise_casting.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Cast Receiver</h1> | ||
<div id="castingPin">Casting PIN: [[pin]]</div> | ||
<button id="newPin" on-click="requestPin">Generate New PIN</button> |
58 changes: 58 additions & 0 deletions
58
chrome/browser/resources/chromeos/enterprise_casting/enterprise_casting.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2021 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. | ||
|
||
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; | ||
|
||
import {BrowserProxy} from './browser_proxy.js'; | ||
import {PageCallbackRouter} from './enterprise_casting.mojom-webui.js'; | ||
|
||
class EnterpriseCastingElement extends PolymerElement { | ||
static get is() { | ||
return 'enterprise-casting'; | ||
} | ||
|
||
static get template() { | ||
return html`{__html_template__}`; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
pin: String, | ||
}; | ||
} | ||
|
||
private pin: string; | ||
private listenerIds: Array<number>; | ||
private router: PageCallbackRouter; | ||
|
||
constructor() { | ||
super(); | ||
this.pin = ''; | ||
this.listenerIds = []; | ||
this.router = BrowserProxy.getInstance().callbackRouter; | ||
} | ||
|
||
connectedCallback() { | ||
super.connectedCallback(); | ||
this.listenerIds.push( | ||
this.router.setPin.addListener(this.setPin.bind(this))); | ||
} | ||
|
||
disconnectedCallback() { | ||
super.disconnectedCallback(); | ||
this.listenerIds.forEach(id => this.router.removeListener(id)); | ||
} | ||
|
||
requestPin() { | ||
BrowserProxy.getInstance().handler.updatePin(); | ||
} | ||
|
||
private setPin(pin: string) { | ||
if (this.pin != pin) { | ||
this.pin = pin; | ||
} | ||
} | ||
} | ||
|
||
customElements.define(EnterpriseCastingElement.is, EnterpriseCastingElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
chrome/browser/resources/chromeos/enterprise_casting/tsconfig_base.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../../../../tools/typescript/tsconfig_base.json", | ||
"compilerOptions": { | ||
"allowJs": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
chrome/browser/ui/webui/chromeos/enterprise_casting/enterprise_casting_handler.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2021 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. | ||
|
||
#include "chrome/browser/ui/webui/chromeos/enterprise_casting/enterprise_casting_handler.h" | ||
|
||
#include "base/rand_util.h" | ||
#include "base/strings/string_number_conversions.h" | ||
|
||
namespace chromeos { | ||
|
||
EnterpriseCastingHandler::EnterpriseCastingHandler( | ||
mojo::PendingReceiver<enterprise_casting::mojom::PageHandler> page_handler, | ||
mojo::PendingRemote<enterprise_casting::mojom::Page> page) | ||
: page_(std::move(page)), receiver_(this, std::move(page_handler)) {} | ||
|
||
EnterpriseCastingHandler::~EnterpriseCastingHandler() = default; | ||
|
||
void EnterpriseCastingHandler::UpdatePin() { | ||
page_->SetPin(base::NumberToString(base::RandInt(0, 9999))); | ||
} | ||
|
||
} // namespace chromeos |
34 changes: 34 additions & 0 deletions
34
chrome/browser/ui/webui/chromeos/enterprise_casting/enterprise_casting_handler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 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. | ||
|
||
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ENTERPRISE_CASTING_ENTERPRISE_CASTING_HANDLER_H_ | ||
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ENTERPRISE_CASTING_ENTERPRISE_CASTING_HANDLER_H_ | ||
|
||
#include "base/scoped_observation.h" | ||
#include "chrome/browser/ui/app_list/search/search_controller.h" | ||
#include "chrome/browser/ui/webui/chromeos/enterprise_casting/enterprise_casting.mojom.h" | ||
#include "mojo/public/cpp/bindings/pending_remote.h" | ||
#include "mojo/public/cpp/bindings/remote.h" | ||
|
||
namespace chromeos { | ||
|
||
class EnterpriseCastingHandler : public enterprise_casting::mojom::PageHandler { | ||
public: | ||
EnterpriseCastingHandler( | ||
mojo::PendingReceiver<enterprise_casting::mojom::PageHandler> | ||
page_handler, | ||
mojo::PendingRemote<enterprise_casting::mojom::Page> page); | ||
~EnterpriseCastingHandler() override; | ||
|
||
// enterprise_casting::mojom::PageHandler : | ||
void UpdatePin() override; | ||
|
||
private: | ||
mojo::Remote<enterprise_casting::mojom::Page> page_; | ||
mojo::Receiver<enterprise_casting::mojom::PageHandler> receiver_; | ||
}; | ||
|
||
} // namespace chromeos | ||
|
||
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ENTERPRISE_CASTING_ENTERPRISE_CASTING_HANDLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters