Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(967)

Unified Diff: examples/js/show_image.js

Issue 848513004: Mojo JS Bindings: URL class (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/js/README.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/js/show_image.js
diff --git a/examples/js/show_image.js b/examples/js/show_image.js
index e0edf5f76ea4a134a6036555b44fbae075db5f20..3e101944043c211fc1775f33373cb22c9cb4a7d9 100644
--- a/examples/js/show_image.js
+++ b/examples/js/show_image.js
@@ -14,33 +14,22 @@ define("main", [
"mojo/services/public/js/application",
"mojo/services/public/js/service_provider",
"mojo/services/window_manager/public/interfaces/window_manager.mojom",
-], function(application, serviceProvider, windowManager) {
+ "third_party/js/url",
+], function(application, serviceProvider, windowManager, url) {
const Application = application.Application;
const ServiceProvider = serviceProvider.ServiceProvider;
const WindowManager = windowManager.WindowManager;
+ const URL = url.URL;
const defaultImageURL =
"http://upload.wikimedia.org/wikipedia/commons/8/87/Google_Chrome_icon_%282011%29.png";
- var windowManager;
- var windowManagerSP;
-
- class WindowManagerClientImpl {
- // An empty stub for now.
- }
-
class ShowImage extends Application {
initialize() {
- var imageURLKey = "?url=";
- var imageURLIndex = this.url.indexOf(imageURLKey);
- var imageURL = (imageURLIndex == -1) ? defaultImageURL :
- this.url.substring(imageURLIndex + imageURLKey.length);
-
- windowManager = this.shell.connectToService(
- "mojo:window_manager", WindowManager, new WindowManagerClientImpl);
- windowManager.embed(imageURL, function(spProxy) {
- windowManagerSP = new ServiceProvider(spProxy);
- });
+ var imageURL = new URL(this.url, true).query.url || defaultImageURL;
+ var windowManager = this.shell.connectToService(
+ "mojo:window_manager", WindowManager, {} /* empty WindowManagerClient */);
+ windowManager.embed(imageURL, function() { /* no ServiceProvider */ });
// Displaying imageURL is now the responsibility of the Mojo application
// launched by its content handler. We're done.
« no previous file with comments | « no previous file | third_party/js/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698