diff options
-rw-r--r-- | chrome/app/nibs/CookieDetailsView.xib | 478 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_details.h | 146 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_details.mm | 221 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_details_unittest.mm | 140 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_prompt_window_controller.mm | 223 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_tree_node.h | 72 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookie_tree_node.mm | 156 | ||||
-rw-r--r-- | chrome/browser/cocoa/cookies_window_controller_unittest.mm | 92 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 6 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 |
10 files changed, 910 insertions, 625 deletions
diff --git a/chrome/app/nibs/CookieDetailsView.xib b/chrome/app/nibs/CookieDetailsView.xib index 6cd519c..3c30664 100644 --- a/chrome/app/nibs/CookieDetailsView.xib +++ b/chrome/app/nibs/CookieDetailsView.xib @@ -312,6 +312,76 @@ <reference key="NSTextColor" ref="503975814"/> </object> </object> + <object class="NSCustomView" id="440361667"> + <reference key="NSNextResponder" ref="430082147"/> + <int key="NSvFlags">-2147483380</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSPopUpButton" id="161048022"> + <reference key="NSNextResponder" ref="440361667"/> + <int key="NSvFlags">266</int> + <string key="NSFrameSize">{200, 26}</string> + <reference key="NSSuperview" ref="440361667"/> + <bool key="NSEnabled">YES</bool> + <object class="NSPopUpButtonCell" key="NSCell" id="173617932"> + <int key="NSCellFlags">-2076049856</int> + <int key="NSCellFlags2">2048</int> + <reference key="NSSupport" ref="123687714"/> + <reference key="NSControlView" ref="161048022"/> + <int key="NSButtonFlags">109199615</int> + <int key="NSButtonFlags2">129</int> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + <object class="NSMenuItem" key="NSMenuItem" id="628665972"> + <reference key="NSMenu" ref="424593479"/> + <string key="NSTitle">Item 1</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <int key="NSState">1</int> + <object class="NSCustomResource" key="NSOnImage" id="825310241"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSMenuCheckmark</string> + </object> + <object class="NSCustomResource" key="NSMixedImage" id="41309840"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSMenuMixedState</string> + </object> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="173617932"/> + </object> + <bool key="NSMenuItemRespectAlignment">YES</bool> + <object class="NSMenu" key="NSMenu" id="424593479"> + <string key="NSTitle">OtherViews</string> + <object class="NSMutableArray" key="NSMenuItems"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="628665972"/> + <object class="NSMenuItem" id="735521972"> + <reference key="NSMenu" ref="424593479"/> + <string key="NSTitle">Item 2</string> + <string key="NSKeyEquiv"/> + <int key="NSKeyEquivModMask">1048576</int> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="825310241"/> + <reference key="NSMixedImage" ref="41309840"/> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="173617932"/> + </object> + </object> + </object> + <int key="NSPreferredEdge">1</int> + <bool key="NSUsesItemFromMenu">YES</bool> + <bool key="NSAltersState">YES</bool> + <int key="NSArrowPosition">2</int> + </object> + </object> + </object> + <string key="NSFrame">{{3, 16}, {200, 26}}</string> + <reference key="NSSuperview" ref="430082147"/> + <string key="NSClassName">GTMWidthBasedTweaker</string> + </object> </object> <string key="NSFrame">{{76, -18}, {386, 207}}</string> <reference key="NSSuperview" ref="238462753"/> @@ -832,25 +902,24 @@ <object class="NSObjectController" id="581169699"> <object class="NSMutableArray" key="NSDeclaredKeys"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>name</string> - <string>content</string> - <string>domain</string> - <string>path</string> - <string>sendFor</string> - <string>created</string> - <string>expires</string> - <string>fileSize</string> - <string>lastModified</string> - <string>databaseDescription</string> - <string>isLocalStorageTreeDetails</string> - <string>isFolderOrCookieTreeDetails</string> - <string>isDatabaseTreeDetails</string> - <string>isDatabasePromptDetails</string> - <string>isLocalStoragePromptDetails</string> - <string>localStorageKey</string> - <string>localStorageValue</string> - <string>count</string> <string>@count</string> + <string>details.expires</string> + <string>details.created</string> + <string>details.sendFor</string> + <string>details.path</string> + <string>details.domain</string> + <string>details.content</string> + <string>details.name</string> + <string>details.lastModified</string> + <string>details.fileSize</string> + <string>details.databaseDescription</string> + <string>details.localStorageValue</string> + <string>details.localStorageKey</string> + <string>details.shouldShowLocalStoragePromptDetailsView</string> + <string>details.shouldShowDatabasePromptDetailsView</string> + <string>details.shouldShowDatabaseTreeDetailsView</string> + <string>details.shouldShowLocalStorageTreeDetailsView</string> + <string>details.shouldHideCookieDetailsView</string> </object> <string key="NSObjectClassName">CocoaCookieTreeNode</string> <bool key="NSEditable">YES</bool> @@ -948,15 +1017,15 @@ </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.expires</string> + <string key="label">value: content.details.expires</string> <reference key="source" ref="860444829"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="860444829"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.expires</string> + <string key="NSLabel">value: content.details.expires</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.expires</string> + <string key="NSKeyPath">content.details.expires</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -977,19 +1046,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">539</int> + <int key="connectionID">582</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.created</string> + <string key="label">value: content.details.created</string> <reference key="source" ref="923803282"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="923803282"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.created</string> + <string key="NSLabel">value: content.details.created</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.created</string> + <string key="NSKeyPath">content.details.created</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1010,19 +1079,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">540</int> + <int key="connectionID">583</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.sendFor</string> + <string key="label">value: content.details.sendFor</string> <reference key="source" ref="753982819"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="753982819"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.sendFor</string> + <string key="NSLabel">value: content.details.sendFor</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.sendFor</string> + <string key="NSKeyPath">content.details.sendFor</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1043,19 +1112,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">541</int> + <int key="connectionID">584</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.path</string> + <string key="label">value: content.details.path</string> <reference key="source" ref="52584846"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="52584846"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.path</string> + <string key="NSLabel">value: content.details.path</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.path</string> + <string key="NSKeyPath">content.details.path</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1076,19 +1145,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">542</int> + <int key="connectionID">585</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.domain</string> + <string key="label">value: content.details.domain</string> <reference key="source" ref="190839613"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="190839613"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.domain</string> + <string key="NSLabel">value: content.details.domain</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.domain</string> + <string key="NSKeyPath">content.details.domain</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1109,19 +1178,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">543</int> + <int key="connectionID">586</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.content</string> + <string key="label">value: content.details.content</string> <reference key="source" ref="589731962"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="589731962"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.content</string> + <string key="NSLabel">value: content.details.content</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.content</string> + <string key="NSKeyPath">content.details.content</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1142,19 +1211,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">544</int> + <int key="connectionID">587</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.name</string> + <string key="label">value: content.details.name</string> <reference key="source" ref="897570455"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="897570455"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.name</string> + <string key="NSLabel">value: content.details.name</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.name</string> + <string key="NSKeyPath">content.details.name</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1175,19 +1244,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">545</int> + <int key="connectionID">588</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.lastModified</string> + <string key="label">value: content.details.lastModified</string> <reference key="source" ref="826212411"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="826212411"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.lastModified</string> + <string key="NSLabel">value: content.details.lastModified</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.lastModified</string> + <string key="NSKeyPath">content.details.lastModified</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1208,19 +1277,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">546</int> + <int key="connectionID">589</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.fileSize</string> + <string key="label">value: content.details.fileSize</string> <reference key="source" ref="236918317"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="236918317"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.fileSize</string> + <string key="NSLabel">value: content.details.fileSize</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.fileSize</string> + <string key="NSKeyPath">content.details.fileSize</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1241,19 +1310,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">547</int> + <int key="connectionID">590</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.domain</string> + <string key="label">value: content.details.domain</string> <reference key="source" ref="280427712"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="280427712"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.domain</string> + <string key="NSLabel">value: content.details.domain</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.domain</string> + <string key="NSKeyPath">content.details.domain</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1274,19 +1343,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">548</int> + <int key="connectionID">591</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.lastModified</string> + <string key="label">value: content.details.lastModified</string> <reference key="source" ref="668449282"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="668449282"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.lastModified</string> + <string key="NSLabel">value: content.details.lastModified</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.lastModified</string> + <string key="NSKeyPath">content.details.lastModified</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1307,19 +1376,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">549</int> + <int key="connectionID">592</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.fileSize</string> + <string key="label">value: content.details.fileSize</string> <reference key="source" ref="190535033"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="190535033"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.fileSize</string> + <string key="NSLabel">value: content.details.fileSize</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.fileSize</string> + <string key="NSKeyPath">content.details.fileSize</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1340,19 +1409,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">550</int> + <int key="connectionID">593</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.databaseDescription</string> + <string key="label">value: content.details.databaseDescription</string> <reference key="source" ref="223492865"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="223492865"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.databaseDescription</string> + <string key="NSLabel">value: content.details.databaseDescription</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.databaseDescription</string> + <string key="NSKeyPath">content.details.databaseDescription</string> <object class="NSDictionary" key="NSOptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> @@ -1373,19 +1442,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">551</int> + <int key="connectionID">594</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.domain</string> - <reference key="source" ref="226333841"/> + <string key="label">value: content.details.name</string> + <reference key="source" ref="875875171"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="226333841"/> + <reference key="NSSource" ref="875875171"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.domain</string> + <string key="NSLabel">value: content.details.name</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.domain</string> + <string key="NSKeyPath">content.details.name</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSRaisesForNotApplicableKeys</string> <reference key="NS.object.0" ref="6"/> @@ -1393,19 +1462,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">552</int> + <int key="connectionID">595</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.name</string> - <reference key="source" ref="875875171"/> + <string key="label">value: content.details.domain</string> + <reference key="source" ref="226333841"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="875875171"/> + <reference key="NSSource" ref="226333841"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.name</string> + <string key="NSLabel">value: content.details.domain</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.name</string> + <string key="NSKeyPath">content.details.domain</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSRaisesForNotApplicableKeys</string> <reference key="NS.object.0" ref="6"/> @@ -1413,19 +1482,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">553</int> + <int key="connectionID">596</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.domain</string> - <reference key="source" ref="460351266"/> + <string key="label">value: content.details.localStorageValue</string> + <reference key="source" ref="160681062"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="460351266"/> + <reference key="NSSource" ref="160681062"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.domain</string> + <string key="NSLabel">value: content.details.localStorageValue</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.domain</string> + <string key="NSKeyPath">content.details.localStorageValue</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSRaisesForNotApplicableKeys</string> <reference key="NS.object.0" ref="6"/> @@ -1433,19 +1502,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">554</int> + <int key="connectionID">597</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.localStorageKey</string> + <string key="label">value: content.details.localStorageKey</string> <reference key="source" ref="1020137061"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> <reference key="NSSource" ref="1020137061"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.localStorageKey</string> + <string key="NSLabel">value: content.details.localStorageKey</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.localStorageKey</string> + <string key="NSKeyPath">content.details.localStorageKey</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSRaisesForNotApplicableKeys</string> <reference key="NS.object.0" ref="6"/> @@ -1453,19 +1522,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">555</int> + <int key="connectionID">598</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: content.localStorageValue</string> - <reference key="source" ref="160681062"/> + <string key="label">value: content.details.domain</string> + <reference key="source" ref="460351266"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="160681062"/> + <reference key="NSSource" ref="460351266"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">value: content.localStorageValue</string> + <string key="NSLabel">value: content.details.domain</string> <string key="NSBinding">value</string> - <string key="NSKeyPath">content.localStorageValue</string> + <string key="NSKeyPath">content.details.domain</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSRaisesForNotApplicableKeys</string> <reference key="NS.object.0" ref="6"/> @@ -1473,19 +1542,19 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">556</int> + <int key="connectionID">599</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">hidden: content.isLocalStorageTreeDetails</string> - <reference key="source" ref="244286403"/> + <string key="label">hidden: content.details.shouldShowLocalStoragePromptDetailsView</string> + <reference key="source" ref="748119605"/> <reference key="destination" ref="581169699"/> - <object class="NSNibBindingConnector" key="connector" id="1022309843"> - <reference key="NSSource" ref="244286403"/> + <object class="NSNibBindingConnector" key="connector" id="775690993"> + <reference key="NSSource" ref="748119605"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">hidden: content.isLocalStorageTreeDetails</string> + <string key="NSLabel">hidden: content.details.shouldShowLocalStoragePromptDetailsView</string> <string key="NSBinding">hidden</string> - <string key="NSKeyPath">content.isLocalStorageTreeDetails</string> + <string key="NSKeyPath">content.details.shouldShowLocalStoragePromptDetailsView</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSValueTransformerName</string> <string key="NS.object.0">NSNegateBoolean</string> @@ -1493,15 +1562,15 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">557</int> + <int key="connectionID">600</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> <string key="label">hidden2: selection.@count</string> - <reference key="source" ref="244286403"/> + <reference key="source" ref="748119605"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="244286403"/> + <reference key="NSSource" ref="748119605"/> <reference key="NSDestination" ref="581169699"/> <string key="NSLabel">hidden2: selection.@count</string> <string key="NSBinding">hidden2</string> @@ -1525,43 +1594,23 @@ <string>NSNegateBoolean</string> </object> </object> - <reference key="NSPreviousConnector" ref="1022309843"/> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">558</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">hidden: content.isFolderOrCookieTreeDetails</string> - <reference key="source" ref="238462753"/> - <reference key="destination" ref="581169699"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="238462753"/> - <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">hidden: content.isFolderOrCookieTreeDetails</string> - <string key="NSBinding">hidden</string> - <string key="NSKeyPath">content.isFolderOrCookieTreeDetails</string> - <object class="NSDictionary" key="NSOptions"> - <string key="NS.key.0">NSValueTransformerName</string> - <string key="NS.object.0">NSNegateBoolean</string> - </object> + <reference key="NSPreviousConnector" ref="775690993"/> <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">559</int> + <int key="connectionID">601</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">hidden: content.isDatabaseTreeDetails</string> - <reference key="source" ref="405138257"/> + <string key="label">hidden: content.details.shouldShowDatabasePromptDetailsView</string> + <reference key="source" ref="654642025"/> <reference key="destination" ref="581169699"/> - <object class="NSNibBindingConnector" key="connector" id="882980630"> - <reference key="NSSource" ref="405138257"/> + <object class="NSNibBindingConnector" key="connector" id="979803685"> + <reference key="NSSource" ref="654642025"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">hidden: content.isDatabaseTreeDetails</string> + <string key="NSLabel">hidden: content.details.shouldShowDatabasePromptDetailsView</string> <string key="NSBinding">hidden</string> - <string key="NSKeyPath">content.isDatabaseTreeDetails</string> + <string key="NSKeyPath">content.details.shouldShowDatabasePromptDetailsView</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSValueTransformerName</string> <string key="NS.object.0">NSNegateBoolean</string> @@ -1569,15 +1618,15 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">560</int> + <int key="connectionID">602</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> <string key="label">hidden2: selection.@count</string> - <reference key="source" ref="405138257"/> + <reference key="source" ref="654642025"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="405138257"/> + <reference key="NSSource" ref="654642025"/> <reference key="NSDestination" ref="581169699"/> <string key="NSLabel">hidden2: selection.@count</string> <string key="NSBinding">hidden2</string> @@ -1601,23 +1650,23 @@ <string>NSNegateBoolean</string> </object> </object> - <reference key="NSPreviousConnector" ref="882980630"/> + <reference key="NSPreviousConnector" ref="979803685"/> <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">561</int> + <int key="connectionID">603</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">hidden: content.isDatabasePromptDetails</string> - <reference key="source" ref="654642025"/> + <string key="label">hidden: content.details.shouldShowDatabaseTreeDetailsView</string> + <reference key="source" ref="405138257"/> <reference key="destination" ref="581169699"/> - <object class="NSNibBindingConnector" key="connector" id="740067409"> - <reference key="NSSource" ref="654642025"/> + <object class="NSNibBindingConnector" key="connector" id="381511258"> + <reference key="NSSource" ref="405138257"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">hidden: content.isDatabasePromptDetails</string> + <string key="NSLabel">hidden: content.details.shouldShowDatabaseTreeDetailsView</string> <string key="NSBinding">hidden</string> - <string key="NSKeyPath">content.isDatabasePromptDetails</string> + <string key="NSKeyPath">content.details.shouldShowDatabaseTreeDetailsView</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSValueTransformerName</string> <string key="NS.object.0">NSNegateBoolean</string> @@ -1625,15 +1674,15 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">562</int> + <int key="connectionID">604</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> <string key="label">hidden2: selection.@count</string> - <reference key="source" ref="654642025"/> + <reference key="source" ref="405138257"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="654642025"/> + <reference key="NSSource" ref="405138257"/> <reference key="NSDestination" ref="581169699"/> <string key="NSLabel">hidden2: selection.@count</string> <string key="NSBinding">hidden2</string> @@ -1657,23 +1706,23 @@ <string>NSNegateBoolean</string> </object> </object> - <reference key="NSPreviousConnector" ref="740067409"/> + <reference key="NSPreviousConnector" ref="381511258"/> <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">563</int> + <int key="connectionID">605</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">hidden: content.isLocalStoragePromptDetails</string> - <reference key="source" ref="748119605"/> + <string key="label">hidden: content.details.shouldShowLocalStorageTreeDetailsView</string> + <reference key="source" ref="244286403"/> <reference key="destination" ref="581169699"/> - <object class="NSNibBindingConnector" key="connector" id="839403343"> - <reference key="NSSource" ref="748119605"/> + <object class="NSNibBindingConnector" key="connector" id="455345162"> + <reference key="NSSource" ref="244286403"/> <reference key="NSDestination" ref="581169699"/> - <string key="NSLabel">hidden: content.isLocalStoragePromptDetails</string> + <string key="NSLabel">hidden: content.details.shouldShowLocalStorageTreeDetailsView</string> <string key="NSBinding">hidden</string> - <string key="NSKeyPath">content.isLocalStoragePromptDetails</string> + <string key="NSKeyPath">content.details.shouldShowLocalStorageTreeDetailsView</string> <object class="NSDictionary" key="NSOptions"> <string key="NS.key.0">NSValueTransformerName</string> <string key="NS.object.0">NSNegateBoolean</string> @@ -1681,15 +1730,15 @@ <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">564</int> + <int key="connectionID">606</int> </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> <string key="label">hidden2: selection.@count</string> - <reference key="source" ref="748119605"/> + <reference key="source" ref="244286403"/> <reference key="destination" ref="581169699"/> <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="748119605"/> + <reference key="NSSource" ref="244286403"/> <reference key="NSDestination" ref="581169699"/> <string key="NSLabel">hidden2: selection.@count</string> <string key="NSBinding">hidden2</string> @@ -1713,11 +1762,43 @@ <string>NSNegateBoolean</string> </object> </object> - <reference key="NSPreviousConnector" ref="839403343"/> + <reference key="NSPreviousConnector" ref="455345162"/> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">607</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: content.details.expires</string> + <reference key="source" ref="628665972"/> + <reference key="destination" ref="581169699"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="628665972"/> + <reference key="NSDestination" ref="581169699"/> + <string key="NSLabel">value: content.details.expires</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">content.details.expires</string> <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">565</int> + <int key="connectionID">609</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">hidden: content.details.shouldHideCookieDetailsView</string> + <reference key="source" ref="238462753"/> + <reference key="destination" ref="581169699"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="238462753"/> + <reference key="NSDestination" ref="581169699"/> + <string key="NSLabel">hidden: content.details.shouldHideCookieDetailsView</string> + <string key="NSBinding">hidden</string> + <string key="NSKeyPath">content.details.shouldHideCookieDetailsView</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">611</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -2034,6 +2115,7 @@ <reference ref="753982819"/> <reference ref="923803282"/> <reference ref="860444829"/> + <reference ref="440361667"/> </object> <reference key="parent" ref="238462753"/> </object> @@ -2457,6 +2539,53 @@ <reference key="object" ref="669425040"/> <reference key="parent" ref="448024654"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">577</int> + <reference key="object" ref="440361667"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="161048022"/> + </object> + <reference key="parent" ref="430082147"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">566</int> + <reference key="object" ref="161048022"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="173617932"/> + </object> + <reference key="parent" ref="440361667"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">567</int> + <reference key="object" ref="173617932"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="424593479"/> + </object> + <reference key="parent" ref="161048022"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">568</int> + <reference key="object" ref="424593479"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="735521972"/> + <reference ref="628665972"/> + </object> + <reference key="parent" ref="173617932"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">570</int> + <reference key="object" ref="735521972"/> + <reference key="parent" ref="424593479"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">569</int> + <reference key="object" ref="628665972"/> + <reference key="parent" ref="424593479"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -2548,13 +2677,23 @@ <string>482.IBPluginDependency</string> <string>483.IBPluginDependency</string> <string>484.IBPluginDependency</string> + <string>566.IBPluginDependency</string> + <string>567.IBPluginDependency</string> + <string>568.IBEditorWindowLastContentRect</string> + <string>568.IBPluginDependency</string> + <string>569.IBPluginDependency</string> + <string>570.IBPluginDependency</string> + <string>577.IBPluginDependency</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{640, 45}, {464, 191}}</string> + <string>{{28, 111}, {464, 191}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -2635,6 +2774,10 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{702, 79}, {200, 43}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> </object> </object> @@ -2658,7 +2801,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">565</int> + <int key="maxID">611</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -2750,6 +2893,13 @@ <reference key="sourceIdentifier" ref="489627463"/> </object> <object class="IBPartialClassDescription"> + <string key="className">NSMenuItem</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/nsmenuitem_additions.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> diff --git a/chrome/browser/cocoa/cookie_details.h b/chrome/browser/cocoa/cookie_details.h new file mode 100644 index 0000000..2ce6dfa --- /dev/null +++ b/chrome/browser/cocoa/cookie_details.h @@ -0,0 +1,146 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> + +#include "chrome/browser/browsing_data_database_helper.h" +#include "chrome/browser/browsing_data_local_storage_helper.h" +#include "base/scoped_nsobject.h" +#include "net/base/cookie_monster.h" + +class CookieTreeNode; +class CookiePromptModalDialog; + +// This enum specifies the type of information contained in the +// cookie details. +enum CocoaCookieDetailsType { + // Represents grouping of cookie data, used in the cookie tree. + kCocoaCookieDetailsTypeFolder = 0, + + // Detailed information about a cookie, used both in the cookie + // tree and the cookie prompt. + kCocoaCookieDetailsTypeCookie = 1, + + // Detailed information about a web database used for + // display in the cookie tree. + kCocoaCookieDetailsTypeTreeDatabase = 2, + + // Detailed information about local storage used for + // display in the cookie tree. + kCocoaCookieDetailsTypeTreeLocalStorage = 3, + + // Detailed information about a web database used for display + // in the cookie prompt dialog. + kCocoaCookieDetailsTypePromptDatabase = 4, + + // Detailed information about local storage used for display + // in the cookie prompt dialog. + kCocoaCookieDetailsTypePromptLocalStorage = 5 +}; + +// This class contains all of the information that can be displayed in +// a cookie details view. Because the view uses bindings to display +// the cookie information, the methods that provide that information +// for display must be implemented directly on this class and not on any +// of its subclasses. +// If this system is rewritten to not use bindings, this class should be +// subclassed and specialized, rather than using an enum to determine type. +@interface CocoaCookieDetails : NSObject { + @private + CocoaCookieDetailsType type_; + + // These members are only set for type kCocoaCookieDetailsTypeCookie. + scoped_nsobject<NSString> content_; + scoped_nsobject<NSString> path_; + scoped_nsobject<NSString> sendFor_; + // Stringifed dates. + scoped_nsobject<NSString> created_; + scoped_nsobject<NSString> expires_; + + // These members are only set for types kCocoaCookieDetailsTypeCookie, + // kCocoaCookieDetailsTypePromptDatabase. + scoped_nsobject<NSString> name_; + + // Only set for types kCocoaCookieDetailsTypeTreeLocalStorage and + // kCocoaCookieDetailsTypeTreeDatabase nodes. + scoped_nsobject<NSString> fileSize_; + scoped_nsobject<NSString> lastModified_; + + // These members are only set for types kCocoaCookieDetailsTypeCookie, + // kCocoaCookieDetailsTypePromptDatabase and + // kCocoaCookieDetailsTypePromptLocalStorage nodes. + scoped_nsobject<NSString> domain_; + + // Used only for type kCocoaCookieTreeNodeTypeDatabaseStorage. + scoped_nsobject<NSString> databaseDescription_; + + // Used only for type kCocoaCookieDetailsTypePromptLocalStorage + scoped_nsobject<NSString> localStorageKey_; + scoped_nsobject<NSString> localStorageValue_; +} + +@property (readonly) CocoaCookieDetailsType type; + +// The following methods are used in the bindings of subviews inside +// the cookie detail view. Note that the method that tests the +// visibility of the subview for cookie-specific information has a different +// polarity than the other visibility testing methods. This ensures that +// this subview is shown when there is no selection in the cookie tree, +// because a hidden value of |false| is generated when the key value binding +// is evaluated through a nil object. The other methods are bound using a +// |NSNegateBoolean| transformer, so that when there is a empty selection the +// hidden value is |true|. +- (BOOL)shouldHideCookieDetailsView; +- (BOOL)shouldShowLocalStorageTreeDetailsView; +- (BOOL)shouldShowDatabaseTreeDetailsView; +- (BOOL)shouldShowDatabasePromptDetailsView; +- (BOOL)shouldShowLocalStoragePromptDetailsView; + +- (NSString*)name; +- (NSString*)content; +- (NSString*)domain; +- (NSString*)path; +- (NSString*)sendFor; +- (NSString*)created; +- (NSString*)expires; +- (NSString*)fileSize; +- (NSString*)lastModified; +- (NSString*)databaseDescription; +- (NSString*)localStorageKey; +- (NSString*)localStorageValue; + +// Used for folders in the cookie tree. +- (id)initAsFolder; + +// Used for cookie details in both the cookie tree and the cookie prompt dialog. +- (id)initWithCookie:(const net::CookieMonster::CanonicalCookie*)treeNode + origin:(NSString*)origin; + +// Used for database details in the cookie tree. +- (id)initWithDatabase: + (const BrowsingDataDatabaseHelper::DatabaseInfo*)databaseInfo; + +// Used for local storage details in the cookie tree. +- (id)initWithLocalStorage: + (const BrowsingDataLocalStorageHelper::LocalStorageInfo*)localStorageInfo; + +// Used for database details in the cookie prompt dialog. +- (id)initWithDatabase:(const std::string&)domain + name:(const string16&)name; + +// Used for local storage details in the cookie prompt dialog. +- (id)initWithLocalStorage:(const std::string&)domain + key:(const string16&)key + value:(const string16&)value; + +// A factory method to create a configured instance given a node from +// the cookie tree in |treeNode|. ++ (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode; + +// A factory method to create a configured instance given a cookie prompt +// modal dialog in |dialog|. ++ (CocoaCookieDetails*)createFromPromptModalDialog: + (CookiePromptModalDialog*)dialog; + +@end diff --git a/chrome/browser/cocoa/cookie_details.mm b/chrome/browser/cocoa/cookie_details.mm new file mode 100644 index 0000000..7552c7f --- /dev/null +++ b/chrome/browser/cocoa/cookie_details.mm @@ -0,0 +1,221 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/cocoa/cookie_details.h" + +#include "app/l10n_util_mac.h" +#import "base/i18n/time_formatting.h" +#include "base/sys_string_conversions.h" +#include "grit/generated_resources.h" +#include "chrome/browser/cookie_modal_dialog.h" +#include "chrome/browser/cookies_tree_model.h" + +@implementation CocoaCookieDetails + +@synthesize type = type_; + +- (BOOL)shouldHideCookieDetailsView { + return type_ != kCocoaCookieDetailsTypeFolder && + type_ != kCocoaCookieDetailsTypeCookie; +} + +- (BOOL)shouldShowLocalStorageTreeDetailsView { + return type_ == kCocoaCookieDetailsTypeTreeLocalStorage; +} + +- (BOOL)shouldShowDatabaseTreeDetailsView { + return type_ == kCocoaCookieDetailsTypeTreeDatabase; +} + +- (BOOL)shouldShowDatabasePromptDetailsView { + return type_ == kCocoaCookieDetailsTypePromptDatabase; +} + +- (BOOL)shouldShowLocalStoragePromptDetailsView { + return type_ == kCocoaCookieDetailsTypePromptLocalStorage; +} + +- (NSString*)name { + return name_.get(); +} + +- (NSString*)content { + return content_.get(); +} + +- (NSString*)domain { + return domain_.get(); +} + +- (NSString*)path { + return path_.get(); +} + +- (NSString*)sendFor { + return sendFor_.get(); +} + +- (NSString*)created { + return created_.get(); +} + +- (NSString*)expires { + return expires_.get(); +} + +- (NSString*)fileSize { + return fileSize_.get(); +} + +- (NSString*)lastModified { + return lastModified_.get(); +} + +- (NSString*)databaseDescription { + return databaseDescription_.get(); +} + +- (NSString*)localStorageKey { + return localStorageKey_.get(); +} + +- (NSString*)localStorageValue { + return localStorageValue_.get(); +} + +- (id)initAsFolder { + if ((self = [super init])) { + type_ = kCocoaCookieDetailsTypeFolder; + } + return self; +} + +- (id)initWithCookie:(const net::CookieMonster::CanonicalCookie*)cookie + origin:(NSString*)origin { + if ((self = [super init])) { + type_ = kCocoaCookieDetailsTypeCookie; + name_.reset([base::SysUTF8ToNSString(cookie->Name()) retain]); + content_.reset([base::SysUTF8ToNSString(cookie->Value()) retain]); + path_.reset([base::SysUTF8ToNSString(cookie->Path()) retain]); + domain_.reset([origin retain]); + + if (cookie->DoesExpire()) { + expires_.reset([base::SysWideToNSString( + base::TimeFormatFriendlyDateAndTime(cookie->ExpiryDate())) retain]); + } else { + expires_.reset([l10n_util::GetNSStringWithFixup( + IDS_COOKIES_COOKIE_EXPIRES_SESSION) retain]); + } + + created_.reset([base::SysWideToNSString( + base::TimeFormatFriendlyDateAndTime(cookie->CreationDate())) retain]); + + if (cookie->IsSecure()) { + sendFor_.reset([l10n_util::GetNSStringWithFixup( + IDS_COOKIES_COOKIE_SENDFOR_SECURE) retain]); + } else { + sendFor_.reset([l10n_util::GetNSStringWithFixup( + IDS_COOKIES_COOKIE_SENDFOR_ANY) retain]); + } + } + return self; +} + +- (id)initWithDatabase:(const BrowsingDataDatabaseHelper::DatabaseInfo*) + databaseInfo { + if ((self = [super init])) { + type_ = kCocoaCookieDetailsTypeTreeDatabase; + databaseDescription_.reset([base::SysUTF8ToNSString( + databaseInfo->description) retain]); + fileSize_.reset([base::SysWideToNSString(FormatBytes(databaseInfo->size, + GetByteDisplayUnits(databaseInfo->size), true)) retain]); + lastModified_.reset([base::SysWideToNSString( + base::TimeFormatFriendlyDateAndTime( + databaseInfo->last_modified)) retain]); + } + return self; +} + +- (id)initWithLocalStorage:( + const BrowsingDataLocalStorageHelper::LocalStorageInfo*)storageInfo { + if ((self = [super init])) { + type_ = kCocoaCookieDetailsTypeTreeLocalStorage; + domain_.reset([base::SysUTF8ToNSString(storageInfo->origin) retain]); + fileSize_.reset([base::SysWideToNSString(FormatBytes(storageInfo->size, + GetByteDisplayUnits(storageInfo->size), true)) retain]); + lastModified_.reset([base::SysWideToNSString( + base::TimeFormatFriendlyDateAndTime( + storageInfo->last_modified)) retain]); + } + return self; +} + +- (id)initWithDatabase:(const std::string&)domain + name:(const string16&)name { + if ((self = [super init])) { + type_ = kCocoaCookieDetailsTypePromptDatabase; + name_.reset([base::SysUTF16ToNSString(name) retain]); + domain_.reset([base::SysUTF8ToNSString(domain) retain]); + } + return self; +} + +- (id)initWithLocalStorage:(const std::string&)domain + key:(const string16&)key + value:(const string16&)value { + if ((self = [super init])) { + type_ = kCocoaCookieDetailsTypePromptLocalStorage; + domain_.reset([base::SysUTF8ToNSString(domain) retain]); + localStorageKey_.reset([base::SysUTF16ToNSString(key) retain]); + localStorageValue_.reset([base::SysUTF16ToNSString(value) retain]); + } + return self; +} + ++ (CocoaCookieDetails*)createFromCookieTreeNode:(CookieTreeNode*)treeNode { + CookieTreeNode::DetailedInfo info = treeNode->GetDetailedInfo(); + CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; + if (nodeType == CookieTreeNode::DetailedInfo::TYPE_COOKIE) { + NSString* origin = base::SysWideToNSString(info.origin.c_str()); + return [[[CocoaCookieDetails alloc] initWithCookie:&(info.cookie->second) + origin:origin] autorelease]; + } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_DATABASE) { + return [[[CocoaCookieDetails alloc] + initWithDatabase:info.database_info] autorelease]; + } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) { + return [[[CocoaCookieDetails alloc] + initWithLocalStorage:info.local_storage_info] autorelease]; + } else { + return [[[CocoaCookieDetails alloc] initAsFolder] autorelease]; + } +} + ++ (CocoaCookieDetails*)createFromPromptModalDialog:(CookiePromptModalDialog*) + dialog { + CookiePromptModalDialog::DialogType type(dialog->dialog_type()); + CocoaCookieDetails* details = nil; + if (type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE) { + net::CookieMonster::ParsedCookie pc(dialog->cookie_line()); + net::CookieMonster::CanonicalCookie cookie(dialog->origin(), pc); + const std::string& domain(pc.HasDomain() ? pc.Domain() : + dialog->origin().host()); + NSString* domainString = base::SysUTF8ToNSString(domain); + details = [[CocoaCookieDetails alloc] initWithCookie:&cookie + origin:domainString]; + } else if (type == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE) { + details = [[CocoaCookieDetails alloc] + initWithLocalStorage:dialog->origin().host() + key:dialog->local_storage_key() + value:dialog->local_storage_value()]; + } else if (type == CookiePromptModalDialog::DIALOG_TYPE_DATABASE) { + details = [[CocoaCookieDetails alloc] + initWithDatabase:dialog->origin().host() + name:dialog->database_name()]; + } else { + NOTIMPLEMENTED(); + } + return [details autorelease]; +} + +@end diff --git a/chrome/browser/cocoa/cookie_details_unittest.mm b/chrome/browser/cocoa/cookie_details_unittest.mm new file mode 100644 index 0000000..a600a8d --- /dev/null +++ b/chrome/browser/cocoa/cookie_details_unittest.mm @@ -0,0 +1,140 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/sys_string_conversions.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "chrome/browser/cocoa/cookie_details.h" +#include "googleurl/src/gurl.h" + +namespace { + +class CookiesDetailsTest : public CocoaTest { +}; + +TEST_F(CookiesDetailsTest, CreateForFolder) { + scoped_nsobject<CocoaCookieDetails> details; + details.reset([[CocoaCookieDetails alloc] initAsFolder]); + + EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeFolder); +} + +TEST_F(CookiesDetailsTest, CreateForCookie) { + scoped_nsobject<CocoaCookieDetails> details; + GURL url("http://chromium.org"); + std::string cookieLine( + "PHPSESSID=0123456789abcdef0123456789abcdef; path=/"); + net::CookieMonster::ParsedCookie pc(cookieLine); + net::CookieMonster::CanonicalCookie cookie(url, pc); + NSString* origin = base::SysUTF8ToNSString("http://chromium.org"); + details.reset([[CocoaCookieDetails alloc] initWithCookie:&cookie + origin:origin]); + + EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeCookie); + EXPECT_TRUE([@"PHPSESSID" isEqualToString:[details.get() name]]); + EXPECT_TRUE([@"0123456789abcdef0123456789abcdef" + isEqualToString:[details.get() content]]); + EXPECT_TRUE([@"http://chromium.org" isEqualToString:[details.get() domain]]); + EXPECT_TRUE([@"/" isEqualToString:[details.get() path]]); + EXPECT_FALSE([@"" isEqualToString:[details.get() lastModified]]); + EXPECT_FALSE([@"" isEqualToString:[details.get() created]]); + EXPECT_FALSE([@"" isEqualToString:[details.get() sendFor]]); + + EXPECT_FALSE([details.get() shouldHideCookieDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); +} + +TEST_F(CookiesDetailsTest, CreateForTreeDatabase) { + scoped_nsobject<CocoaCookieDetails> details; + std::string host("http://chromium.org"); + std::string database_name("sassolungo"); + std::string origin_identifier("dolomites"); + std::string description("a great place to climb"); + int64 size = 1234; + base::Time last_modified = base::Time::Now(); + BrowsingDataDatabaseHelper::DatabaseInfo info(host, database_name, + origin_identifier, description, size, last_modified); + details.reset([[CocoaCookieDetails alloc] initWithDatabase:&info]); + + EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeDatabase); + EXPECT_TRUE([@"a great place to climb" isEqualToString:[details.get() + databaseDescription]]); + EXPECT_TRUE([@"1234 B" isEqualToString:[details.get() fileSize]]); + EXPECT_FALSE([@"" isEqualToString:[details.get() lastModified]]); + + EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); + EXPECT_TRUE([details.get() shouldShowDatabaseTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); +} + +TEST_F(CookiesDetailsTest, CreateForTreeLocalStorage) { + scoped_nsobject<CocoaCookieDetails> details; + std::string protocol("http"); + std::string host("chromium.org"); + unsigned short port = 80; + std::string database_identifier("id"); + std::string origin("chromium.org"); + FilePath file_path(FilePath::FromWStringHack(std::wstring(L"/"))); + int64 size = 1234; + base::Time last_modified = base::Time::Now(); + BrowsingDataLocalStorageHelper::LocalStorageInfo info(protocol, host, port, + database_identifier, origin, file_path, size, last_modified); + details.reset([[CocoaCookieDetails alloc] initWithLocalStorage:&info]); + + EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypeTreeLocalStorage); + EXPECT_TRUE([@"chromium.org" isEqualToString:[details.get() domain]]); + EXPECT_TRUE([@"1234 B" isEqualToString:[details.get() fileSize]]); + EXPECT_FALSE([@"" isEqualToString:[details.get() lastModified]]); + + EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); + EXPECT_TRUE([details.get() shouldShowLocalStorageTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); +} + +TEST_F(CookiesDetailsTest, CreateForPromptDatabase) { + scoped_nsobject<CocoaCookieDetails> details; + std::string domain("chromium.org"); + string16 name(base::SysNSStringToUTF16(@"wicked_name")); + details.reset([[CocoaCookieDetails alloc] initWithDatabase:domain + name:name]); + + EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypePromptDatabase); + EXPECT_TRUE([@"chromium.org" isEqualToString:[details.get() domain]]); + EXPECT_TRUE([@"wicked_name" isEqualToString:[details.get() name]]); + + EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStoragePromptDetailsView]); + EXPECT_TRUE([details.get() shouldShowDatabasePromptDetailsView]); +} + +TEST_F(CookiesDetailsTest, CreateForPromptLocalStorage) { + scoped_nsobject<CocoaCookieDetails> details; + std::string domain("chromium.org"); + string16 key(base::SysNSStringToUTF16(@"testKey")); + string16 value(base::SysNSStringToUTF16(@"testValue")); + details.reset([[CocoaCookieDetails alloc] initWithLocalStorage:domain + key:key + value:value]); + + EXPECT_EQ([details.get() type], kCocoaCookieDetailsTypePromptLocalStorage); + EXPECT_TRUE([@"chromium.org" isEqualToString:[details.get() domain]]); + EXPECT_TRUE([@"testKey" isEqualToString:[details.get() localStorageKey]]); + EXPECT_TRUE([@"testValue" isEqualToString:[details.get() localStorageValue]]); + + EXPECT_TRUE([details.get() shouldHideCookieDetailsView]); + EXPECT_FALSE([details.get() shouldShowLocalStorageTreeDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabaseTreeDetailsView]); + EXPECT_TRUE([details.get() shouldShowLocalStoragePromptDetailsView]); + EXPECT_FALSE([details.get() shouldShowDatabasePromptDetailsView]); +} + +} diff --git a/chrome/browser/cocoa/cookie_prompt_window_controller.mm b/chrome/browser/cocoa/cookie_prompt_window_controller.mm index 5b85397..833423b 100644 --- a/chrome/browser/cocoa/cookie_prompt_window_controller.mm +++ b/chrome/browser/cocoa/cookie_prompt_window_controller.mm @@ -19,206 +19,42 @@ #include "grit/generated_resources.h" #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" -#pragma mark Window Controller - -// This class is an apapter allows the cookie details view to be shared -// by the cookie prompt window and the cookie tree in the cookies and -// other site data window. As instance of the class is set as the -// content object of the object controller for the details view and -// implements the methods expected by bindings inside that view. +#pragma mark Selection Adapter + +// The subpanes of the cookie details view expect to be able to bind to methods +// through a key path in the form |content.details.xxxx|. This class serves as +// an adapter that simply wraps a |CocoaCookieDetails| object. An instance of +// this class is set as the content object for cookie details view's object +// controller so that key paths are properly resolved through to the +// |CocoaCookieDetails| object for the cookie prompt. @interface CookiePromptSelectionAdapter : NSObject { @private - // The type of the cookie prompt being displayed, used to - // determine which subview of the details view is visible - CookiePromptModalDialog::DialogType promptType_; - - // The following members are used to hold information used in the - // cookie prompt detailed information for cookies and web databases. - scoped_nsobject<NSString> name_; - scoped_nsobject<NSString> domain_; - scoped_nsobject<NSString> content_; - - // The following members are used to hold information used in the - // cookie prompt detailed information for cookies only. - scoped_nsobject<NSString> path_; - scoped_nsobject<NSString> sendFor_; - scoped_nsobject<NSString> created_; - scoped_nsobject<NSString> expires_; - - // The following members are used to hold information used in the - // cookie prompt detailed information for local storage only. - scoped_nsobject<NSString> localStorageKey_; - scoped_nsobject<NSString> localStorageValue_; + scoped_nsobject<CocoaCookieDetails> details_; } -// Creates and returns an instance approriate for displaying information -// about a cookie. -- (id)initWithCookie:(const std::string&)cookie_line - url:(const GURL&)url; - -// Creates and returns an instance approriate for displaying information -// about a local storage. -- (id)initWithLocalStorage:(const std::string&)domain - key:(const string16&)key - value:(const string16&)value; - -// Creates and returns an instance approriate for displaying information -// about a web database. -- (id)initWithDatabase:(const std::string&)domain - name:(const string16&)name; - -// The following methods are all used in the bindings inside the cookie -// detail view. -@property (readonly) BOOL isFolderOrCookieTreeDetails; -@property (readonly) BOOL isLocalStorageTreeDetails; -@property (readonly) BOOL isDatabaseTreeDetails; -@property (readonly) BOOL isDatabasePromptDetails; -@property (readonly) BOOL isLocalStoragePromptDetails; -@property (readonly) NSString* name; -@property (readonly) NSString* content; -@property (readonly) NSString* domain; -@property (readonly) NSString* path; -@property (readonly) NSString* sendFor; -@property (readonly) NSString* created; -@property (readonly) NSString* expires; -@property (readonly) NSString* fileSize; -@property (readonly) NSString* lastModified; -@property (readonly) NSString* databaseDescription; -@property (readonly) NSString* localStorageKey; -@property (readonly) NSString* localStorageValue; - +- (CocoaCookieDetails*)details; +- (id)initWithDetails:(CocoaCookieDetails*)details; @end @implementation CookiePromptSelectionAdapter -- (id)initWithCookie:(const std::string&)cookie_line - url:(const GURL&)url { - if ((self = [super init])) { - promptType_ = CookiePromptModalDialog::DIALOG_TYPE_COOKIE; - net::CookieMonster::ParsedCookie pc(cookie_line); - net::CookieMonster::CanonicalCookie cookie(url, pc); - const std::string& domain(pc.HasDomain() ? pc.Domain() : url.host()); - domain_.reset([base::SysUTF8ToNSString(domain) retain]); - name_.reset([base::SysUTF8ToNSString(cookie.Name()) retain]); - content_.reset([base::SysUTF8ToNSString(cookie.Value()) retain]); - path_.reset([base::SysUTF8ToNSString(cookie.Path()) retain]); - - if (cookie.DoesExpire()) { - expires_.reset([base::SysWideToNSString( - base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate())) - retain]); - } else { - expires_.reset([l10n_util::GetNSStringWithFixup( - IDS_COOKIES_COOKIE_EXPIRES_SESSION) retain]); - } - - created_.reset([base::SysWideToNSString( - base::TimeFormatFriendlyDateAndTime(cookie.CreationDate())) - retain]); - - if (cookie.IsSecure()) { - sendFor_.reset([l10n_util::GetNSStringWithFixup( - IDS_COOKIES_COOKIE_SENDFOR_SECURE) retain]); - } else { - sendFor_.reset([l10n_util::GetNSStringWithFixup( - IDS_COOKIES_COOKIE_SENDFOR_ANY) retain]); - } - } - return self; -} - -- (id)initWithLocalStorage:(const std::string&)domain - key:(const string16&)key - value:(const string16&)value { - if ((self = [super init])) { - promptType_ = CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE; - domain_.reset([base::SysUTF8ToNSString(domain) retain]); - localStorageKey_.reset([base::SysUTF16ToNSString(key) retain]); - localStorageValue_.reset([base::SysUTF16ToNSString(value) retain]); - } - return self; -} - -- (id)initWithDatabase:(const std::string&)domain - name:(const string16&)name { +// The adapter assumes ownership of the details object +// in its initializer. +- (id)initWithDetails:(CocoaCookieDetails*)details { if ((self = [super init])) { - promptType_ = CookiePromptModalDialog::DIALOG_TYPE_DATABASE; - name_.reset([base::SysUTF16ToNSString(name) retain]); - domain_.reset([base::SysUTF8ToNSString(domain) retain]); + details_.reset([details retain]); } return self; } -- (BOOL)isFolderOrCookieTreeDetails { - return promptType_ == CookiePromptModalDialog::DIALOG_TYPE_COOKIE; -} - -- (BOOL)isLocalStorageTreeDetails { - return false; -} - -- (BOOL)isDatabaseTreeDetails { - return false; -} - -- (BOOL) isDatabasePromptDetails { - return promptType_ == CookiePromptModalDialog::DIALOG_TYPE_DATABASE; -} - -- (BOOL) isLocalStoragePromptDetails { - return promptType_ == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE; -} - -- (NSString*)name { - return name_; -} - -- (NSString*)content { - return content_; -} - -- (NSString*)domain { - return domain_; -} - -- (NSString*)path { - return path_; -} - -- (NSString*)sendFor { - return sendFor_; -} - -- (NSString*)created { - return created_; -} - -- (NSString*)expires { - return expires_; -} - -- (NSString*)fileSize { - return nil; -} - -- (NSString*)lastModified { - return nil; -} - -- (NSString*)databaseDescription { - return nil; -} - -- (NSString*)localStorageKey { - return localStorageKey_; -} - -- (NSString*)localStorageValue { - return localStorageValue_; +- (CocoaCookieDetails*)details { + return details_.get(); } @end +#pragma mark Window Controller + @implementation CookiePromptWindowController - (id)initWithDialog:(CookiePromptModalDialog*)dialog { @@ -227,23 +63,10 @@ ofType:@"nib"]; if ((self = [super initWithWindowNibPath:nibpath owner:self])) { dialog_ = dialog; - CookiePromptModalDialog::DialogType type(dialog_->dialog_type()); - if (type == CookiePromptModalDialog::DIALOG_TYPE_COOKIE) { - selectionAdapterObject_.reset([[CookiePromptSelectionAdapter alloc] - initWithCookie:dialog_->cookie_line() - url:dialog_->origin()]); - } else if (type == CookiePromptModalDialog::DIALOG_TYPE_LOCAL_STORAGE) { - selectionAdapterObject_.reset([[CookiePromptSelectionAdapter alloc] - initWithLocalStorage:dialog_->origin().host() - key:dialog_->local_storage_key() - value:dialog_->local_storage_value()]); - } else if (type == CookiePromptModalDialog::DIALOG_TYPE_DATABASE) { - selectionAdapterObject_.reset([[CookiePromptSelectionAdapter alloc] - initWithDatabase:dialog_->origin().host() - name:dialog_->database_name()]); - } else { - NOTIMPLEMENTED(); - } + CocoaCookieDetails* details = [CocoaCookieDetails + createFromPromptModalDialog:dialog]; + selectionAdapterObject_.reset([[CookiePromptSelectionAdapter alloc] + initWithDetails:details]); } return self; } diff --git a/chrome/browser/cocoa/cookie_tree_node.h b/chrome/browser/cocoa/cookie_tree_node.h index 66f5851..827c784 100644 --- a/chrome/browser/cocoa/cookie_tree_node.h +++ b/chrome/browser/cocoa/cookie_tree_node.h @@ -6,56 +6,13 @@ #include "base/scoped_nsobject.h" #include "chrome/browser/cookies_tree_model.h" +#include "chrome/browser/cocoa/cookie_details.h" -// This enum specifies the type of display node a CocoaCookieTreeNode is. If -// this system is rewritten to not use bindings, this class should be -// subclassed and specialized, rather than using an enum to determine type. -enum CocoaCookieTreeNodeType { - // Represents grouping data for the actual data. - kCocoaCookieTreeNodeTypeFolder = 0, - - // A cookie node. - kCocoaCookieTreeNodeTypeCookie = 1, - - // A HTML5 database storage node. - kCocoaCookieTreeNodeTypeDatabaseStorage = 2, - - // A local storage node. - kCocoaCookieTreeNodeTypeLocalStorage = 3 -}; - -// This class is used by CookiesWindowController and represents a node in the -// cookie tree view. @interface CocoaCookieTreeNode : NSObject { scoped_nsobject<NSString> title_; scoped_nsobject<NSMutableArray> children_; - - CocoaCookieTreeNodeType nodeType_; - - // The platform-independent model node. + scoped_nsobject<CocoaCookieDetails> details_; CookieTreeNode* treeNode_; // weak - - // These members are only set for kCocoaCookieTreeNodeTypeCookie nodes. - scoped_nsobject<NSString> name_; - scoped_nsobject<NSString> content_; - scoped_nsobject<NSString> path_; - scoped_nsobject<NSString> sendFor_; - // Stringifed dates. - scoped_nsobject<NSString> created_; - scoped_nsobject<NSString> expires_; - - // These members are only set for kCocoaCookieTreeNodeTypeLocalStorage - // and kCocoaCookieTreeNodeTypeDatabaseStorage nodes. - scoped_nsobject<NSString> fileSize_; - scoped_nsobject<NSString> lastModified_; - - // These members are only set for kCocoaCookieTreeNodeTypeCookie and - // kCocoaCookieTreeNodeTypeLocalStorage nodes. - scoped_nsobject<NSString> domain_; - - // These members are used only for nodes of type - // kCocoaCookieTreeNodeTypeDatabaseStorage. - scoped_nsobject<NSString> databaseDescription_; } // Designated initializer. @@ -66,7 +23,7 @@ enum CocoaCookieTreeNodeType { // Common getters.. - (NSString*)title; -- (CocoaCookieTreeNodeType)nodeType; +- (CocoaCookieDetailsType)nodeType; - (TreeModelNode*)treeNode; // |-mutableChildren| exists so that the CookiesTreeModelObserverBridge can @@ -75,27 +32,6 @@ enum CocoaCookieTreeNodeType { - (NSArray*)children; - (BOOL)isLeaf; -- (BOOL)isFolderOrCookieTreeDetails; -- (BOOL)isLocalStorageTreeDetails; -- (BOOL)isDatabaseTreeDetails; -- (BOOL)isLocalStoragePromptDetails; -- (BOOL)isDatabasePromptDetails; - -// Used only by kCocoaCookieTreeNodeTypeCookie. Nil for other types. -- (NSString*)name; -- (NSString*)content; -- (NSString*)domain; -- (NSString*)path; -- (NSString*)sendFor; -- (NSString*)created; -- (NSString*)expires; - -// Used by kCocoaCookieTreeNodeTypeLocalStorage and -// kCocoaCookieTreeNodeTypeDatabaseStorage nodes. Nil for other types. -- (NSString*)fileSize; -- (NSString*)lastModified; - -// Used by kCocoaCookieTreeNodeTypeDatabaseStorage nodes. Nil for other types. -- (NSString*)databaseDescription; +- (CocoaCookieDetails*)details; @end diff --git a/chrome/browser/cocoa/cookie_tree_node.mm b/chrome/browser/cocoa/cookie_tree_node.mm index 376df82..553a7bb 100644 --- a/chrome/browser/cocoa/cookie_tree_node.mm +++ b/chrome/browser/cocoa/cookie_tree_node.mm @@ -4,11 +4,7 @@ #import "chrome/browser/cocoa/cookie_tree_node.h" -#include "app/l10n_util_mac.h" -#import "base/i18n/time_formatting.h" #include "base/sys_string_conversions.h" -#include "chrome/browser/browsing_data_local_storage_helper.h" -#include "grit/generated_resources.h" @implementation CocoaCookieTreeNode @@ -24,68 +20,17 @@ - (void)rebuild { title_.reset([base::SysWideToNSString(treeNode_->GetTitle()) retain]); children_.reset(); - nodeType_ = kCocoaCookieTreeNodeTypeFolder; - - CookieTreeNode::DetailedInfo info = treeNode_->GetDetailedInfo(); - CookieTreeNode::DetailedInfo::NodeType nodeType = info.node_type; - if (nodeType == CookieTreeNode::DetailedInfo::TYPE_COOKIE) { - nodeType_ = kCocoaCookieTreeNodeTypeCookie; - net::CookieMonster::CanonicalCookie cookie = info.cookie->second; - - name_.reset([base::SysUTF8ToNSString(cookie.Name()) retain]); - title_.reset([base::SysUTF8ToNSString(cookie.Name()) retain]); - content_.reset([base::SysUTF8ToNSString(cookie.Value()) retain]); - path_.reset([base::SysUTF8ToNSString(cookie.Path()) retain]); - domain_.reset([base::SysWideToNSString(info.origin) retain]); - - if (cookie.DoesExpire()) { - expires_.reset([base::SysWideToNSString( - base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate())) retain]); - } else { - expires_.reset([l10n_util::GetNSStringWithFixup( - IDS_COOKIES_COOKIE_EXPIRES_SESSION) retain]); - } - - created_.reset([base::SysWideToNSString( - base::TimeFormatFriendlyDateAndTime(cookie.CreationDate())) retain]); - - if (cookie.IsSecure()) { - sendFor_.reset([l10n_util::GetNSStringWithFixup( - IDS_COOKIES_COOKIE_SENDFOR_SECURE) retain]); - } else { - sendFor_.reset([l10n_util::GetNSStringWithFixup( - IDS_COOKIES_COOKIE_SENDFOR_ANY) retain]); - } - } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_DATABASE) { - const BrowsingDataDatabaseHelper::DatabaseInfo* databaseInfo = - info.database_info; - nodeType_ = kCocoaCookieTreeNodeTypeDatabaseStorage; - databaseDescription_.reset([base::SysUTF8ToNSString( - databaseInfo->description) retain]); - fileSize_.reset([base::SysWideToNSString(FormatBytes(databaseInfo->size, - GetByteDisplayUnits(databaseInfo->size), true)) retain]); - lastModified_.reset([base::SysWideToNSString( - base::TimeFormatFriendlyDateAndTime( - databaseInfo->last_modified)) retain]); - } else if (nodeType == CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) { - const BrowsingDataLocalStorageHelper::LocalStorageInfo* storageInfo = - info.local_storage_info; - nodeType_ = kCocoaCookieTreeNodeTypeLocalStorage; - domain_.reset([base::SysUTF8ToNSString(storageInfo->origin) retain]); - fileSize_.reset([base::SysWideToNSString(FormatBytes(storageInfo->size, - GetByteDisplayUnits(storageInfo->size), true)) retain]); - lastModified_.reset([base::SysWideToNSString( - base::TimeFormatFriendlyDateAndTime( - storageInfo->last_modified)) retain]); - } + // The tree node assumes ownership of the cookie details object + details_.reset([[CocoaCookieDetails createFromCookieTreeNode:(treeNode_)] + retain]); } - (NSString*)title { return title_.get(); } -- (CocoaCookieTreeNodeType)nodeType { - return nodeType_; +- (CocoaCookieDetailsType)nodeType { + return [details_.get() type]; } - (TreeModelNode*)treeNode { @@ -111,8 +56,8 @@ } - (BOOL)isLeaf { - return nodeType_ != kCocoaCookieTreeNodeTypeFolder; -} + return [self nodeType] != kCocoaCookieDetailsTypeFolder; +}; - (NSString*)description { NSString* format = @@ -121,91 +66,8 @@ [self nodeType], [[self children] count]]; } -- (BOOL)isFolderOrCookieTreeDetails { - return [self nodeType] == kCocoaCookieTreeNodeTypeFolder || - [self nodeType] == kCocoaCookieTreeNodeTypeCookie; -} - -- (BOOL)isDatabaseTreeDetails { - return [self nodeType] == kCocoaCookieTreeNodeTypeDatabaseStorage; -} - -- (BOOL)isLocalStorageTreeDetails { - return [self nodeType] == kCocoaCookieTreeNodeTypeLocalStorage; -} - -- (BOOL)isDatabasePromptDetails { - return false; -} - -- (BOOL)isLocalStoragePromptDetails { - return false; -} - -#pragma mark Cookie Accessors - -- (NSString*)name { - return name_.get(); -} - -- (NSString*)content { - return content_.get(); -} - -- (NSString*)domain { - return domain_.get(); -} - -- (NSString*)path { - return path_.get(); -} - -- (NSString*)sendFor { - return sendFor_.get(); -} - -- (NSString*)created { - return created_.get(); -} - -- (NSString*)expires { - return expires_.get(); -} - -#pragma mark Local Storage and Database Accessors - -- (NSString*)fileSize { - return fileSize_.get(); -} - -- (NSString*)lastModified { - return lastModified_.get(); -} - -#pragma mark Database Accessors - -- (NSString*)databaseDescription { - return databaseDescription_.get(); -} - -#pragma mark Unused Accessors - -// This method is never called for the cookie tree, it is only -// only included because the Cocoa bindings for the shared view -// used to display browser data details always expects the method -// even though it is only used in the cookie prompt window. -- (id)localStorageKey { - NOTIMPLEMENTED(); - return nil; -} - -// This method is never called for the cookie tree, it is only -// only included because the Cocoa bindings for the shared view -// used to display browser data details always expects the method -// even though it is only used in the cookie prompt window. -- (id)localStorageValue { - NOTIMPLEMENTED(); - return nil; +- (CocoaCookieDetails*)details { + return details_; } @end diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm index fb19db3..898ed9e 100644 --- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm +++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm @@ -141,14 +141,15 @@ TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) { TreeModelNode* node = model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0); CocoaCookieTreeNode* cookie = CocoaNodeFromTreeNode(node); - EXPECT_TRUE([@"B" isEqualToString:[cookie content]]); - EXPECT_TRUE([@"When I close my browser" isEqualToString:[cookie expires]]); - EXPECT_TRUE([@"Any kind of connection" isEqualToString:[cookie sendFor]]); + CocoaCookieDetails* details = [cookie details]; + EXPECT_TRUE([@"B" isEqualToString:[details content]]); + EXPECT_TRUE([@"When I close my browser" isEqualToString:[details expires]]); + EXPECT_TRUE([@"Any kind of connection" isEqualToString:[details sendFor]]); EXPECT_TRUE([@"A" isEqualToString:[cookie title]]); - EXPECT_TRUE([@"A" isEqualToString:[cookie name]]); - EXPECT_TRUE([@"/" isEqualToString:[cookie path]]); + EXPECT_TRUE([@"A" isEqualToString:[details name]]); + EXPECT_TRUE([@"/" isEqualToString:[details path]]); EXPECT_EQ(0U, [[cookie children] count]); - EXPECT_TRUE([cookie created]); + EXPECT_TRUE([details created]); EXPECT_TRUE([cookie isLeaf]); EXPECT_EQ(node, [cookie treeNode]); } @@ -179,15 +180,16 @@ TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeRecursive) { EXPECT_EQ(node->GetChild(0), [cookies treeNode]); // Test cookie node. This is the same as CocoaNodeFromTreeNodeCookie. - EXPECT_TRUE([@"B" isEqualToString:[cookie content]]); - EXPECT_TRUE([@"When I close my browser" isEqualToString:[cookie expires]]); - EXPECT_TRUE([@"Any kind of connection" isEqualToString:[cookie sendFor]]); + CocoaCookieDetails* details = [cookie details]; + EXPECT_TRUE([@"B" isEqualToString:[details content]]); + EXPECT_TRUE([@"When I close my browser" isEqualToString:[details expires]]); + EXPECT_TRUE([@"Any kind of connection" isEqualToString:[details sendFor]]); EXPECT_TRUE([@"A" isEqualToString:[cookie title]]); - EXPECT_TRUE([@"A" isEqualToString:[cookie name]]); - EXPECT_TRUE([@"/" isEqualToString:[cookie path]]); - EXPECT_TRUE([@"foo.com" isEqualToString:[cookie domain]]); + EXPECT_TRUE([@"A" isEqualToString:[details name]]); + EXPECT_TRUE([@"/" isEqualToString:[details path]]); + EXPECT_TRUE([@"foo.com" isEqualToString:[details domain]]); EXPECT_EQ(0U, [[cookie children] count]); - EXPECT_TRUE([cookie created]); + EXPECT_TRUE([details created]); EXPECT_TRUE([cookie isLeaf]); EXPECT_EQ(node->GetChild(0)->GetChild(0), [cookie treeNode]); } @@ -261,7 +263,7 @@ TEST_F(CookiesWindowControllerTest, TreeNodesRemoved) { EXPECT_EQ(1U, [cocoa_children count]); - NSString* title = [[cocoa_children objectAtIndex:0] name]; + NSString* title = [[[cocoa_children objectAtIndex:0] details] name]; EXPECT_TRUE([@"A" isEqualToString:title]); } @@ -286,11 +288,11 @@ TEST_F(CookiesWindowControllerTest, TreeNodeChildrenReordered) { // Check default ordering. CocoaCookieTreeNode* node = [cocoa_children objectAtIndex:0]; - EXPECT_TRUE([@"A" isEqualToString:[node name]]); + EXPECT_TRUE([@"A" isEqualToString:[[node details] name]]); node = [cocoa_children objectAtIndex:1]; - EXPECT_TRUE([@"C" isEqualToString:[node name]]); + EXPECT_TRUE([@"C" isEqualToString:[[node details] name]]); node = [cocoa_children objectAtIndex:2]; - EXPECT_TRUE([@"E" isEqualToString:[node name]]); + EXPECT_TRUE([@"E" isEqualToString:[[node details] name]]); CookiesTreeModel* model = [controller_ treeModel]; // Root --> foo.com --> Cookies. @@ -307,11 +309,11 @@ TEST_F(CookiesWindowControllerTest, TreeNodeChildrenReordered) { // Check the new order. node = [cocoa_children objectAtIndex:0]; - EXPECT_TRUE([@"E" isEqualToString:[node name]]); + EXPECT_TRUE([@"E" isEqualToString:[[node details] name]]); node = [cocoa_children objectAtIndex:1]; - EXPECT_TRUE([@"A" isEqualToString:[node name]]); + EXPECT_TRUE([@"A" isEqualToString:[[node details] name]]); node = [cocoa_children objectAtIndex:2]; - EXPECT_TRUE([@"C" isEqualToString:[node name]]); + EXPECT_TRUE([@"C" isEqualToString:[[node details] name]]); } TEST_F(CookiesWindowControllerTest, TreeNodeChanged) { @@ -590,43 +592,45 @@ TEST_F(CookiesWindowControllerTest, CreateDatabaseStorageNodes) { CocoaCookieTreeNode* node = [[[controller_ cocoaTreeModel] children] objectAtIndex:0]; EXPECT_TRUE([@"gdbhost1" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // host1 --> Web Databases. node = [[node children] lastObject]; EXPECT_TRUE([@"Web Databases" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // Database Storage --> db1. node = [[node children] lastObject]; EXPECT_TRUE([@"db1" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeDatabaseStorage, [node nodeType]); - EXPECT_TRUE([@"description 1" isEqualToString:[node databaseDescription]]); - EXPECT_TRUE([node lastModified]); - EXPECT_TRUE([node fileSize]); + EXPECT_EQ(kCocoaCookieDetailsTypeTreeDatabase, [node nodeType]); + CocoaCookieDetails* details = [node details]; + EXPECT_TRUE([@"description 1" isEqualToString:[details databaseDescription]]); + EXPECT_TRUE([details lastModified]); + EXPECT_TRUE([details fileSize]); // Root --> gdbhost2. node = [[[controller_ cocoaTreeModel] children] objectAtIndex:1]; EXPECT_TRUE([@"gdbhost2" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // host1 --> Web Databases. node = [[node children] lastObject]; EXPECT_TRUE([@"Web Databases" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // Database Storage --> db2. node = [[node children] lastObject]; EXPECT_TRUE([@"db2" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeDatabaseStorage, [node nodeType]); - EXPECT_TRUE([@"description 2" isEqualToString:[node databaseDescription]]); - EXPECT_TRUE([node lastModified]); - EXPECT_TRUE([node fileSize]); + EXPECT_EQ(kCocoaCookieDetailsTypeTreeDatabase, [node nodeType]); + details = [node details]; + EXPECT_TRUE([@"description 2" isEqualToString:[details databaseDescription]]); + EXPECT_TRUE([details lastModified]); + EXPECT_TRUE([details fileSize]); } TEST_F(CookiesWindowControllerTest, CreateLocalStorageNodes) { @@ -649,43 +653,43 @@ TEST_F(CookiesWindowControllerTest, CreateLocalStorageNodes) { CocoaCookieTreeNode* node = [[[controller_ cocoaTreeModel] children] objectAtIndex:2]; EXPECT_TRUE([@"host1" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // host1 --> Local Storage. node = [[node children] lastObject]; EXPECT_TRUE([@"Local Storage" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // Local Storage --> origin1. node = [[node children] lastObject]; EXPECT_TRUE([@"origin1" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeLocalStorage, [node nodeType]); - EXPECT_TRUE([@"origin1" isEqualToString:[node domain]]); - EXPECT_TRUE([node lastModified]); - EXPECT_TRUE([node fileSize]); + EXPECT_EQ(kCocoaCookieDetailsTypeTreeLocalStorage, [node nodeType]); + EXPECT_TRUE([@"origin1" isEqualToString:[[node details] domain]]); + EXPECT_TRUE([[node details] lastModified]); + EXPECT_TRUE([[node details] fileSize]); // Root --> host2. node = [[[controller_ cocoaTreeModel] children] objectAtIndex:3]; EXPECT_TRUE([@"host2" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // host2 --> Local Storage. node = [[node children] lastObject]; EXPECT_TRUE([@"Local Storage" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeFolder, [node nodeType]); + EXPECT_EQ(kCocoaCookieDetailsTypeFolder, [node nodeType]); EXPECT_EQ(1U, [[node children] count]); // Local Storage --> origin2. node = [[node children] lastObject]; EXPECT_TRUE([@"origin2" isEqualToString:[node title]]); - EXPECT_EQ(kCocoaCookieTreeNodeTypeLocalStorage, [node nodeType]); - EXPECT_TRUE([@"origin2" isEqualToString:[node domain]]); - EXPECT_TRUE([node lastModified]); - EXPECT_TRUE([node fileSize]); + EXPECT_EQ(kCocoaCookieDetailsTypeTreeLocalStorage, [node nodeType]); + EXPECT_TRUE([@"origin2" isEqualToString:[[node details] domain]]); + EXPECT_TRUE([[node details] lastModified]); + EXPECT_TRUE([[node details] fileSize]); } } // namespace diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 9560f97..0c399b2 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -546,10 +546,12 @@ 'browser/cocoa/content_exceptions_window_controller.mm', 'browser/cocoa/content_settings_dialog_controller.h', 'browser/cocoa/content_settings_dialog_controller.mm', - 'browser/cocoa/cookie_tree_node.h', - 'browser/cocoa/cookie_tree_node.mm', + 'browser/cocoa/cookie_details.h', + 'browser/cocoa/cookie_details.mm', 'browser/cocoa/cookie_details_view_controller.h', 'browser/cocoa/cookie_details_view_controller.mm', + 'browser/cocoa/cookie_tree_node.h', + 'browser/cocoa/cookie_tree_node.mm', 'browser/cocoa/cookies_window_controller.h', 'browser/cocoa/cookies_window_controller.mm', 'browser/cocoa/cookie_prompt_window_controller.h', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 97a7f32..c5522a0 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -643,6 +643,7 @@ 'browser/cocoa/content_settings_dialog_controller_unittest.mm', 'browser/cocoa/cookies_window_controller_unittest.mm', 'browser/cocoa/cookie_prompt_window_controller_unittest.mm', + 'browser/cocoa/cookie_details_unittest.mm', 'browser/cocoa/cookie_details_view_controller_unittest.mm', 'browser/cocoa/custom_home_pages_model_unittest.mm', 'browser/cocoa/delayedmenu_button_unittest.mm', |