diff options
-rw-r--r-- | chrome/app/nibs/PageInfo.xib | 935 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller.h | 35 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller.mm | 86 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_controller_unittest.mm | 50 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_mac.h | 36 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_mac.mm | 198 | ||||
-rw-r--r-- | chrome/browser/cocoa/page_info_window_mac_unittest.mm | 195 | ||||
-rw-r--r-- | chrome/browser/page_info_model.h | 18 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 1 | ||||
-rw-r--r-- | chrome/chrome_dll.gypi | 1 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 |
11 files changed, 419 insertions, 1138 deletions
diff --git a/chrome/app/nibs/PageInfo.xib b/chrome/app/nibs/PageInfo.xib deleted file mode 100644 index 9b31f68..0000000 --- a/chrome/app/nibs/PageInfo.xib +++ /dev/null @@ -1,935 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> - <data> - <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L31a</string> - <string key="IBDocument.InterfaceBuilderVersion">677</string> - <string key="IBDocument.AppKitVersion">949.54</string> - <string key="IBDocument.HIToolboxVersion">353.00</string> - <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> - <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1"/> - </object> - <object class="NSArray" key="IBDocument.PluginDependencies"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - </object> - <object class="NSMutableDictionary" key="IBDocument.Metadata"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - </object> - <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSCustomObject" id="1001"> - <string key="NSClassName">PageInfoWindowController</string> - </object> - <object class="NSCustomObject" id="1003"> - <string key="NSClassName">FirstResponder</string> - </object> - <object class="NSCustomObject" id="1004"> - <string key="NSClassName">NSApplication</string> - </object> - <object class="NSWindowTemplate" id="1005"> - <int key="NSWindowStyleMask">7</int> - <int key="NSWindowBacking">2</int> - <string key="NSWindowRect">{{196, 216}, {460, 290}}</string> - <int key="NSWTFlags">536870912</int> - <string key="NSWindowTitle">^IDS_PAGEINFO_WINDOW_TITLE</string> - <string key="NSWindowClass">NSWindow</string> - <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> - <object class="NSView" key="NSWindowView" id="1006"> - <reference key="NSNextResponder"/> - <int key="NSvFlags">256</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSBox" id="431855544"> - <reference key="NSNextResponder" ref="1006"/> - <int key="NSvFlags">12</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSView" id="225157021"> - <reference key="NSNextResponder" ref="431855544"/> - <int key="NSvFlags">256</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSImageView" id="962782496"> - <reference key="NSNextResponder" ref="225157021"/> - <int key="NSvFlags">268</int> - <object class="NSMutableSet" key="NSDragTypes"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="set.sortedObjects"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>Apple PDF pasteboard type</string> - <string>Apple PICT pasteboard type</string> - <string>Apple PNG pasteboard type</string> - <string>NSFilenamesPboardType</string> - <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string> - <string>NeXT TIFF v4.0 pasteboard type</string> - </object> - </object> - <string key="NSFrame">{{18, 14}, {30, 30}}</string> - <reference key="NSSuperview" ref="225157021"/> - <bool key="NSEnabled">YES</bool> - <object class="NSImageCell" key="NSCell" id="810131060"> - <int key="NSCellFlags">130560</int> - <int key="NSCellFlags2">33554432</int> - <int key="NSAlign">0</int> - <int key="NSScale">2</int> - <int key="NSStyle">0</int> - <bool key="NSAnimates">NO</bool> - </object> - <bool key="NSEditable">YES</bool> - </object> - <object class="NSTextField" id="848644722"> - <reference key="NSNextResponder" ref="225157021"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{53, 14}, {358, 30}}</string> - <reference key="NSSuperview" ref="225157021"/> - <bool key="NSEnabled">YES</bool> - <object class="NSTextFieldCell" key="NSCell" id="482159508"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">272629760</int> - <string key="NSContents">Multiline Label</string> - <object class="NSFont" key="NSSupport" id="157990634"> - <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.100000e+01</double> - <int key="NSfFlags">16</int> - </object> - <reference key="NSControlView" ref="848644722"/> - <object class="NSColor" key="NSBackgroundColor" id="755488189"> - <int key="NSColorSpace">6</int> - <string key="NSCatalogName">System</string> - <string key="NSColorName">controlColor</string> - <object class="NSColor" key="NSColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> - </object> - </object> - <object class="NSColor" key="NSTextColor" id="930195236"> - <int key="NSColorSpace">6</int> - <string key="NSCatalogName">System</string> - <string key="NSColorName">controlTextColor</string> - <object class="NSColor" key="NSColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MAA</bytes> - </object> - </object> - </object> - </object> - </object> - <string key="NSFrame">{{1, 1}, {426, 54}}</string> - <reference key="NSSuperview" ref="431855544"/> - </object> - </object> - <string key="NSFrame">{{16, 200}, {428, 70}}</string> - <reference key="NSSuperview" ref="1006"/> - <string key="NSOffsets">{0, 0}</string> - <object class="NSTextFieldCell" key="NSTitleCell"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">0</int> - <string key="NSContents">^IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE</string> - <object class="NSFont" key="NSSupport" id="26"> - <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.100000e+01</double> - <int key="NSfFlags">3100</int> - </object> - <object class="NSColor" key="NSBackgroundColor" id="359763623"> - <int key="NSColorSpace">6</int> - <string key="NSCatalogName">System</string> - <string key="NSColorName">textBackgroundColor</string> - <object class="NSColor" key="NSColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MQA</bytes> - </object> - </object> - <object class="NSColor" key="NSTextColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes> - </object> - </object> - <reference key="NSContentView" ref="225157021"/> - <int key="NSBorderType">1</int> - <int key="NSBoxType">0</int> - <int key="NSTitlePosition">2</int> - <bool key="NSTransparent">NO</bool> - </object> - <object class="NSBox" id="792616117"> - <reference key="NSNextResponder" ref="1006"/> - <int key="NSvFlags">12</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSView" id="277547661"> - <reference key="NSNextResponder" ref="792616117"/> - <int key="NSvFlags">256</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSImageView" id="988006815"> - <reference key="NSNextResponder" ref="277547661"/> - <int key="NSvFlags">268</int> - <object class="NSMutableSet" key="NSDragTypes"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="set.sortedObjects"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>Apple PDF pasteboard type</string> - <string>Apple PICT pasteboard type</string> - <string>Apple PNG pasteboard type</string> - <string>NSFilenamesPboardType</string> - <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string> - <string>NeXT TIFF v4.0 pasteboard type</string> - </object> - </object> - <string key="NSFrame">{{18, 14}, {30, 30}}</string> - <reference key="NSSuperview" ref="277547661"/> - <bool key="NSEnabled">YES</bool> - <object class="NSImageCell" key="NSCell" id="612578912"> - <int key="NSCellFlags">130560</int> - <int key="NSCellFlags2">33554432</int> - <int key="NSAlign">0</int> - <int key="NSScale">2</int> - <int key="NSStyle">0</int> - <bool key="NSAnimates">NO</bool> - </object> - <bool key="NSEditable">YES</bool> - </object> - <object class="NSTextField" id="527959022"> - <reference key="NSNextResponder" ref="277547661"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{53, 14}, {358, 30}}</string> - <reference key="NSSuperview" ref="277547661"/> - <bool key="NSEnabled">YES</bool> - <object class="NSTextFieldCell" key="NSCell" id="937890898"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">272629760</int> - <string key="NSContents">Multiline Label</string> - <reference key="NSSupport" ref="157990634"/> - <reference key="NSControlView" ref="527959022"/> - <reference key="NSBackgroundColor" ref="755488189"/> - <reference key="NSTextColor" ref="930195236"/> - </object> - </object> - </object> - <string key="NSFrame">{{1, 1}, {426, 54}}</string> - <reference key="NSSuperview" ref="792616117"/> - </object> - </object> - <string key="NSFrame">{{16, 126}, {428, 70}}</string> - <reference key="NSSuperview" ref="1006"/> - <string key="NSOffsets">{0, 0}</string> - <object class="NSTextFieldCell" key="NSTitleCell"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">0</int> - <string key="NSContents">^IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE</string> - <reference key="NSSupport" ref="26"/> - <reference key="NSBackgroundColor" ref="359763623"/> - <object class="NSColor" key="NSTextColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes> - </object> - </object> - <reference key="NSContentView" ref="277547661"/> - <int key="NSBorderType">1</int> - <int key="NSBoxType">0</int> - <int key="NSTitlePosition">2</int> - <bool key="NSTransparent">NO</bool> - </object> - <object class="NSBox" id="901112678"> - <reference key="NSNextResponder" ref="1006"/> - <int key="NSvFlags">12</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSView" id="1038706718"> - <reference key="NSNextResponder" ref="901112678"/> - <int key="NSvFlags">256</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSImageView" id="763385001"> - <reference key="NSNextResponder" ref="1038706718"/> - <int key="NSvFlags">268</int> - <object class="NSMutableSet" key="NSDragTypes"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="set.sortedObjects"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>Apple PDF pasteboard type</string> - <string>Apple PICT pasteboard type</string> - <string>Apple PNG pasteboard type</string> - <string>NSFilenamesPboardType</string> - <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string> - <string>NeXT TIFF v4.0 pasteboard type</string> - </object> - </object> - <string key="NSFrame">{{18, 14}, {30, 30}}</string> - <reference key="NSSuperview" ref="1038706718"/> - <bool key="NSEnabled">YES</bool> - <object class="NSImageCell" key="NSCell" id="505989441"> - <int key="NSCellFlags">130560</int> - <int key="NSCellFlags2">33554432</int> - <int key="NSAlign">0</int> - <int key="NSScale">2</int> - <int key="NSStyle">0</int> - <bool key="NSAnimates">NO</bool> - </object> - <bool key="NSEditable">YES</bool> - </object> - <object class="NSTextField" id="733407920"> - <reference key="NSNextResponder" ref="1038706718"/> - <int key="NSvFlags">268</int> - <string key="NSFrame">{{53, 14}, {358, 30}}</string> - <reference key="NSSuperview" ref="1038706718"/> - <bool key="NSEnabled">YES</bool> - <object class="NSTextFieldCell" key="NSCell" id="768941348"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">272629760</int> - <string key="NSContents">Multiline Label</string> - <reference key="NSSupport" ref="157990634"/> - <reference key="NSControlView" ref="733407920"/> - <reference key="NSBackgroundColor" ref="755488189"/> - <reference key="NSTextColor" ref="930195236"/> - </object> - </object> - </object> - <string key="NSFrame">{{1, 1}, {426, 54}}</string> - <reference key="NSSuperview" ref="901112678"/> - </object> - </object> - <string key="NSFrame">{{16, 52}, {428, 70}}</string> - <reference key="NSSuperview" ref="1006"/> - <string key="NSOffsets">{0, 0}</string> - <object class="NSTextFieldCell" key="NSTitleCell"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">0</int> - <string key="NSContents">^IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE</string> - <reference key="NSSupport" ref="26"/> - <reference key="NSBackgroundColor" ref="359763623"/> - <object class="NSColor" key="NSTextColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes> - </object> - </object> - <reference key="NSContentView" ref="1038706718"/> - <int key="NSBorderType">1</int> - <int key="NSBoxType">0</int> - <int key="NSTitlePosition">2</int> - <bool key="NSTransparent">NO</bool> - </object> - <object class="NSCustomView" id="230975413"> - <reference key="NSNextResponder" ref="1006"/> - <int key="NSvFlags">292</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSButton" id="339407270"> - <reference key="NSNextResponder" ref="230975413"/> - <int key="NSvFlags">292</int> - <string key="NSFrame">{{14, 12}, {126, 32}}</string> - <reference key="NSSuperview" ref="230975413"/> - <bool key="NSEnabled">YES</bool> - <object class="NSButtonCell" key="NSCell" id="395621113"> - <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">134217728</int> - <string key="NSContents">^IDS_PAGEINFO_CERT_INFO_BUTTON</string> - <object class="NSFont" key="NSSupport"> - <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.300000e+01</double> - <int key="NSfFlags">1044</int> - </object> - <reference key="NSControlView" ref="339407270"/> - <int key="NSButtonFlags">-2038284033</int> - <int key="NSButtonFlags2">129</int> - <string key="NSAlternateContents"/> - <string key="NSKeyEquivalent"/> - <int key="NSPeriodicDelay">200</int> - <int key="NSPeriodicInterval">25</int> - </object> - </object> - </object> - <string key="NSFrame">{{-1, 0}, {154, 48}}</string> - <reference key="NSSuperview" ref="1006"/> - <string key="NSClassName">GTMWidthBasedTweaker</string> - </object> - </object> - <string key="NSFrameSize">{460, 290}</string> - <reference key="NSSuperview"/> - </object> - <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> - <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> - </object> - <object class="NSCustomObject" id="664010657"> - <string key="NSClassName">GTMUILocalizerAndLayoutTweaker</string> - </object> - <object class="NSCustomObject" id="109132430"> - <string key="NSClassName">ChromeUILocalizer</string> - </object> - </object> - <object class="IBObjectContainer" key="IBDocument.Objects"> - <object class="NSMutableArray" key="connectionRecords"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">window</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="1005"/> - </object> - <int key="connectionID">5</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">showCertWindow:</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="339407270"/> - </object> - <int key="connectionID">39</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">enabled: enableCertButton</string> - <reference key="source" ref="339407270"/> - <reference key="destination" ref="1001"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="339407270"/> - <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">enabled: enableCertButton</string> - <string key="NSBinding">enabled</string> - <string key="NSKeyPath">enableCertButton</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">47</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: historyImg</string> - <reference key="source" ref="763385001"/> - <reference key="destination" ref="1001"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="763385001"/> - <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">value: historyImg</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">historyImg</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">48</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: historyMsg</string> - <reference key="source" ref="733407920"/> - <reference key="destination" ref="1001"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="733407920"/> - <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">value: historyMsg</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">historyMsg</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">51</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: connectionMsg</string> - <reference key="source" ref="527959022"/> - <reference key="destination" ref="1001"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="527959022"/> - <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">value: connectionMsg</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">connectionMsg</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">52</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: connectionImg</string> - <reference key="source" ref="988006815"/> - <reference key="destination" ref="1001"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="988006815"/> - <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">value: connectionImg</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">connectionImg</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">53</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: identityMsg</string> - <reference key="source" ref="848644722"/> - <reference key="destination" ref="1001"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="848644722"/> - <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">value: identityMsg</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">identityMsg</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">54</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> - <string key="label">value: identityImg</string> - <reference key="source" ref="962782496"/> - <reference key="destination" ref="1001"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="962782496"/> - <reference key="NSDestination" ref="1001"/> - <string key="NSLabel">value: identityImg</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">identityImg</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">55</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">delegate</string> - <reference key="source" ref="1005"/> - <reference key="destination" ref="1001"/> - </object> - <int key="connectionID">56</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">historyBox_</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="901112678"/> - </object> - <int key="connectionID">57</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">localizer_</string> - <reference key="source" ref="664010657"/> - <reference key="destination" ref="109132430"/> - </object> - <int key="connectionID">61</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">uiObject_</string> - <reference key="source" ref="664010657"/> - <reference key="destination" ref="1005"/> - </object> - <int key="connectionID">62</int> - </object> - </object> - <object class="IBMutableOrderedSet" key="objectRecords"> - <object class="NSArray" key="orderedObjects"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBObjectRecord"> - <int key="objectID">0</int> - <object class="NSArray" key="object" id="1002"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <reference key="children" ref="1000"/> - <nil key="parent"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-2</int> - <reference key="object" ref="1001"/> - <reference key="parent" ref="1002"/> - <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-1</int> - <reference key="object" ref="1003"/> - <reference key="parent" ref="1002"/> - <string key="objectName">First Responder</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-3</int> - <reference key="object" ref="1004"/> - <reference key="parent" ref="1002"/> - <string key="objectName">Application</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">1</int> - <reference key="object" ref="1005"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="1006"/> - </object> - <reference key="parent" ref="1002"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">2</int> - <reference key="object" ref="1006"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="431855544"/> - <reference ref="792616117"/> - <reference ref="901112678"/> - <reference ref="230975413"/> - </object> - <reference key="parent" ref="1005"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">6</int> - <reference key="object" ref="431855544"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="962782496"/> - <reference ref="848644722"/> - </object> - <reference key="parent" ref="1006"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">7</int> - <reference key="object" ref="792616117"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="988006815"/> - <reference ref="527959022"/> - </object> - <reference key="parent" ref="1006"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">8</int> - <reference key="object" ref="901112678"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="763385001"/> - <reference ref="733407920"/> - </object> - <reference key="parent" ref="1006"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">20</int> - <reference key="object" ref="763385001"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="505989441"/> - </object> - <reference key="parent" ref="901112678"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">21</int> - <reference key="object" ref="505989441"/> - <reference key="parent" ref="763385001"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">17</int> - <reference key="object" ref="962782496"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="810131060"/> - </object> - <reference key="parent" ref="431855544"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">18</int> - <reference key="object" ref="810131060"/> - <reference key="parent" ref="962782496"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">22</int> - <reference key="object" ref="988006815"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="612578912"/> - </object> - <reference key="parent" ref="792616117"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">23</int> - <reference key="object" ref="612578912"/> - <reference key="parent" ref="988006815"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">28</int> - <reference key="object" ref="848644722"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="482159508"/> - </object> - <reference key="parent" ref="431855544"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">29</int> - <reference key="object" ref="482159508"/> - <reference key="parent" ref="848644722"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">30</int> - <reference key="object" ref="527959022"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="937890898"/> - </object> - <reference key="parent" ref="792616117"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">31</int> - <reference key="object" ref="937890898"/> - <reference key="parent" ref="527959022"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">32</int> - <reference key="object" ref="733407920"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="768941348"/> - </object> - <reference key="parent" ref="901112678"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">33</int> - <reference key="object" ref="768941348"/> - <reference key="parent" ref="733407920"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">58</int> - <reference key="object" ref="230975413"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="339407270"/> - </object> - <reference key="parent" ref="1006"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">11</int> - <reference key="object" ref="339407270"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="395621113"/> - </object> - <reference key="parent" ref="230975413"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">12</int> - <reference key="object" ref="395621113"/> - <reference key="parent" ref="339407270"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">59</int> - <reference key="object" ref="664010657"/> - <reference key="parent" ref="1002"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">60</int> - <reference key="object" ref="109132430"/> - <reference key="parent" ref="1002"/> - </object> - </object> - </object> - <object class="NSMutableDictionary" key="flattenedProperties"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>-1.IBPluginDependency</string> - <string>-2.IBPluginDependency</string> - <string>-3.IBPluginDependency</string> - <string>1.IBEditorWindowLastContentRect</string> - <string>1.IBPluginDependency</string> - <string>1.IBViewEditorWindowController.showingBoundsRectangles</string> - <string>1.IBWindowTemplateEditedContentRect</string> - <string>1.NSWindowTemplate.visibleAtLaunch</string> - <string>1.WindowOrigin</string> - <string>1.editorWindowContentRectSynchronizationRect</string> - <string>11.IBPluginDependency</string> - <string>12.IBPluginDependency</string> - <string>17.IBPluginDependency</string> - <string>18.IBPluginDependency</string> - <string>2.IBPluginDependency</string> - <string>20.IBPluginDependency</string> - <string>21.IBPluginDependency</string> - <string>22.IBPluginDependency</string> - <string>23.IBPluginDependency</string> - <string>28.IBPluginDependency</string> - <string>29.IBPluginDependency</string> - <string>30.IBPluginDependency</string> - <string>31.IBPluginDependency</string> - <string>32.IBPluginDependency</string> - <string>33.IBPluginDependency</string> - <string>59.IBPluginDependency</string> - <string>6.IBPluginDependency</string> - <string>60.IBPluginDependency</string> - <string>7.IBPluginDependency</string> - <string>8.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>{{303, 366}, {460, 290}}</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <boolean value="NO" id="6"/> - <string>{{303, 366}, {460, 290}}</string> - <reference ref="6"/> - <string>{196, 240}</string> - <string>{{357, 418}, {480, 270}}</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> - <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> - <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> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - </object> - </object> - <object class="NSMutableDictionary" key="unlocalizedProperties"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - </object> - <nil key="activeLocalization"/> - <object class="NSMutableDictionary" key="localizations"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - </object> - <nil key="sourceID"/> - <int key="maxID">62</int> - </object> - <object class="IBClassDescriber" key="IBDocument.Classes"> - <object class="NSMutableArray" key="referencedPartialClassDescriptions"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBPartialClassDescription"> - <string key="className">ChromeUILocalizer</string> - <string key="superclassName">GTMUILocalizer</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/ui_localizer.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">GTMUILocalizer</string> - <string key="superclassName">NSObject</string> - <object class="NSMutableDictionary" key="outlets"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>otherObjectToLocalize_</string> - <string>owner_</string> - <string>yetAnotherObjectToLocalize_</string> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>id</string> - <string>id</string> - <string>id</string> - </object> - </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">../third_party/GTM/AppKit/GTMUILocalizer.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">GTMUILocalizerAndLayoutTweaker</string> - <string key="superclassName">NSObject</string> - <object class="NSMutableDictionary" key="outlets"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>localizerOwner_</string> - <string>localizer_</string> - <string>uiObject_</string> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>id</string> - <string>GTMUILocalizer</string> - <string>id</string> - </object> - </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="879734295"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">../third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">GTMWidthBasedTweaker</string> - <string key="superclassName">NSView</string> - <object class="NSMutableDictionary" key="outlets"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>viewToResize_</string> - <string>viewToSlideAndResize_</string> - <string>viewToSlide_</string> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>id</string> - <string>NSView</string> - <string>NSView</string> - </object> - </object> - <reference key="sourceIdentifier" ref="879734295"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/status_bubble_mac.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">PageInfoWindowController</string> - <string key="superclassName">NSWindowController</string> - <object class="NSMutableDictionary" key="actions"> - <string key="NS.key.0">showCertWindow:</string> - <string key="NS.object.0">id</string> - </object> - <object class="NSMutableDictionary" key="outlets"> - <string key="NS.key.0">historyBox_</string> - <string key="NS.object.0">NSBox</string> - </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">browser/cocoa/page_info_window_controller.h</string> - </object> - </object> - </object> - </object> - <int key="IBDocument.localizationMode">0</int> - <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string> - <int key="IBDocument.defaultPropertyAccessControl">3</int> - </data> -</archive> diff --git a/chrome/browser/cocoa/page_info_window_controller.h b/chrome/browser/cocoa/page_info_window_controller.h index c8e5564..4a9624c 100644 --- a/chrome/browser/cocoa/page_info_window_controller.h +++ b/chrome/browser/cocoa/page_info_window_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. @@ -16,49 +16,16 @@ class PrefService; @interface PageInfoWindowController : NSWindowController { @private - // We load both images and then we share the refs with our UI elements. - scoped_nsobject<NSImage> goodImg_; - scoped_nsobject<NSImage> badImg_; - - // User interface item values. The NIB uses KVO to get these, so the values - // are not explicitly set in the view by the controller. - NSImage* identityImg_; - NSImage* connectionImg_; - NSImage* historyImg_; - NSString* identityMsg_; - NSString* connectionMsg_; - NSString* historyMsg_; - BOOL enableCertButton_; - - // Box that allows us to show/hide the history information. - IBOutlet NSBox* historyBox_; - // Bridge to Chromium that we own. scoped_ptr<PageInfoWindowMac> pageInfo_; scoped_nsobject<WindowSizeAutosaver> sizeSaver_; } -@property(readwrite, retain) NSImage* identityImg; -@property(readwrite, retain) NSImage* connectionImg; -@property(readwrite, retain) NSImage* historyImg; -@property(readwrite, copy) NSString* identityMsg; -@property(readwrite, copy) NSString* connectionMsg; -@property(readwrite, copy) NSString* historyMsg; -@property(readwrite) BOOL enableCertButton; - // Sets the bridge between Cocoa and Chromium. - (void)setPageInfo:(PageInfoWindowMac*)pageInfo; -// Returns the good and bad image refs. -- (NSImage*)goodImg; -- (NSImage*)badImg; - // Shows the certificate display window - (IBAction)showCertWindow:(id)sender; -// Sets whether or not to show or hide the history box. This will resize the -// frame of the window. -- (void)setShowHistoryBox:(BOOL)show; - @end diff --git a/chrome/browser/cocoa/page_info_window_controller.mm b/chrome/browser/cocoa/page_info_window_controller.mm index 988f6b9..521ab68 100644 --- a/chrome/browser/cocoa/page_info_window_controller.mm +++ b/chrome/browser/cocoa/page_info_window_controller.mm @@ -1,10 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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 "chrome/browser/cocoa/page_info_window_controller.h" -#include "app/resource_bundle.h" +#include "app/l10n_util_mac.h" #include "base/mac_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -12,25 +12,30 @@ #include "chrome/browser/cocoa/window_size_autosaver.h" #include "chrome/browser/pref_service.h" #include "chrome/common/pref_names.h" -#include "grit/theme_resources.h" +#include "grit/generated_resources.h" + +namespace { + +// The width of the window. The height will be determined by the content. +const NSInteger kWindowWidth = 460; + +} // namespace @implementation PageInfoWindowController -@synthesize identityImg = identityImg_; -@synthesize connectionImg = connectionImg_; -@synthesize historyImg = historyImg_; -@synthesize identityMsg = identityMsg_; -@synthesize connectionMsg = connectionMsg_; -@synthesize historyMsg = historyMsg_; -@synthesize enableCertButton = enableCertButton_; - (id)init { - NSBundle* bundle = mac_util::MainAppBundle(); - NSString* nibpath = [bundle pathForResource:@"PageInfo" ofType:@"nib"]; - if ((self = [super initWithWindowNibPath:nibpath owner:self])) { - // Load the image refs. - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - goodImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_GOOD) retain]); - badImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_BAD) retain]); + NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | + NSMiniaturizableWindowMask; + scoped_nsobject<NSWindow> window( + // Use an arbitrary height because it will be changed by the bridge. + [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, kWindowWidth, 100) + styleMask:styleMask + backing:NSBackingStoreBuffered + defer:NO]); + if ((self = [super initWithWindow:window.get()])) { + [window setTitle: + l10n_util::GetNSStringWithFixup(IDS_PAGEINFO_WINDOW_TITLE)]; + [window setDelegate:self]; if (g_browser_process && g_browser_process->local_state()) { sizeSaver_.reset([[WindowSizeAutosaver alloc] @@ -38,66 +43,19 @@ prefService:g_browser_process->local_state() path:prefs::kPageInfoWindowPlacement state:kSaveWindowPos]); - // Cascade again to get the offset when opening new windows. - NSRect frame = [[self window] frame]; - NSPoint cascadePoint = [[self window] - cascadeTopLeftFromPoint:NSMakePoint(NSMinX(frame), NSMaxY(frame))]; - [[self window] cascadeTopLeftFromPoint:cascadePoint]; } } return self; } -- (void)awakeFromNib { - // By default, assume we have no history information. - [self setShowHistoryBox:NO]; -} - -- (void)dealloc { - [identityImg_ release]; - [connectionImg_ release]; - [historyImg_ release]; - [identityMsg_ release]; - [connectionMsg_ release]; - [historyMsg_ release]; - [super dealloc]; -} - - (void)setPageInfo:(PageInfoWindowMac*)pageInfo { pageInfo_.reset(pageInfo); } -- (NSImage*)goodImg { - return goodImg_.get(); -} - -- (NSImage*)badImg { - return badImg_.get(); -} - - (IBAction)showCertWindow:(id)sender { pageInfo_->ShowCertDialog(0); // Pass it any int because it's ignored. } -- (void)setShowHistoryBox:(BOOL)show { - [historyBox_ setHidden:!show]; - - NSWindow* window = [self window]; - NSRect frame = [window frame]; - - const NSSize kPageInfoWindowSize = NSMakeSize(460, 235); - const NSSize kPageInfoWindowWithHistorySize = NSMakeSize(460, 310); - - NSSize size = (show ? kPageInfoWindowWithHistorySize : kPageInfoWindowSize); - - // Just setting |size| will cause the window to grow upwards. Shift the - // origin up by grow amount, which causes the window to grow downwards. - frame.origin.y -= size.height - frame.size.height; - frame.size = size; - - [window setFrame:frame display:YES animate:YES]; -} - // If the page info window gets closed, we have nothing left to manage and we // can clean ourselves up. - (void)windowWillClose:(NSNotification*)notif { diff --git a/chrome/browser/cocoa/page_info_window_controller_unittest.mm b/chrome/browser/cocoa/page_info_window_controller_unittest.mm deleted file mode 100644 index 8ca4782..0000000 --- a/chrome/browser/cocoa/page_info_window_controller_unittest.mm +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2009 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/scoped_nsobject.h" -#import "chrome/browser/cocoa/page_info_window_controller.h" -#include "chrome/browser/cocoa/browser_test_helper.h" -#import "chrome/browser/cocoa/cocoa_test_helper.h" - -class PageInfoWindowControllerTest : public CocoaTest { - virtual void SetUp() { - CocoaTest::SetUp(); - controller_ = [[PageInfoWindowController alloc] init]; - EXPECT_TRUE([controller_ window]); - } - - virtual void TearDown() { - [controller_ close]; - CocoaTest::TearDown(); - } - - public: - BrowserTestHelper helper_; - PageInfoWindowController* controller_; -}; - - -TEST_F(PageInfoWindowControllerTest, TestImages) { - EXPECT_TRUE([controller_ goodImg]); - EXPECT_TRUE([controller_ badImg]); -} - - -TEST_F(PageInfoWindowControllerTest, TestGrow) { - NSRect frame = [[controller_ window] frame]; - [controller_ setShowHistoryBox:YES]; - NSRect newFrame = [[controller_ window] frame]; - EXPECT_GE(newFrame.size.height, frame.size.height); - EXPECT_LE(newFrame.origin.y, frame.origin.y); -} - - -TEST_F(PageInfoWindowControllerTest, TestShrink) { - [controller_ setShowHistoryBox:YES]; - NSRect frame = [[controller_ window] frame]; - [controller_ setShowHistoryBox:NO]; - NSRect newFrame = [[controller_ window] frame]; - EXPECT_LE(newFrame.size.height, frame.size.height); - EXPECT_GE(newFrame.origin.y, frame.origin.y); -} diff --git a/chrome/browser/cocoa/page_info_window_mac.h b/chrome/browser/cocoa/page_info_window_mac.h index da7b2b6..c1beccf 100644 --- a/chrome/browser/cocoa/page_info_window_mac.h +++ b/chrome/browser/cocoa/page_info_window_mac.h @@ -1,16 +1,30 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. #ifndef CHROME_BROWSER_COCOA_PAGE_INFO_WINDOW_MAC_H_ #define CHROME_BROWSER_COCOA_PAGE_INFO_WINDOW_MAC_H_ +#import <Cocoa/Cocoa.h> + +#include "base/scoped_nsobject.h" +#include "base/scoped_ptr.h" #include "chrome/browser/page_info_model.h" #include "chrome/browser/page_info_window.h" class Profile; @class PageInfoWindowController; +namespace { + +class PageInfoWindowMacTest; + +}; + +// This bridge is responsible for getting information from the cross-platform +// model and dynamically creating the contents of the window. The controller is +// responsible for managing the window's memory and user events (pressing on +// the Show Certificate button). class PageInfoWindowMac : public PageInfoModel::PageInfoModelObserver { public: virtual ~PageInfoWindowMac(); @@ -30,19 +44,37 @@ class PageInfoWindowMac : public PageInfoModel::PageInfoModelObserver { virtual void ModelChanged(); private: + friend class ::PageInfoWindowMacTest; + + // Private constructor, called by ShowPageInfo(). PageInfoWindowMac(PageInfoWindowController* controller, Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, bool show_history); + // Testing constructor. DO NOT USE. + PageInfoWindowMac(PageInfoWindowController* controller, + PageInfoModel* model); + + // Shared constructor initialization. + void Init(); + + // Dynamically creates the window's content section. void LayoutSections(); + // Shows the actual window. void Show(); + // The window controller that manages the memory and window reference. PageInfoWindowController* controller_; // WEAK, owns us. - PageInfoModel model_; + // The platform-independent model for the info window. + scoped_ptr<PageInfoModel> model_; + + // Reference to the good and bad images that are placed within the UI. + scoped_nsobject<NSImage> good_image_; + scoped_nsobject<NSImage> bad_image_; // The certificate ID for the page, 0 if the page is not over HTTPS. int cert_id_; diff --git a/chrome/browser/cocoa/page_info_window_mac.mm b/chrome/browser/cocoa/page_info_window_mac.mm index 0ea0eae..b56192f 100644 --- a/chrome/browser/cocoa/page_info_window_mac.mm +++ b/chrome/browser/cocoa/page_info_window_mac.mm @@ -1,23 +1,52 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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/page_info_window_mac.h" +#include <algorithm> #include <Security/Security.h> #include <SecurityInterface/SFCertificatePanel.h> #include "app/l10n_util.h" #include "base/scoped_cftyperef.h" #include "base/i18n/time_formatting.h" +#include "app/resource_bundle.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" #import "chrome/browser/cocoa/page_info_window_controller.h" #include "chrome/browser/cert_store.h" #include "chrome/browser/profile.h" #include "grit/generated_resources.h" +#include "grit/theme_resources.h" #include "net/base/cert_status_flags.h" #include "net/base/x509_certificate.h" +#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" + +namespace { + +// Spacing in between section boxes. +const NSInteger kVerticalSpacing = 10; + +// Padding from the edge of the boxes and the window frame. +const NSInteger kFramePadding = 20; + +// Spacing between the frame of the box and the left edge of the image and the +// right edge of the text. +const NSInteger kBoxHorizontalSpacing = 13; + +// Spacing between the top/bottom of the box frame and the top of the image and +// text components. +const NSInteger kBoxTopSpacing = 33; +const NSInteger kBoxBottomSpacing = 7; + +// Spacing between the image and the text. +const NSInteger kImageSpacing = 10; + +// Square size of the image. +const CGFloat kImageSize = 30; + +} // namespace void PageInfoWindowMac::ShowPageInfo(Profile* profile, const GURL& url, @@ -43,8 +72,27 @@ PageInfoWindowMac::PageInfoWindowMac(PageInfoWindowController* controller, const NavigationEntry::SSLStatus& ssl, bool show_history) : controller_(controller), - model_(profile, url, ssl, show_history, this), + model_(new PageInfoModel(profile, url, ssl, show_history, this)), cert_id_(ssl.cert_id()) { + Init(); +} + +PageInfoWindowMac::PageInfoWindowMac(PageInfoWindowController* controller, + PageInfoModel* model) + : controller_(controller), + model_(model) { + Init(); +} + +void PageInfoWindowMac::Init() { + // Load the image refs. + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + good_image_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_GOOD) retain]); + DCHECK_GE(kImageSize, [good_image_ size].width); + DCHECK_GE(kImageSize, [good_image_ size].height); + bad_image_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_BAD) retain]); + DCHECK_GE(kImageSize, [bad_image_ size].width); + DCHECK_GE(kImageSize, [bad_image_ size].height); } PageInfoWindowMac::~PageInfoWindowMac() { @@ -93,42 +141,113 @@ void PageInfoWindowMac::ShowCertDialog(int) { // The SFCertificatePanel releases itself when the sheet is dismissed. } +// This will create the subviews for the page info window. The general layout +// is 2 or 3 boxed and titled sections, each of which has a status image to +// provide visual feedback and a description that explains it. The description +// text is usually only 1 or 2 lines, but can be much longer. At the bottom of +// the window is a button to view the SSL certificate, which is disabled if +// not using HTTPS. void PageInfoWindowMac::LayoutSections() { - // Identity section - PageInfoModel::SectionInfo identity_section = - model_.GetSectionInfo(PageInfoModel::IDENTITY); - if (identity_section.state) - [controller_ setIdentityImg:[controller_ goodImg]]; - else - [controller_ setIdentityImg:[controller_ badImg]]; - [controller_ setIdentityMsg:base::SysUTF16ToNSString( - identity_section.description)]; - - // Connection section. - PageInfoModel::SectionInfo connection_section = - model_.GetSectionInfo(PageInfoModel::CONNECTION); - if (connection_section.state) - [controller_ setConnectionImg:[controller_ goodImg]]; - else - [controller_ setConnectionImg:[controller_ badImg]]; - [controller_ setConnectionMsg: - base::SysUTF16ToNSString(connection_section.description)]; - - if (model_.GetSectionCount() > 2) { - // We have the history info. - PageInfoModel::SectionInfo history_section = - model_.GetSectionInfo(PageInfoModel::HISTORY); - if (history_section.state) - [controller_ setHistoryImg:[controller_ goodImg]]; - else - [controller_ setHistoryImg:[controller_ badImg]]; - - [controller_ setHistoryMsg: - base::SysUTF16ToNSString(history_section.description)]; + NSRect window_frame = [[controller_ window] frame]; + CGFloat window_width = NSWidth(window_frame); + // |offset| is the Y position that should be drawn at next. + CGFloat offset = kFramePadding; + + // Keep the new subviews in an array that gets replaced at the end. + NSMutableArray* subviews = [NSMutableArray array]; + + // Create the certificate button. The frame will be fixed up by GTM, so use + // arbitrary values. + NSRect button_rect = NSMakeRect(kFramePadding, offset, 100, 20); + scoped_nsobject<NSButton> cert_button( + [[NSButton alloc] initWithFrame:button_rect]); + [cert_button setTitle: + l10n_util::GetNSStringWithFixup(IDS_PAGEINFO_CERT_INFO_BUTTON)]; + [cert_button setButtonType:NSMomentaryPushInButton]; + [cert_button setBezelStyle:NSRoundedBezelStyle]; + // The default button will use control size font, not the system/button font. + [cert_button setFont:[NSFont systemFontOfSize:0]]; + [cert_button setTarget:controller_]; + [cert_button setAction:@selector(showCertWindow:)]; + [subviews addObject:cert_button.get()]; + [GTMUILocalizerAndLayoutTweaker sizeToFitView:cert_button]; + offset += NSHeight(button_rect) + kFramePadding; + + // Small font for the description labels. + NSFont* font = [NSFont labelFontOfSize:11]; + + // Calculate some common, constant values. + const CGFloat box_width = window_width - (2 * kFramePadding); + const CGFloat text_width = + box_width - (kBoxHorizontalSpacing + kImageSize + + kImageSpacing + kBoxHorizontalSpacing * 2); + const CGFloat text_x = kBoxHorizontalSpacing + kImageSize + kImageSpacing; + + // Build the window from bottom-up because Cocoa's coordinate origin is the + // lower left. + for (int i = model_->GetSectionCount() - 1; i >= 0; --i) { + PageInfoModel::SectionInfo info = model_->GetSectionInfo(i); + + // Create the text field first, because that informs how large to make the + // box it goes in. + NSRect text_field_rect = + NSMakeRect(text_x, kBoxBottomSpacing, text_width, kImageSpacing); + scoped_nsobject<NSTextField> text_field( + [[NSTextField alloc] initWithFrame:text_field_rect]); + [text_field setEditable:NO]; + [text_field setDrawsBackground:NO]; + [text_field setBezeled:NO]; + [text_field setStringValue:base::SysUTF16ToNSString(info.description)]; + [text_field setFont:font]; + + // If the text is oversized, resize the text field. + text_field_rect.size.height += + [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField: + text_field]; + + // Make the box, sized to fit the text. It should be at least large enough + // to contain the height of the image, which is larger than a single line + // of text. + CGFloat box_height = kBoxTopSpacing + + std::max(NSHeight(text_field_rect), kImageSize) + kBoxBottomSpacing; + NSRect box_rect = NSMakeRect(kFramePadding, offset, box_width, box_height); + scoped_nsobject<NSBox> box([[NSBox alloc] initWithFrame:box_rect]); + [box setTitlePosition:NSAtTop]; + [box setTitle:base::SysUTF16ToNSString(info.title)]; + offset += box_height + kVerticalSpacing; + + // Re-position the text field's origin now that the box height is known. + text_field_rect.origin.y = box_height - + (NSHeight(text_field_rect) + kBoxTopSpacing); + [text_field setFrame:text_field_rect]; + + // Insert the image subview. + NSRect image_view_rect = + NSMakeRect(kBoxHorizontalSpacing, + box_height - (kImageSize + kBoxTopSpacing), + kImageSize, kImageSize); + scoped_nsobject<NSImageView> image_view( + [[NSImageView alloc] initWithFrame:image_view_rect]); + [image_view setImageFrameStyle:NSImageFrameNone]; + [image_view setImage:(info.state) ? good_image_.get() : bad_image_.get()]; + + // Add the box to the list of new subviews. + [box addSubview:image_view.get()]; + [box addSubview:text_field.get()]; + [subviews addObject:box.get()]; } + // Replace the window's content. + [[[controller_ window] contentView] setSubviews:subviews]; + + // Just setting |size| will cause the window to grow upwards. Shift the + // origin up by grow amount, which causes the window to grow downwards. + offset += kFramePadding; + window_frame.origin.y -= offset - window_frame.size.height; + window_frame.size.height = offset; + // By default, assume that we don't have certificate information to show. - [controller_ setEnableCertButton:NO]; + [cert_button setEnabled:NO]; if (cert_id_) { scoped_refptr<net::X509Certificate> cert; CertStore::GetSharedInstance()->RetrieveCert(cert_id_, &cert); @@ -136,14 +255,17 @@ void PageInfoWindowMac::LayoutSections() { // Don't bother showing certificates if there isn't one. Gears runs with no // os root certificate. if (cert.get() && cert->os_cert_handle()) { - [controller_ setEnableCertButton:YES]; + [cert_button setEnabled:YES]; } } + + // Resize the window. Only animate if the window is visible, otherwise it + // could be "growing" while it's opening, looking awkward. + [[controller_ window] setFrame:window_frame + display:YES + animate:[[controller_ window] isVisible]]; } void PageInfoWindowMac::ModelChanged() { - // We have history information, so show the box and extend the window frame. - [controller_ setShowHistoryBox:YES]; LayoutSections(); } - diff --git a/chrome/browser/cocoa/page_info_window_mac_unittest.mm b/chrome/browser/cocoa/page_info_window_mac_unittest.mm new file mode 100644 index 0000000..30becc4 --- /dev/null +++ b/chrome/browser/cocoa/page_info_window_mac_unittest.mm @@ -0,0 +1,195 @@ +// 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 "app/l10n_util.h" +#include "base/scoped_nsobject.h" +#include "base/string_util.h" +#include "base/sys_string_conversions.h" +#import "chrome/browser/cocoa/page_info_window_mac.h" +#import "chrome/browser/cocoa/page_info_window_controller.h" +#include "chrome/browser/cocoa/browser_test_helper.h" +#import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "chrome/browser/page_info_model.h" +#include "grit/generated_resources.h" + +namespace { + +class FakeModel : public PageInfoModel { + public: + void AddSection(bool state, + const string16& title, + const string16& description) { + sections_.push_back(SectionInfo( + state, + title, + string16(), + description)); + } +}; + +class PageInfoWindowMacTest : public CocoaTest { + public: + virtual void SetUp() { + CocoaTest::SetUp(); + + // The controller cleans up after itself when the window closes. + controller_ = [[PageInfoWindowController alloc] init]; + window_ = [controller_ window]; + + // The bridge will own the model. + model_ = new FakeModel(); + + // The controller will take ownership of the bridge. + bridge_ = new PageInfoWindowMac(controller_, model_); + [controller_ setPageInfo:bridge_]; + EXPECT_TRUE([controller_ window]); + } + + virtual void TearDown() { + [controller_ close]; + CocoaTest::TearDown(); + } + + // Checks the controller's window for the requisite subviews in the given + // numbers. + void CheckWindow(int button_count, int box_count) { + for (NSView* view in [[window_ contentView] subviews]) { + if ([view isKindOfClass:[NSButton class]]) { + --button_count; + CheckButton(static_cast<NSButton*>(view)); + } else if ([view isKindOfClass:[NSBox class]]) { + --box_count; + CheckBox(static_cast<NSBox*>(view)); + } else { + EXPECT_TRUE(false) << "Unknown subview"; + } + } + EXPECT_EQ(0, button_count); + EXPECT_EQ(0, box_count); + EXPECT_EQ([window_ delegate], controller_); + } + + // Checks that a button is hooked up correctly. + void CheckButton(NSButton* button) { + EXPECT_EQ(@selector(showCertWindow:), [button action]); + EXPECT_EQ(controller_, [button target]); + EXPECT_TRUE([button stringValue]); + } + + // Makes sure the box has a valid image and a string. + void CheckBox(NSBox* box) { + EXPECT_TRUE([box title]); + NSArray* subviews = [[box contentView] subviews]; + EXPECT_EQ(2U, [subviews count]); + for (NSView* view in subviews) { + if ([view isKindOfClass:[NSImageView class]]) { + NSImageView* image_view = static_cast<NSImageView*>(view); + EXPECT_TRUE([image_view image] == bridge_->good_image_.get() || + [image_view image] == bridge_->bad_image_.get()); + } else if ([view isKindOfClass:[NSTextField class]]) { + NSTextField* text_field = static_cast<NSTextField*>(view); + EXPECT_LT(0U, [[text_field stringValue] length]); + } else { + EXPECT_TRUE(false) << "Unknown box subview"; + } + } + } + + BrowserTestHelper helper_; + + PageInfoWindowController* controller_; // Weak, owns self. + PageInfoWindowMac* bridge_; // Weak, owned by controller. + FakeModel* model_; // Weak, owned by bridge. + + NSWindow* window_; // Weak, owned by controller. +}; + + +TEST_F(PageInfoWindowMacTest, NoHistoryNoSecurity) { + model_->AddSection(false, + l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), + l10n_util::GetStringFUTF16( + IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY, + ASCIIToUTF16("google.com"))); + model_->AddSection(false, + l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE), + l10n_util::GetStringFUTF16( + IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, + ASCIIToUTF16("google.com"))); + + bridge_->ModelChanged(); + + CheckWindow(1, 2); +} + + +TEST_F(PageInfoWindowMacTest, HistoryNoSecurity) { + model_->AddSection(false, + l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), + l10n_util::GetStringFUTF16( + IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY, + ASCIIToUTF16("google.com"))); + model_->AddSection(false, + l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE), + l10n_util::GetStringFUTF16( + IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, + ASCIIToUTF16("google.com"))); + + // In practice, the history information comes later because it's queried + // asynchronously, so replicate the double-build here. + bridge_->ModelChanged(); + + model_->AddSection(false, + l10n_util::GetStringUTF16( + IDS_PAGE_INFO_SECURITY_TAB_PERSONAL_HISTORY_TITLE), + l10n_util::GetStringUTF16( + IDS_PAGE_INFO_SECURITY_TAB_FIRST_VISITED_TODAY)); + + bridge_->ModelChanged(); + + CheckWindow(1, 3); +} + + +TEST_F(PageInfoWindowMacTest, NoHistoryMixedSecurity) { + model_->AddSection(true, + l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_IDENTITY_TITLE), + l10n_util::GetStringFUTF16( + IDS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, + ASCIIToUTF16("Goat Security Systems"))); + + // This string is super long and the text should overflow the default clip + // region (kImageSize). + string16 title = + l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_CONNECTION_TITLE); + model_->AddSection(true, + title, + l10n_util::GetStringFUTF16( + IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, + l10n_util::GetStringFUTF16( + IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, + ASCIIToUTF16("chrome.google.com"), + IntToString16(1024)), + l10n_util::GetStringUTF16( + IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_MIXED_CONTENT_WARNING))); + + bridge_->ModelChanged(); + + NSArray* subviews = [[window_ contentView] subviews]; + CheckWindow(1, 2); + + // Look for the over-sized box. + NSString* targetTitle = base::SysUTF16ToNSString(title); + for (NSView* subview in subviews) { + if ([subview isKindOfClass:[NSBox class]]) { + NSBox* box = static_cast<NSBox*>(subview); + if ([[box title] isEqualToString:targetTitle]) { + // Typical box frame is ~55px, make sure this is extra large. + EXPECT_LT(75, NSHeight([box frame])); + } + } + } +} + +} // namespace diff --git a/chrome/browser/page_info_model.h b/chrome/browser/page_info_model.h index 526372e..a3bee79 100644 --- a/chrome/browser/page_info_model.h +++ b/chrome/browser/page_info_model.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. @@ -25,16 +25,6 @@ class PageInfoModel { virtual void ModelChanged() = 0; }; - // Because the UI on the Mac is statically laid-out, this enum provides the - // section type for the associated index. It is only used on Mac. - // Ideally the view wouldn't have to know anything regarding the semantics of - // the model and would only use GetSectionCount()/GetSectionInfo(). - enum SectionType { - IDENTITY = 0, - CONNECTION, - HISTORY - }; - struct SectionInfo { SectionInfo(bool state, const string16& title, @@ -76,7 +66,10 @@ class PageInfoModel { static void RegisterPrefs(PrefService* prefs); - private: + protected: + // Testing constructor. DO NOT USE. + PageInfoModel() {} + PageInfoModelObserver* observer_; std::vector<SectionInfo> sections_; @@ -84,6 +77,7 @@ class PageInfoModel { // Used to request number of visits. CancelableRequestConsumer request_consumer_; + private: DISALLOW_COPY_AND_ASSIGN(PageInfoModel); }; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 95ce051..dc582e3 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2764,7 +2764,6 @@ 'app/nibs/ImportProgressDialog.xib', 'app/nibs/KeywordEditor.xib', 'app/nibs/MainMenu.xib', - 'app/nibs/PageInfo.xib', 'app/nibs/Preferences.xib', 'app/nibs/ReportBug.xib', 'app/nibs/SadTab.xib', diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index 4255fec5..a23125a 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -232,7 +232,6 @@ 'app/nibs/ImportProgressDialog.xib', 'app/nibs/KeywordEditor.xib', 'app/nibs/MainMenu.xib', - 'app/nibs/PageInfo.xib', 'app/nibs/Preferences.xib', 'app/nibs/ReportBug.xib', 'app/nibs/SaveAccessoryView.xib', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index de78cb7..bf01a6bf 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -724,7 +724,7 @@ 'browser/cocoa/nsimage_cache_unittest.mm', 'browser/cocoa/nsmenuitem_additions_unittest.mm', 'browser/cocoa/objc_method_swizzle_unittest.mm', - 'browser/cocoa/page_info_window_controller_unittest.mm', + 'browser/cocoa/page_info_window_mac_unittest.mm', 'browser/cocoa/preferences_window_controller_unittest.mm', 'browser/cocoa/rwhvm_editcommand_helper_unittest.mm', 'browser/cocoa/sad_tab_controller_unittest.mm', |