| OLD | NEW |
| 1 <div id="pageData-name" class="pageData">Storage</div> | 1 <div id="pageData-name" class="pageData">Storage</div> |
| 2 | 2 |
| 3 <!-- BEGIN AUTHORED CONTENT --> | 3 <!-- BEGIN AUTHORED CONTENT --> |
| 4 <p id="classSummary"> | 4 <p id="classSummary"> |
| 5 Use the <code>chrome.storage</code> module | 5 Use the <code>chrome.storage</code> module |
| 6 to store, retrieve, and track changes to user data. | 6 to store, retrieve, and track changes to user data. |
| 7 This API has been optimized | 7 This API has been optimized |
| 8 to meet the specific storage needs of extensions. | 8 to meet the specific storage needs of extensions. |
| 9 It provides the same storage capabilities as the | 9 It provides the same storage capabilities as the |
| 10 <a href="https://developer.mozilla.org/en/DOM/Storage#localStorage">localStorage
API</a> | 10 <a href="https://developer.mozilla.org/en/DOM/Storage#localStorage">localStorage
API</a> |
| 11 with the following key differences: | 11 with the following key differences: |
| 12 </p> | 12 </p> |
| 13 | 13 |
| 14 <ul> | 14 <ul> |
| 15 <li>User data can be automatically synced with Chrome sync | 15 <li>User data can be automatically synced with Chrome sync |
| 16 (using <code>storage.sync</code>).</li> | 16 (using <code>storage.sync</code>).</li> |
| 17 <li>Your extension's content scripts can directly access user data | 17 <li>Your extension's content scripts can directly access user data |
| 18 without the need for a background page.</li> | 18 without the need for a background page.</li> |
| 19 <li>A user's extension settings can be persisted | 19 <li>A user's extension settings can be persisted |
| 20 even when using | 20 even when using |
| 21 <a href="manifest.html#incognito">split incognito behavior</a>.</li> | 21 <a href="manifest.html#incognito">split incognito behavior</a>.</li> |
| 22 <li>User data can be stored as objects | 22 <li>User data can be stored as objects |
| 23 (the <code>localStorage API</code> stores data in strings).</li> | 23 (the <code>localStorage API</code> stores data in strings).</li> |
| 24 <li>Domain policies configured by the administrator for the extension | |
| 25 can be read (using <code>storage.managed</code>).</li> | |
| 26 </ul> | 24 </ul> |
| 27 | 25 |
| 28 <h2 id="manifest">Manifest</h2> | 26 <h2 id="manifest">Manifest</h2> |
| 29 <p>You must declare the "storage" permission in the <a | 27 <p>You must declare the "storage" permission in the <a |
| 30 href="manifest.html">extension manifest</a> | 28 href="manifest.html">extension manifest</a> |
| 31 to use the storage API. | 29 to use the storage API. |
| 32 For example:</p> | 30 For example:</p> |
| 33 <pre>{ | 31 <pre>{ |
| 34 "name": "My extension", | 32 "name": "My extension", |
| 35 ... | 33 ... |
| (...skipping 25 matching lines...) Expand all Loading... |
| 61 <code>storage.sync</code> will still work. | 59 <code>storage.sync</code> will still work. |
| 62 In this case, it will behave identically | 60 In this case, it will behave identically |
| 63 to <code>storage.local</code>. | 61 to <code>storage.local</code>. |
| 64 </p> | 62 </p> |
| 65 | 63 |
| 66 <p class="warning"> | 64 <p class="warning"> |
| 67 Confidential user information should not be stored! | 65 Confidential user information should not be stored! |
| 68 The storage area isn't encrypted. | 66 The storage area isn't encrypted. |
| 69 </p> | 67 </p> |
| 70 | 68 |
| 71 <p> | |
| 72 The <code>storage.managed</code> is a read-only | |
| 73 storage that contains settings configured by the | |
| 74 domain administrator for the extension. Enforcing | |
| 75 these settings allows administrators to configure | |
| 76 your extension on enterprise deployments. | |
| 77 </p> | |
| 78 | |
| 79 <h2 id="limits">Storage and throttling limits</h2> | 69 <h2 id="limits">Storage and throttling limits</h2> |
| 80 | 70 |
| 81 <p><code>chrome.storage</code> is not a big truck. | 71 <p><code>chrome.storage</code> is not a big truck. |
| 82 It's a series of tubes. | 72 It's a series of tubes. |
| 83 And if you don't understand, | 73 And if you don't understand, |
| 84 those tubes can be filled, | 74 those tubes can be filled, |
| 85 and if they are filled | 75 and if they are filled |
| 86 when you put your message in, | 76 when you put your message in, |
| 87 it gets in line, | 77 it gets in line, |
| 88 and it's going to be delayed | 78 and it's going to be delayed |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 135 } |
| 146 }); | 136 }); |
| 147 </pre> | 137 </pre> |
| 148 | 138 |
| 149 <p> | 139 <p> |
| 150 You can find examples that use this API on the | 140 You can find examples that use this API on the |
| 151 <a href="samples.html#sty">Samples page</a>. | 141 <a href="samples.html#sty">Samples page</a>. |
| 152 </p> | 142 </p> |
| 153 | 143 |
| 154 <!-- END AUTHORED CONTENT --> | 144 <!-- END AUTHORED CONTENT --> |
| OLD | NEW |