Inside Windows 8.1 Share Contracts
Share contracts are one of many contracts built into the Windows 8.1 (and Windows 8) platform. Contracts, which are a key element to the Win8 platform, are a sort of agreement between one or more apps that allows them to work together. A similar technique to these contracts dates back to 2006.
Microsoft’s then-Chief Software Architect Ray Ozzie came up with the idea of a “universal clipboard.” Since the earliest days of Windows, there’s been a clipboard – a repository for data (of various formats) that’s taken out of one program and put into another. Ozzie’s brilliant insight was that both the sending and receiving programs can agree in advance on a set of specifications about what kind of data was being sent and make it super-simple to transfer all sorts of information from one program to another. Windows would keep track of the specifications and match donors with recipients.
Ozzie’s approach ended up in the public domain, but in Windows 8, Microsoft implemented a similar technique in the Share Charm, which uses the Share contract.
The mechanics of a Share contract are pretty straightforward, although the details can get hairy.
When you install a new program, it tells Windows what kinds of data it can share, and what kinds of data it can receive. So, for example, an e-mail program might tell Windows that it can offer formatted text, or pictures, or links. The same e-mail program might accept formatted text, pictures, links, or web references of a specific type — call it StandardWebReference.
The e-mail program also tells Windows that the StandardWebReference type consists of a small graphic, a link, and formatted text. The Mail programmers are smart enough to know that Internet Explorer 11 (IE 11) has already registered with Windows, telling the Windows Share Broker that it will send out StandardWebReference packets that just happen to have the same characteristics as the StandardWebReference type in the Mail program.
That’s all it takes for a contract. If you’re surfing in IE 11, and you tap the Share Charm, and then choose the Mail program, a packet of information in the StandardWebReference type gets transferred from IE 11 to the Mail program. It ends up looking like the following figure.
There are all sorts of benefits to using Share contracts, but the most important one for Metro users is the fact that you don’t have to select anything before you share: with both the sending and receiving apps running full screen, the Share contract handles all of the details.