Google Chrome Sync check if enabled via API/Extension?

后端 未结 6 2063
一个人的身影
一个人的身影 2021-01-01 13:14

Is it possible to programmatically check if Chrome Sync is configured in Google Chrome?

The reason I ask is that I am coding an Extension for Chrome that depends on

6条回答
  •  误落风尘
    2021-01-01 14:13

    Chrome now provides chrome.identity.getProfileUserInfo api. You can use this api to check if user is signed into chrome or not. You will need to add identity permission in your manifest.json (though it won't ask user for any extra permission and I think it's because we don't actually use oAuth)

    Here's the code snippet:

    manifest.json

    ....
    "permissions": [
      "identity"
    ]
    ....
    

    background page

    chrome.identity.getProfileUserInfo(function(data) {
        if (data.id) {
            alert("User is signed in to chrome!");
        }
        else
        {
            alert("User is not signed in to chrome.");
        }
    });
    

    It's possible that user is signed in to chrome but has specifically disabled sync but such cases will be very rare. This is the closest method I could find.

提交回复
热议问题