summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-15 17:11:30 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-15 17:11:30 +0000
commitb694453d2397cb3886e4fb59bfdefb55c9f9081e (patch)
tree2c3c730e61bb6731bf9c4eb8a8adb17e4efc4887
parent3cd1f6b0d74cb2f546b430f49af1a91ef951ce95 (diff)
downloadchromium_src-b694453d2397cb3886e4fb59bfdefb55c9f9081e.zip
chromium_src-b694453d2397cb3886e4fb59bfdefb55c9f9081e.tar.gz
chromium_src-b694453d2397cb3886e4fb59bfdefb55c9f9081e.tar.bz2
Make a shared app menu model and update win and mac to use it. Remove the NSMenu from Toolbar.xib.
BUG=22646 TEST=the app menu works as it used to. Review URL: http://codereview.chromium.org/482006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34561 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/nibs/Toolbar.xib626
-rw-r--r--chrome/browser/app_menu_model.cc123
-rw-r--r--chrome/browser/app_menu_model.h44
-rw-r--r--chrome/browser/app_menu_model_unittest.cc52
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc1
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h2
-rw-r--r--chrome/browser/cocoa/toolbar_controller.h10
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm14
-rw-r--r--chrome/browser/defaults.cc7
-rw-r--r--chrome/browser/defaults.h7
-rw-r--r--chrome/browser/views/toolbar_view.cc115
-rw-r--r--chrome/browser/views/toolbar_view.h18
-rwxr-xr-xchrome/chrome_browser.gypi2
-rwxr-xr-xchrome/chrome_tests.gypi1
14 files changed, 261 insertions, 761 deletions
diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib
index b4aed92..f2e6c52 100644
--- a/chrome/app/nibs/Toolbar.xib
+++ b/chrome/app/nibs/Toolbar.xib
@@ -311,194 +311,6 @@
<reference key="NSWindow"/>
<string key="NSClassName">ToolbarView</string>
</object>
- <object class="NSMenu" id="558188039">
- <string key="NSTitle">Wrench Menu</string>
- <object class="NSMutableArray" key="NSMenuItems">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMenuItem" id="306298564">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <object class="NSCustomResource" key="NSOnImage" id="377723476">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuCheckmark</string>
- </object>
- <object class="NSCustomResource" key="NSMixedImage" id="651760058">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuMixedState</string>
- </object>
- </object>
- <object class="NSMenuItem" id="824187729">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_NEW_TAB</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">34014</int>
- </object>
- <object class="NSMenuItem" id="300890436">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_NEW_WINDOW</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">34000</int>
- </object>
- <object class="NSMenuItem" id="498957868">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_NEW_INCOGNITO_WINDOW</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">34001</int>
- </object>
- <object class="NSMenuItem" id="805002579">
- <reference key="NSMenu" ref="558188039"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- </object>
- <object class="NSMenuItem" id="755764032">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_BOOMARK_BAR_ALWAYS_SHOW</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">40009</int>
- </object>
- <object class="NSMenuItem" id="1051303932">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_FULLSCREEN</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">34030</int>
- </object>
- <object class="NSMenuItem" id="800541023">
- <reference key="NSMenu" ref="558188039"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- </object>
- <object class="NSMenuItem" id="118179064">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_CLEAR_BROWSING_DATA_MAC</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">40013</int>
- </object>
- <object class="NSMenuItem" id="791058457">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_IMPORT_SETTINGS_TITLE</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">40014</int>
- </object>
- <object class="NSMenuItem" id="1010888289">
- <reference key="NSMenu" ref="558188039"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- </object>
- <object class="NSMenuItem" id="6307962">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_SHOW_HISTORY</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">40010</int>
- </object>
- <object class="NSMenuItem" id="241294165">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_BOOKMARK_MANAGER</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- </object>
- <object class="NSMenuItem" id="548636593">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_SHOW_DOWNLOADS</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">40012</int>
- </object>
- <object class="NSMenuItem" id="211303389">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_SHOW_EXTENSIONS</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">40023</int>
- </object>
- <object class="NSMenuItem" id="163898806">
- <reference key="NSMenu" ref="558188039"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- </object>
- <object class="NSMenuItem" id="1012539825">
- <reference key="NSMenu" ref="558188039"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsHidden">YES</bool>
- <string key="NSTitle">^IDS_SYNC_START_SYNC_BUTTON_LABEL</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- <int key="NSTag">41108</int>
- </object>
- <object class="NSMenuItem" id="922630377">
- <reference key="NSMenu" ref="558188039"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <bool key="NSIsHidden">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- </object>
- <object class="NSMenuItem" id="510846575">
- <reference key="NSMenu" ref="558188039"/>
- <string key="NSTitle">^IDS_PREFERENCES_MAC</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="377723476"/>
- <reference key="NSMixedImage" ref="651760058"/>
- </object>
- </object>
- </object>
<object class="NSCustomObject" id="1044322163">
<string key="NSClassName">ChromeUILocalizer</string>
</object>
@@ -625,78 +437,6 @@
<object class="IBActionConnection" key="connection">
<string key="label">commandDispatch:</string>
<reference key="source" ref="1003"/>
- <reference key="destination" ref="824187729"/>
- </object>
- <int key="connectionID">108</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="300890436"/>
- </object>
- <int key="connectionID">109</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="498957868"/>
- </object>
- <int key="connectionID">110</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="755764032"/>
- </object>
- <int key="connectionID">111</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="1051303932"/>
- </object>
- <int key="connectionID">112</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="6307962"/>
- </object>
- <int key="connectionID">113</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="241294165"/>
- </object>
- <int key="connectionID">114</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="548636593"/>
- </object>
- <int key="connectionID">115</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">showPreferences:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="510846575"/>
- </object>
- <int key="connectionID">118</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
<reference key="destination" ref="559273956"/>
</object>
<int key="connectionID">121</int>
@@ -710,22 +450,6 @@
<int key="connectionID">123</int>
</object>
<object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">otherObjectToLocalize_</string>
- <reference key="source" ref="1044322163"/>
- <reference key="destination" ref="558188039"/>
- </object>
- <int key="connectionID">124</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">attachedMenu_</string>
- <reference key="source" ref="602421009"/>
- <reference key="destination" ref="558188039"/>
- </object>
- <int key="connectionID">136</int>
- </object>
- <object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">commandDispatchUsingKeyModifiers:</string>
<reference key="source" ref="1003"/>
@@ -742,14 +466,6 @@
<int key="connectionID">139</int>
</object>
<object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="1012539825"/>
- </object>
- <int key="connectionID">143</int>
- </object>
- <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">browserActionContainerView_</string>
<reference key="source" ref="1001"/>
@@ -757,30 +473,6 @@
</object>
<int key="connectionID">145</int>
</object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="211303389"/>
- </object>
- <int key="connectionID">147</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="791058457"/>
- </object>
- <int key="connectionID">152</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">commandDispatch:</string>
- <reference key="source" ref="1003"/>
- <reference key="destination" ref="118179064"/>
- </object>
- <int key="connectionID">153</int>
- </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -956,143 +648,21 @@
<reference key="parent" ref="602421009"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">48</int>
- <reference key="object" ref="558188039"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="824187729"/>
- <reference ref="300890436"/>
- <reference ref="498957868"/>
- <reference ref="805002579"/>
- <reference ref="755764032"/>
- <reference ref="1051303932"/>
- <reference ref="800541023"/>
- <reference ref="6307962"/>
- <reference ref="548636593"/>
- <reference ref="241294165"/>
- <reference ref="922630377"/>
- <reference ref="510846575"/>
- <reference ref="306298564"/>
- <reference ref="163898806"/>
- <reference ref="1012539825"/>
- <reference ref="211303389"/>
- <reference ref="118179064"/>
- <reference ref="791058457"/>
- <reference ref="1010888289"/>
- </object>
- <reference key="parent" ref="835640952"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">49</int>
- <reference key="object" ref="824187729"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">50</int>
- <reference key="object" ref="300890436"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">51</int>
- <reference key="object" ref="498957868"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">96</int>
- <reference key="object" ref="805002579"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">97</int>
- <reference key="object" ref="755764032"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">98</int>
- <reference key="object" ref="1051303932"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">99</int>
- <reference key="object" ref="800541023"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100</int>
- <reference key="object" ref="6307962"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">101</int>
- <reference key="object" ref="548636593"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">102</int>
- <reference key="object" ref="241294165"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">106</int>
- <reference key="object" ref="922630377"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">107</int>
- <reference key="object" ref="510846575"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">122</int>
<reference key="object" ref="1044322163"/>
<reference key="parent" ref="835640952"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">129</int>
- <reference key="object" ref="306298564"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">130</int>
<reference key="object" ref="306232897"/>
<reference key="parent" ref="835640952"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">141</int>
- <reference key="object" ref="163898806"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">142</int>
- <reference key="object" ref="1012539825"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">144</int>
<reference key="object" ref="421615633"/>
<reference key="parent" ref="928520650"/>
<string key="objectName">Browser Actions Container</string>
</object>
- <object class="IBObjectRecord">
- <int key="objectID">146</int>
- <reference key="object" ref="211303389"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">148</int>
- <reference key="object" ref="118179064"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">149</int>
- <reference key="object" ref="791058457"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">150</int>
- <reference key="object" ref="1010888289"/>
- <reference key="parent" ref="558188039"/>
- </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1107,29 +677,17 @@
<string>1.IBViewEditorWindowController.showingLayoutRectangles</string>
<string>10.CustomClassName</string>
<string>10.IBPluginDependency</string>
- <string>100.IBPluginDependency</string>
- <string>101.IBPluginDependency</string>
- <string>102.IBPluginDependency</string>
- <string>106.IBPluginDependency</string>
- <string>107.IBPluginDependency</string>
<string>12.CustomClassName</string>
<string>12.IBPluginDependency</string>
<string>122.IBPluginDependency</string>
- <string>129.IBPluginDependency</string>
<string>13.CustomClassName</string>
<string>13.IBPluginDependency</string>
<string>130.IBPluginDependency</string>
<string>14.CustomClassName</string>
<string>14.IBPluginDependency</string>
- <string>141.IBPluginDependency</string>
- <string>142.IBPluginDependency</string>
<string>144.IBPluginDependency</string>
- <string>146.IBPluginDependency</string>
- <string>148.IBShouldRemoveOnLegacySave</string>
- <string>149.IBShouldRemoveOnLegacySave</string>
<string>15.CustomClassName</string>
<string>15.IBPluginDependency</string>
- <string>150.IBShouldRemoveOnLegacySave</string>
<string>2.CustomClassName</string>
<string>2.IBAttributePlaceholdersKey</string>
<string>2.IBPluginDependency</string>
@@ -1151,12 +709,7 @@
<string>39.IBPluginDependency</string>
<string>4.CustomClassName</string>
<string>4.IBPluginDependency</string>
- <string>48.IBEditorWindowLastContentRect</string>
- <string>48.IBPluginDependency</string>
- <string>49.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
- <string>50.IBPluginDependency</string>
- <string>51.IBPluginDependency</string>
<string>7.CustomClassName</string>
<string>7.IBAttributePlaceholdersKey</string>
<string>7.IBPluginDependency</string>
@@ -1164,10 +717,6 @@
<string>8.IBPluginDependency</string>
<string>9.CustomClassName</string>
<string>9.IBPluginDependency</string>
- <string>96.IBPluginDependency</string>
- <string>97.IBPluginDependency</string>
- <string>98.IBPluginDependency</string>
- <string>99.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1176,32 +725,20 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{272, 820}, {618, 36}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <boolean value="YES" id="5"/>
+ <boolean value="YES"/>
<string>ClickHoldButtonCell</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>ToolbarButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>AutocompleteTextFieldCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ToolbarButtonCell</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>
- <reference ref="5"/>
- <reference ref="5"/>
<string>ClickHoldButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <reference ref="5"/>
<string>DelayedMenuButton</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">ToolTip</string>
@@ -1259,11 +796,6 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>AutocompleteTextField</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{48, 162}, {335, 333}}</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>DelayedMenuButton</string>
<object class="NSMutableDictionary">
@@ -1286,10 +818,6 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>ToolbarButtonCell</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">
@@ -1318,42 +846,6 @@
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
- <string key="className">AppController</string>
- <string key="superclassName">NSObject</string>
- <object class="NSMutableDictionary" key="actions">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>orderFrontStandardAboutPanel:</string>
- <string>showPreferences:</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>id</string>
- <string>id</string>
- </object>
- </object>
- <object class="NSMutableDictionary" key="outlets">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>closeTabMenuItem_</string>
- <string>closeWindowMenuItem_</string>
- <string>helpMenu_</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>NSMenuItem</string>
- <string>NSMenuItem</string>
- <string>NSMenu</string>
- </object>
- </object>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">browser/app_controller_mac.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">AutocompleteTextField</string>
<string key="superclassName">StyledTextField</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -1470,13 +962,6 @@
</object>
</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>
@@ -1491,113 +976,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">NSWindow</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">browser/cocoa/nswindow_local_state.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">PreferencesWindowController</string>
- <string key="superclassName">NSWindowController</string>
- <object class="NSMutableDictionary" key="actions">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>addHomepage:</string>
- <string>browseDownloadLocation:</string>
- <string>clearData:</string>
- <string>doSyncAction:</string>
- <string>importData:</string>
- <string>makeDefaultBrowser:</string>
- <string>manageSearchEngines:</string>
- <string>privacyLearnMore:</string>
- <string>removeSelectedHomepages:</string>
- <string>resetThemeToDefault:</string>
- <string>showPreferences:</string>
- <string>showSavedPasswords:</string>
- <string>themesGallery:</string>
- <string>toolbarButtonSelected:</string>
- <string>useCurrentPagesAsHomepage:</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- <string>id</string>
- </object>
- </object>
- <object class="NSMutableDictionary" key="outlets">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>basicsGroupDefaultBrowser_</string>
- <string>basicsGroupHomePage_</string>
- <string>basicsGroupSearchEngine_</string>
- <string>basicsGroupStartup_</string>
- <string>basicsGroupToolbar_</string>
- <string>basicsView_</string>
- <string>customPagesArrayController_</string>
- <string>downloadLocationButton_</string>
- <string>downloadLocationControl_</string>
- <string>enableLoggingCheckbox_</string>
- <string>personalStuffGroupAutofill_</string>
- <string>personalStuffGroupBrowserData_</string>
- <string>personalStuffGroupPasswords_</string>
- <string>personalStuffGroupSync_</string>
- <string>personalStuffGroupThemes_</string>
- <string>personalStuffView_</string>
- <string>syncButton_</string>
- <string>syncStatus_</string>
- <string>toolbar_</string>
- <string>underTheHoodContentView_</string>
- <string>underTheHoodScroller_</string>
- <string>underTheHoodView_</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSView</string>
- <string>NSArrayController</string>
- <string>NSButton</string>
- <string>NSPathControl</string>
- <string>NSButton</string>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSArray</string>
- <string>NSView</string>
- <string>NSButton</string>
- <string>NSTextField</string>
- <string>NSToolbar</string>
- <string>NSView</string>
- <string>NSScrollView</string>
- <string>NSView</string>
- </object>
- </object>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">browser/cocoa/preferences_window_controller.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">StyledTextField</string>
<string key="superclassName">NSTextField</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -1678,7 +1056,6 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>backButton_</string>
<string>browserActionContainerView_</string>
- <string>encodingMenu_</string>
<string>forwardButton_</string>
<string>goButton_</string>
<string>homeButton_</string>
@@ -1693,7 +1070,6 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>DelayedMenuButton</string>
<string>NSView</string>
- <string>NSMenu</string>
<string>DelayedMenuButton</string>
<string>NSButton</string>
<string>NSButton</string>
diff --git a/chrome/browser/app_menu_model.cc b/chrome/browser/app_menu_model.cc
new file mode 100644
index 0000000..5cd69f3
--- /dev/null
+++ b/chrome/browser/app_menu_model.cc
@@ -0,0 +1,123 @@
+// 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 "chrome/browser/app_menu_model.h"
+
+#include "app/l10n_util.h"
+#include "base/command_line.h"
+#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/defaults.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/sync_ui_util.h"
+#include "chrome/common/chrome_switches.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+
+AppMenuModel::AppMenuModel(menus::SimpleMenuModel::Delegate* delegate,
+ Browser* browser)
+ : menus::SimpleMenuModel(delegate),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ profiles_helper_(new GetProfilesHelper(this))),
+ browser_(browser) {
+ Build();
+}
+
+AppMenuModel::~AppMenuModel() {
+ profiles_helper_->OnDelegateDeleted();
+}
+
+void AppMenuModel::Build() {
+ AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
+ AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
+ AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW);
+ // Enumerate profiles asynchronously and then create the parent menu item.
+ // We will create the child menu items for this once the asynchronous call is
+ // done. See OnGetProfilesDone().
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kEnableUserDataDirProfiles)) {
+ if (!profiles_menu_contents_.get()) {
+ profiles_helper_->GetProfiles(NULL);
+ profiles_menu_contents_.reset(new menus::SimpleMenuModel(delegate()));
+ }
+ AddSubMenuWithStringId(IDS_PROFILE_MENU, profiles_menu_contents_.get());
+ }
+
+ AddSeparator();
+ AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR, IDS_SHOW_BOOKMARK_BAR);
+ AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
+ AddSeparator();
+ AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
+ AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER);
+ AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS);
+
+ // Create the manage extensions menu item.
+ AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS);
+
+ AddSeparator();
+ if (ProfileSyncService::IsSyncEnabled()) {
+ string16 label;
+ string16 link;
+ // TODO(akalin): use sync_ui_util::GetStatus instead.
+ sync_ui_util::MessageType type = sync_ui_util::GetStatusLabels(
+ browser_->profile()->GetOriginalProfile()->GetProfileSyncService(),
+ &label, &link);
+ if (type == sync_ui_util::SYNCED) {
+ label = l10n_util::GetStringUTF16(IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL);
+ } else if (type == sync_ui_util::SYNC_ERROR) {
+ label = l10n_util::GetStringUTF16(
+ IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL);
+ } else {
+ label = l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL);
+ }
+ AddItem(IDC_SYNC_BOOKMARKS, label);
+ AddSeparator();
+ }
+#if defined(OS_MACOSX)
+ AddItemWithStringId(IDC_OPTIONS, IDS_PREFERENCES_MAC);
+#else
+ AddItemWithStringId(IDC_OPTIONS, IDS_OPTIONS);
+#endif
+ if (browser_defaults::kShowAboutMenuItem) {
+ AddItem(IDC_ABOUT,
+ l10n_util::GetStringFUTF16(
+ IDS_ABOUT,
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
+ }
+ AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
+ if (browser_defaults::kShowExitMenuItem) {
+ AddSeparator();
+ AddItemWithStringId(IDC_EXIT, IDS_EXIT);
+ }
+}
+
+void AppMenuModel::OnGetProfilesDone(
+ const std::vector<std::wstring>& profiles) {
+ // Nothing to do if the menu has gone away.
+ if (!profiles_menu_contents_.get())
+ return;
+
+ // Store the latest list of profiles in the browser.
+ browser_->set_user_data_dir_profiles(profiles);
+
+ // Add direct submenu items for profiles.
+ std::vector<std::wstring>::const_iterator iter = profiles.begin();
+ for (int i = IDC_NEW_WINDOW_PROFILE_0;
+ i <= IDC_NEW_WINDOW_PROFILE_LAST && iter != profiles.end();
+ ++i, ++iter)
+ profiles_menu_contents_->AddItem(i, WideToUTF16Hack(*iter));
+
+ // If there are more profiles then show "Other" link.
+ if (iter != profiles.end()) {
+ profiles_menu_contents_->AddSeparator();
+ profiles_menu_contents_->AddItemWithStringId(IDC_SELECT_PROFILE,
+ IDS_SELECT_PROFILE);
+ }
+
+ // Always show a link to select a new profile.
+ profiles_menu_contents_->AddSeparator();
+ profiles_menu_contents_->AddItemWithStringId(
+ IDC_NEW_PROFILE,
+ IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY);
+}
diff --git a/chrome/browser/app_menu_model.h b/chrome/browser/app_menu_model.h
new file mode 100644
index 0000000..086d613
--- /dev/null
+++ b/chrome/browser/app_menu_model.h
@@ -0,0 +1,44 @@
+// 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.
+
+#ifndef CHROME_BROWSER_APP_MENU_MODEL_H_
+#define CHROME_BROWSER_APP_MENU_MODEL_H_
+
+#include "app/menus/simple_menu_model.h"
+#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
+#include "chrome/browser/user_data_manager.h"
+
+class Browser;
+
+// A menu model that builds the contents of the app menu. This menu has only
+// one level (no submenus).
+class AppMenuModel : public menus::SimpleMenuModel,
+ public GetProfilesHelper::Delegate {
+ public:
+ explicit AppMenuModel(menus::SimpleMenuModel::Delegate* delegate,
+ Browser* browser);
+ virtual ~AppMenuModel();
+
+ // Overridden from GetProfilesHelper::Delegate
+ virtual void OnGetProfilesDone(
+ const std::vector<std::wstring>& profiles);
+
+ private:
+ void Build();
+
+ // The top-level model.
+ scoped_ptr<menus::SimpleMenuModel> model_;
+ // Contents of the profiles menu to populate with profile names.
+ scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_;
+
+ // Helper class to enumerate profiles information on the file thread.
+ scoped_refptr<GetProfilesHelper> profiles_helper_;
+
+ Browser* browser_; // weak
+
+ DISALLOW_COPY_AND_ASSIGN(AppMenuModel);
+};
+
+#endif // CHROME_BROWSER_APP_MENU_MODEL_H_
diff --git a/chrome/browser/app_menu_model_unittest.cc b/chrome/browser/app_menu_model_unittest.cc
new file mode 100644
index 0000000..b354292
--- /dev/null
+++ b/chrome/browser/app_menu_model_unittest.cc
@@ -0,0 +1,52 @@
+// 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 "chrome/browser/app_menu_model.h"
+
+#include "base/logging.h"
+#include "chrome/test/browser_with_test_window_test.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// A menu delegate that counts the number of times certain things are called
+// to make sure things are hooked up properly.
+class Delegate : public menus::SimpleMenuModel::Delegate {
+ public:
+ Delegate() : execute_count_(0), enable_count_(0) { }
+
+ virtual bool IsCommandIdChecked(int command_id) const { return false; }
+ virtual bool IsCommandIdEnabled(int command_id) const {
+ ++enable_count_;
+ return true;
+ }
+ virtual bool GetAcceleratorForCommandId(
+ int command_id,
+ menus::Accelerator* accelerator) { return false; }
+ virtual void ExecuteCommand(int command_id) { ++execute_count_; }
+
+ int execute_count_;
+ mutable int enable_count_;
+};
+
+class AppMenuModelTest : public BrowserWithTestWindowTest {
+};
+
+TEST_F(AppMenuModelTest, Basics) {
+ Delegate delegate;
+ AppMenuModel model(&delegate, browser());
+
+ // Verify it has items. The number varies by platform, so we don't check
+ // the exact number.
+ EXPECT_GT(model.GetItemCount(), 5);
+
+ // Execute a couple of the items and make sure it gets back to our delegate.
+ model.ActivatedAt(0);
+ EXPECT_TRUE(model.IsEnabledAt(0));
+ model.ActivatedAt(3);
+ EXPECT_TRUE(model.IsEnabledAt(4));
+ EXPECT_EQ(delegate.execute_count_, 2);
+ EXPECT_EQ(delegate.enable_count_, 2);
+
+ delegate.execute_count_ = 0;
+ delegate.enable_count_ = 0;
+}
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 75c9608..c00d5f3 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -43,7 +43,6 @@
#include "grit/generated_resources.h"
#include "net/base/escape.h"
#include "skia/ext/skia_utils_win.h"
-#include "views/controls/menu/menu_2.h"
#include "views/drag_utils.h"
#include "views/focus/focus_util_win.h"
#include "views/widget/widget.h"
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index 8da5ad1..393ef0a 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -22,6 +22,7 @@
#include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
#include "chrome/common/page_transition_types.h"
#include "webkit/glue/window_open_disposition.h"
+#include "views/controls/menu/menu_2.h"
class AutocompletePopupModel;
class CommandUpdater;
@@ -29,7 +30,6 @@ class Profile;
class TabContents;
namespace views {
class View;
-class Menu2;
}
class AutocompleteEditController;
diff --git a/chrome/browser/cocoa/toolbar_controller.h b/chrome/browser/cocoa/toolbar_controller.h
index 676b0a8..0b96569 100644
--- a/chrome/browser/cocoa/toolbar_controller.h
+++ b/chrome/browser/cocoa/toolbar_controller.h
@@ -14,6 +14,7 @@
#import "chrome/browser/cocoa/view_resizer.h"
#include "chrome/common/pref_member.h"
+class AppMenuModel;
@class AutocompleteTextField;
@class AutocompleteTextFieldEditor;
@class BackForwardMenuController;
@@ -56,11 +57,14 @@ class ToolbarModel;
scoped_nsobject<BrowserActionsController> browserActionsController_;
// Lazily-instantiated model, controller, and delegate for the menu on the
- // page button. If it's visible, these will be non-null, but they are not
- // reaped when the button is hidden once it is initially shown.
+ // page and wrench buttons. The wrench menu is also called the "app menu". If
+ // it's visible, these will be non-null, but they are not reaped when the
+ // button is hidden once it is initially shown.
scoped_ptr<PageMenuModel> pageMenuModel_;
scoped_nsobject<MenuController> pageMenuController_;
- scoped_ptr<ToolbarControllerInternal::MenuDelegate> pageMenuDelegate_;
+ scoped_ptr<ToolbarControllerInternal::MenuDelegate> menuDelegate_;
+ scoped_ptr<AppMenuModel> appMenuModel_;
+ scoped_nsobject<MenuController> appMenuController_;
// Used for monitoring the optional toolbar button prefs.
scoped_ptr<ToolbarControllerInternal::PrefObserverBridge> prefObserver_;
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index 937fe43..05a70b7 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -10,6 +10,7 @@
#include "base/sys_string_conversions.h"
#include "base/gfx/rect.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/app_menu_model.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/bubble_positioner.h"
@@ -472,13 +473,18 @@ class PrefObserverBridge : public NotificationObserver {
- (void)installPageWrenchMenus {
if (pageMenuModel_.get())
return;
- pageMenuDelegate_.reset(
- new ToolbarControllerInternal::MenuDelegate(browser_));
- pageMenuModel_.reset(new PageMenuModel(pageMenuDelegate_.get(), browser_));
+ menuDelegate_.reset(new ToolbarControllerInternal::MenuDelegate(browser_));
+ pageMenuModel_.reset(new PageMenuModel(menuDelegate_.get(), browser_));
pageMenuController_.reset(
[[MenuController alloc] initWithModel:pageMenuModel_.get()
- useWithPopUpButtonCell:YES]);
+ useWithPopUpButtonCell:YES]);
[pageButton_ setAttachedMenu:[pageMenuController_ menu]];
+
+ appMenuModel_.reset(new AppMenuModel(menuDelegate_.get(), browser_));
+ appMenuController_.reset(
+ [[MenuController alloc] initWithModel:appMenuModel_.get()
+ useWithPopUpButtonCell:YES]);
+ [wrenchButton_ setAttachedMenu:[appMenuController_ menu]];
}
// Show or hide the page and wrench buttons based on the pref.
diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc
index e0f9142..ed99c9d 100644
--- a/chrome/browser/defaults.cc
+++ b/chrome/browser/defaults.cc
@@ -19,6 +19,7 @@ const bool kCanToggleSystemTitleBar = false;
const bool kRestorePopups = true;
const bool kShowImportOnBookmarkBar = false;
const bool kShowExitMenuItem = false;
+const bool kShowAboutMenuItem = true;
const bool kOSSupportsOtherBrowsers = false;
#elif defined(OS_LINUX)
@@ -48,7 +49,13 @@ const SessionStartupPref::Type kDefaultSessionStartupType =
const int kPinnedTabWidth = 56;
const bool kRestorePopups = false;
const bool kShowImportOnBookmarkBar = true;
+#if defined(OS_MACOSX)
+const bool kShowExitMenuItem = false;
+const bool kShowAboutMenuItem = false;
+#else
const bool kShowExitMenuItem = true;
+const bool kShowAboutMenuItem = true;
+#endif
const bool kOSSupportsOtherBrowsers = true;
#endif
diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h
index 4df86b6..7ab5505 100644
--- a/chrome/browser/defaults.h
+++ b/chrome/browser/defaults.h
@@ -41,12 +41,15 @@ extern const bool kRestorePopups;
extern const bool kBrowserAliveWithNoWindows;
// Should a link be shown on the bookmark bar allowing the user to import
-// bookmarks.
+// bookmarks?
extern const bool kShowImportOnBookmarkBar;
-// Should the exit menu be shown?
+// Should the exit menu item be shown in the toolbar menu?
extern const bool kShowExitMenuItem;
+// Should the about menu item be shown in the toolbar app menu?
+extern const bool kShowAboutMenuItem;
+
// Does the OS support other browsers? If not, operations such as default
// browser check are not done.
extern const bool kOSSupportsOtherBrowsers;
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 6aae9df..411d1e0 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -16,7 +16,6 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/app/chrome_dll_resource.h"
-#include "chrome/browser/back_forward_menu_model_views.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
@@ -31,7 +30,6 @@
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
-#include "chrome/browser/user_data_manager.h"
#include "chrome/browser/views/bookmark_menu_button.h"
#include "chrome/browser/views/browser_actions_container.h"
#include "chrome/browser/views/event_utils.h"
@@ -94,9 +92,7 @@ ToolbarView::ToolbarView(Browser* browser)
bookmark_menu_(NULL),
profile_(NULL),
browser_(browser),
- profiles_menu_contents_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- profiles_helper_(new GetProfilesHelper(this))) {
+ profiles_menu_contents_(NULL) {
browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
browser_->command_updater()->AddCommandObserver(IDC_RELOAD, this);
@@ -113,10 +109,6 @@ ToolbarView::ToolbarView(Browser* browser)
}
}
-ToolbarView::~ToolbarView() {
- profiles_helper_->OnDelegateDeleted();
-}
-
void ToolbarView::Init(Profile* profile) {
back_menu_model_.reset(new BackForwardMenuModelViews(
browser_, BackForwardMenuModel::BACKWARD_MENU, GetWidget()));
@@ -180,39 +172,6 @@ void ToolbarView::RunMenu(views::View* source, const gfx::Point& pt) {
}
////////////////////////////////////////////////////////////////////////////////
-// ToolbarView, GetProfilesHelper::Delegate implementation:
-
-void ToolbarView::OnGetProfilesDone(
- const std::vector<std::wstring>& profiles) {
- // Nothing to do if the menu has gone away.
- if (!profiles_menu_contents_.get())
- return;
-
- // Store the latest list of profiles in the browser.
- browser_->set_user_data_dir_profiles(profiles);
-
- // Add direct sub menu items for profiles.
- std::vector<std::wstring>::const_iterator iter = profiles.begin();
- for (int i = IDC_NEW_WINDOW_PROFILE_0;
- (i <= IDC_NEW_WINDOW_PROFILE_LAST) && (iter != profiles.end());
- ++i, ++iter)
- profiles_menu_contents_->AddItem(i, WideToUTF16Hack(*iter));
-
- // If there are more profiles then show "Other" link.
- if (iter != profiles.end()) {
- profiles_menu_contents_->AddSeparator();
- profiles_menu_contents_->AddItemWithStringId(IDC_SELECT_PROFILE,
- IDS_SELECT_PROFILE);
- }
-
- // Always show a link to select a new profile.
- profiles_menu_contents_->AddSeparator();
- profiles_menu_contents_->AddItemWithStringId(
- IDC_NEW_PROFILE,
- IDS_SELECT_PROFILE_DIALOG_NEW_PROFILE_ENTRY);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// ToolbarView, LocationBarView::Delegate implementation:
TabContents* ToolbarView::GetTabContents() {
@@ -770,75 +729,9 @@ void ToolbarView::RunPageMenu(const gfx::Point& pt) {
}
void ToolbarView::RunAppMenu(const gfx::Point& pt) {
- CreateAppMenu();
- app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
-}
-
-void ToolbarView::CreateAppMenu() {
// We always rebuild the app menu so that we can get the current state of
// the sync system.
-
- app_menu_contents_.reset(new menus::SimpleMenuModel(this));
- app_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB);
- app_menu_contents_->AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW);
- app_menu_contents_->AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW,
- IDS_NEW_INCOGNITO_WINDOW);
- // Enumerate profiles asynchronously and then create the parent menu item.
- // We will create the child menu items for this once the asynchronous call is
- // done. See OnGetProfilesDone().
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kEnableUserDataDirProfiles) &&
- !profiles_menu_contents_.get()) {
- profiles_helper_->GetProfiles(NULL);
- profiles_menu_contents_.reset(new menus::SimpleMenuModel(this));
- app_menu_contents_->AddSubMenuWithStringId(IDS_PROFILE_MENU,
- profiles_menu_contents_.get());
- }
-
- app_menu_contents_->AddSeparator();
- app_menu_contents_->AddCheckItemWithStringId(IDC_SHOW_BOOKMARK_BAR,
- IDS_SHOW_BOOKMARK_BAR);
- app_menu_contents_->AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN);
- app_menu_contents_->AddSeparator();
- app_menu_contents_->AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY);
- app_menu_contents_->AddItemWithStringId(IDC_SHOW_BOOKMARK_MANAGER,
- IDS_BOOKMARK_MANAGER);
- app_menu_contents_->AddItemWithStringId(IDC_SHOW_DOWNLOADS,
- IDS_SHOW_DOWNLOADS);
-
- // Create the manage extensions menu item.
- app_menu_contents_->AddItemWithStringId(IDC_MANAGE_EXTENSIONS,
- IDS_SHOW_EXTENSIONS);
-
- app_menu_contents_->AddSeparator();
- if (ProfileSyncService::IsSyncEnabled()) {
- string16 label;
- string16 link;
- // TODO(akalin): use sync_ui_util::GetStatus instead.
- sync_ui_util::MessageType type = sync_ui_util::GetStatusLabels(
- browser_->profile()->GetOriginalProfile()->GetProfileSyncService(),
- &label, &link);
- label = type == sync_ui_util::SYNCED ?
- l10n_util::GetStringUTF16(IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL) :
- type == sync_ui_util::SYNC_ERROR ?
- l10n_util::GetStringUTF16(IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL) :
- l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL);
- app_menu_contents_->AddItem(IDC_SYNC_BOOKMARKS, label);
- app_menu_contents_->AddSeparator();
- }
- app_menu_contents_->AddItem(IDC_OPTIONS,
- l10n_util::GetStringFUTF16(
- IDS_OPTIONS,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
- app_menu_contents_->AddItem(IDC_ABOUT,
- l10n_util::GetStringFUTF16(
- IDS_ABOUT,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
- app_menu_contents_->AddItemWithStringId(IDC_HELP_PAGE, IDS_HELP_PAGE);
- if (browser_defaults::kShowExitMenuItem) {
- app_menu_contents_->AddSeparator();
- app_menu_contents_->AddItemWithStringId(IDC_EXIT, IDS_EXIT);
- }
-
- app_menu_menu_.reset(new views::Menu2(app_menu_contents_.get()));
+ app_menu_model_.reset(new AppMenuModel(this, browser_));
+ app_menu_menu_.reset(new views::Menu2(app_menu_model_.get()));
+ app_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT);
}
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index 5048fb1..22b4788 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -8,12 +8,12 @@
#include <vector>
#include "app/menus/simple_menu_model.h"
-#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "chrome/browser/app_menu_model.h"
+#include "chrome/browser/back_forward_menu_model_views.h"
#include "chrome/browser/bubble_positioner.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/page_menu_model.h"
-#include "chrome/browser/user_data_manager.h"
#include "chrome/browser/views/accessible_toolbar_view.h"
#include "chrome/browser/views/go_button.h"
#include "chrome/browser/views/location_bar_view.h"
@@ -23,7 +23,6 @@
#include "views/controls/menu/view_menu_delegate.h"
#include "views/view.h"
-class BackForwardMenuModelViews;
class BrowserActionsContainer;
class Browser;
class Profile;
@@ -40,13 +39,12 @@ class ToolbarView : public AccessibleToolbarView,
public menus::SimpleMenuModel::Delegate,
public LocationBarView::Delegate,
public NotificationObserver,
- public GetProfilesHelper::Delegate,
public CommandUpdater::CommandObserver,
public views::ButtonListener,
public BubblePositioner {
public:
explicit ToolbarView(Browser* browser);
- virtual ~ToolbarView();
+ virtual ~ToolbarView() { }
// Create the contents of the Browser Toolbar
void Init(Profile* profile);
@@ -79,9 +77,6 @@ class ToolbarView : public AccessibleToolbarView,
// Overridden from views::MenuDelegate:
virtual void RunMenu(views::View* source, const gfx::Point& pt);
- // Overridden from GetProfilesHelper::Delegate:
- virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles);
-
// Overridden from LocationBarView::Delegate:
virtual TabContents* GetTabContents();
virtual void OnInputInProgress(bool in_progress);
@@ -143,8 +138,6 @@ class ToolbarView : public AccessibleToolbarView,
void RunPageMenu(const gfx::Point& pt);
void RunAppMenu(const gfx::Point& pt);
- void CreateAppMenu();
-
// Types of display mode this toolbar can have.
enum DisplayMode {
DISPLAYMODE_NORMAL, // Normal toolbar with buttons, etc.
@@ -180,9 +173,6 @@ class ToolbarView : public AccessibleToolbarView,
// Contents of the profiles menu to populate with profile names.
scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_;
- // Helper class to enumerate profiles information on the file thread.
- scoped_refptr<GetProfilesHelper> profiles_helper_;
-
// Controls whether or not a home button should be shown on the toolbar.
BooleanPrefMember show_home_button_;
@@ -191,7 +181,7 @@ class ToolbarView : public AccessibleToolbarView,
// The contents of the various menus.
scoped_ptr<PageMenuModel> page_menu_model_;
- scoped_ptr<menus::SimpleMenuModel> app_menu_contents_;
+ scoped_ptr<AppMenuModel> app_menu_model_;
// TODO(beng): build these into MenuButton.
scoped_ptr<views::Menu2> page_menu_menu_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a5ce56e..6f7b8e9 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -43,6 +43,8 @@
'browser/app_controller_cppsafe_mac.h',
'browser/app_controller_mac.h',
'browser/app_controller_mac.mm',
+ 'browser/app_menu_model.cc',
+ 'browser/app_menu_model.h',
'browser/app_modal_dialog.cc',
'browser/app_modal_dialog.h',
'browser/app_modal_dialog_gtk.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index f103ff1..495ba3d 100755
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -506,6 +506,7 @@
'app/breakpad_mac_stubs.mm',
# All unittests in browser, common, and renderer.
'browser/app_controller_mac_unittest.mm',
+ 'browser/app_menu_model_unittest.cc',
'browser/autocomplete/autocomplete_edit_view_mac_unittest.mm',
'browser/autocomplete/autocomplete_unittest.cc',
'browser/autocomplete/autocomplete_popup_view_mac_unittest.mm',