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

Unified Diff: remoting/client/extension/background.js

Issue 6532042: Make chromoting connect always work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 9 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/extension/background.js
diff --git a/remoting/client/extension/background.js b/remoting/client/extension/background.js
index b8b400d5c70f90824a5d054e404a980f5a4c137c..f41740794a2ac731486d65ef35e8d9b8a57b32c2 100644
--- a/remoting/client/extension/background.js
+++ b/remoting/client/extension/background.js
@@ -63,11 +63,29 @@ function openChromotingTab(hostName, hostJid) {
" hostName='" + request.hostName + "'" +
" hostJid='" + request.hostJid + "'" +
" auth_token='" + request.xmppAuth + "'");
- navigate(newTabUrl, function(tab) {
- console.log("We're trying now to send to " + tab.id);
- chrome.tabs.sendRequest(
- tab.id, request, function() {
- console.log('Tab finished connect.');
- });
- });
+
+ var sendRequestFunc = function (tab) {
+ console.log("We're trying now to send to " + tab.id);
+ chrome.tabs.sendRequest(
+ tab.id, request, function() {
+ console.log('Tab finished connect.');
+ });
+ };
+
+ // This function will run when after the url for the tab is updated. If
+ // the tab is not yet loaded it will wait for another 500ms to inspect
+ // again.
+ var checkStatusFunc = function (tab) {
+ if (tab.status == "complete") {
+ sendRequestFunc(tab);
+ return;
+ }
+
+ // Wait for 500ms and then get the tab and check its status.
+ setTimeout(function() {
+ chrome.tabs.get(tab.id, checkStatusFunc);
+ }, 500);
+ }
+
+ navigate(newTabUrl, checkStatusFunc);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698