~ps-jenkins/unity-chromium-extension/trusty-proposed

« back to all changes in this revision

Viewing changes to chromium-extension/infobar.js

  • Committer: Tarmac
  • Author(s): Alexandre Abreu
  • Date: 2013-07-11 18:50:30 UTC
  • mfrom: (224.1.2 fix-chromium-28-support)
  • Revision ID: tarmac-20130711185030-rgajj7lnqnjgblt8
Fix issue w/ installation (when message is being sent to background page from infobar, the sender.tab object is not set); updated some apis to newer versions. Fixes: https://bugs.launchpad.net/bugs/1196943.

Approved by Víctor R. Ruiz, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
var doIntegrate = function (integrate) {
2
2
  chrome.tabs.getCurrent (function (tab) {
3
 
    chrome.extension.sendMessage ({tabId: tab.id, method: "on_user_infobar_request_result", integrate: integrate}
 
3
    chrome.runtime.sendMessage ({tabId: tab.id, method: "on_user_infobar_request_result", integrate: integrate}
4
4
                                 , function (response) {});
5
5
    window.close();
6
6
  });
7
7
};
8
8
 
9
9
window.onload = function () {
10
 
  var bg = chrome.extension.getBackgroundPage();
11
 
  document.getElementById('notintegrate').onclick = function () { doIntegrate(false); };
12
 
  document.getElementById('integrate').onclick = function () { doIntegrate(true); };
13
 
  chrome.tabs.getCurrent (function (tab) {
14
 
    if (!bg|| !bg.background_page) {
15
 
      window.close();
16
 
      return;
17
 
    }
18
 
    var msg = bg.background_page.getMessageForTabId(tab.id);
19
 
    if (msg == null) {
20
 
      window.close();
21
 
      return;
22
 
    }
23
 
    document.getElementById ('content').style.display = "block";
24
 
    document.getElementById ('message').innerHTML = msg || "";
 
10
  chrome.runtime.getBackgroundPage(function (bg) {
 
11
      document.getElementById('notintegrate').onclick = function () { doIntegrate(false); };
 
12
      document.getElementById('integrate').onclick = function () { doIntegrate(true); };
 
13
 
 
14
      chrome.tabs.getCurrent (function (tab) {
 
15
          if (!bg|| !bg.background_page) {
 
16
              window.close();
 
17
              return;
 
18
          }
 
19
          var msg = bg.background_page.getMessageForTabId(tab.id);
 
20
          if (msg == null) {
 
21
              window.close();
 
22
              return;
 
23
          }
 
24
          document.getElementById ('content').style.display = "block";
 
25
          document.getElementById ('message').innerHTML = msg || "";
 
26
      });
25
27
  });
26
28
};
27
29