diff options
| author | Stephen Blott | 2016-02-11 07:34:36 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-02-11 07:34:36 +0000 |
| commit | aabd2068e4ba497c9ad7d237a727121fd573b837 (patch) | |
| tree | 43c08529d3bdf39b5dcc427eed6300ef573ad4be /lib | |
| parent | b6a0cc82d138dd67a77d8e3298c6f56362e729be (diff) | |
| parent | 2aa6af6d9f1b7394be460d66d34166451f04d2b2 (diff) | |
| download | vimium-aabd2068e4ba497c9ad7d237a727121fd573b837.tar.bz2 | |
Merge pull request #1977 from mrmr1993/help-dialog-uicomponent
Move help dialog to a UIComponent
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/settings.coffee | 4 | ||||
| -rw-r--r-- | lib/utils.coffee | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/settings.coffee b/lib/settings.coffee index dd1aa377..8b7f6062 100644 --- a/lib/settings.coffee +++ b/lib/settings.coffee @@ -18,8 +18,10 @@ Settings = onLoadedCallbacks: [] init: -> - if Utils.isExtensionPage() + if Utils.isExtensionPage() and Utils.isExtensionPage window.top # On extension pages, we use localStorage (or a copy of it) as the cache. + # For UIComponents (or other content of ours in an iframe within a regular page), we can't access + # localStorage, so we check that the top level frame is also an extension page. @cache = if Utils.isBackgroundPage() then localStorage else extend {}, localStorage @onLoaded() diff --git a/lib/utils.coffee b/lib/utils.coffee index c255102e..50d8c7dd 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -2,12 +2,12 @@ Utils = getCurrentVersion: -> chrome.runtime.getManifest().version - # Returns true whenever the current page is from the extension's origin (and thus can access the - # extension's localStorage). - isExtensionPage: -> document.location?.origin + "/" == chrome.extension.getURL "" + # Returns true whenever the current page (or the page supplied as an argument) is from the extension's + # origin (and thus can access the extension's localStorage). + isExtensionPage: (win = window) -> try win.document.location?.origin + "/" == chrome.extension.getURL "" # Returns true whenever the current page is the extension's background page. - isBackgroundPage: -> @isExtensionPage() and chrome.extension.getBackgroundPage() == window + isBackgroundPage: -> @isExtensionPage() and chrome.extension.getBackgroundPage?() == window # Takes a dot-notation object string and call the function # that it points to with the correct value for 'this'. |
