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

Unified Diff: remoting/webapp/background/background.js

Issue 450383003: Hangout remote desktop part II - background.html and AppLauncher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address 2nd round feedbacks Created 6 years, 4 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 | « remoting/webapp/background/app_launcher.js ('k') | remoting/webapp/base.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/background/background.js
diff --git a/remoting/webapp/background/background.js b/remoting/webapp/background/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..5f2678898e2a13f6e782b0c85e16586463091920
--- /dev/null
+++ b/remoting/webapp/background/background.js
@@ -0,0 +1,57 @@
+// Copyright 2014 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.
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+(function(){
+
+/** @return {boolean} */
+function isAppsV2() {
+ var manifest = chrome.runtime.getManifest();
+ if (manifest && manifest.app && manifest.app.background) {
+ return true;
+ }
+ return false;
+}
+
+/** @param {remoting.AppLauncher} appLauncher */
+function initializeAppV2(appLauncher) {
+ /** @type {string} */
+ var kNewWindowId = 'new-window';
+
+ /** @param {OnClickData} info */
+ function onContextMenu(info) {
+ if (info.menuItemId == kNewWindowId) {
+ appLauncher.launch();
+ }
+ }
+
+ function initializeContextMenu() {
+ chrome.contextMenus.create({
+ id: kNewWindowId,
+ contexts: ['launcher'],
+ title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
+ });
+ chrome.contextMenus.onClicked.addListener(onContextMenu);
+ }
+
+ initializeContextMenu();
+ chrome.app.runtime.onLaunched.addListener(
+ appLauncher.launch.bind(appLauncher)
+ );
+}
+
+function main() {
+ /** @type {remoting.AppLauncher} */
+ var appLauncher = new remoting.V1AppLauncher();
+ if (isAppsV2()) {
+ appLauncher = new remoting.V2AppLauncher();
+ initializeAppV2(appLauncher);
+ }
+}
+
+window.addEventListener('load', main, false);
+
+}());
« no previous file with comments | « remoting/webapp/background/app_launcher.js ('k') | remoting/webapp/base.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698