summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/chrome_dll_resource.h14
-rw-r--r--chrome/app/nibs/en.lproj/MainMenu.xib168
-rw-r--r--chrome/app/nibs/en.lproj/TabContents.xib78
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu.cc3
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.cc32
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.h8
-rw-r--r--chrome/browser/browser.cc11
-rw-r--r--chrome/browser/browser.h6
-rw-r--r--chrome/browser/browser_prefs.cc8
-rw-r--r--chrome/browser/cocoa/bookmark_bar_state_controller.h36
-rw-r--r--chrome/browser/cocoa/bookmark_bar_state_controller.mm38
-rw-r--r--chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm45
-rw-r--r--chrome/browser/cocoa/bookmark_menu_bridge.h56
-rw-r--r--chrome/browser/cocoa/bookmark_menu_bridge.mm110
-rw-r--r--chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm107
-rw-r--r--chrome/browser/cocoa/browser_test_helper.h38
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.h12
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.mm19
-rw-r--r--chrome/browser/cocoa/browser_window_controller.h7
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm52
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.h27
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.mm48
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.h26
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm41
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc24
-rw-r--r--chrome/browser/views/bookmark_bar_view.h6
-rw-r--r--chrome/browser/views/bookmark_table_view.cc9
-rw-r--r--chrome/browser/views/bookmark_table_view.h2
-rw-r--r--chrome/browser/views/frame/browser_view.cc3
-rw-r--r--chrome/chrome.gyp14
-rw-r--r--chrome/common/temp_scaffolding_stubs.h5
-rw-r--r--chrome/test/testing_profile.h2
32 files changed, 815 insertions, 240 deletions
diff --git a/chrome/app/chrome_dll_resource.h b/chrome/app/chrome_dll_resource.h
index ec823a5..b981be7 100644
--- a/chrome/app/chrome_dll_resource.h
+++ b/chrome/app/chrome_dll_resource.h
@@ -1,6 +1,9 @@
//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by chrome_dll.rc
+//
+// What began as a Microsoft Visual C++ generated include file is now
+// edited by hand. Do not generate!!!
+//
+// Used by chrome_dll.rc, Mac nibs, ...
//
#define IDR_MAINFRAME 101
@@ -194,3 +197,10 @@
#define _APS_NEXT_SYMED_VALUE 1001
#endif
#endif
+
+// Identifiers for platform-specific items.
+// Placed in a common file to help insure they never collide.
+#define IDC_BOOKMARK_MENU 43000 // OSX only
+#define IDC_BOOKMARK_MENUITEM_BASE 43001 // OSX only
+// Numbers 43002-43998 reserved for menu items
+#define IDC_BOOKMARK_MENUITEM_MAX 43999 // OSX only
diff --git a/chrome/app/nibs/en.lproj/MainMenu.xib b/chrome/app/nibs/en.lproj/MainMenu.xib
index e191c9a..67e0556 100644
--- a/chrome/app/nibs/en.lproj/MainMenu.xib
+++ b/chrome/app/nibs/en.lproj/MainMenu.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="450"/>
+ <integer value="29"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -680,6 +680,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
+ <int key="NSTag">40009</int>
</object>
<object class="NSMenuItem" id="946218152">
<reference key="NSMenu" ref="466310130"/>
@@ -848,6 +849,7 @@
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
<string key="NSAction">submenuAction:</string>
+ <int key="NSTag">43000</int>
<object class="NSMenu" key="NSSubmenu" id="891828782">
<string key="NSTitle">Bookmarks</string>
<object class="NSMutableArray" key="NSMenuItems">
@@ -859,6 +861,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
+ <int key="NSTag">35000</int>
</object>
<object class="NSMenuItem" id="505033846">
<reference key="NSMenu" ref="891828782"/>
@@ -870,63 +873,6 @@
<reference key="NSOnImage" ref="353210768"/>
<reference key="NSMixedImage" ref="549394948"/>
</object>
- <object class="NSMenuItem" id="1034669272">
- <reference key="NSMenu" ref="891828782"/>
- <string key="NSTitle">Bonjour</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="353210768"/>
- <reference key="NSMixedImage" ref="549394948"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="2554196">
- <string key="NSTitle">Bonjour</string>
- <object class="NSMutableArray" key="NSMenuItems">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMenuItem" id="963150272">
- <reference key="NSMenu" ref="2554196"/>
- <string key="NSTitle">Item</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="353210768"/>
- <reference key="NSMixedImage" ref="549394948"/>
- </object>
- </object>
- </object>
- </object>
- <object class="NSMenuItem" id="1024441020">
- <reference key="NSMenu" ref="891828782"/>
- <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="353210768"/>
- <reference key="NSMixedImage" ref="549394948"/>
- </object>
- <object class="NSMenuItem" id="690079652">
- <reference key="NSMenu" ref="891828782"/>
- <string key="NSTitle">Item 1</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="353210768"/>
- <reference key="NSMixedImage" ref="549394948"/>
- </object>
- <object class="NSMenuItem" id="968858508">
- <reference key="NSMenu" ref="891828782"/>
- <string key="NSTitle">Item 2</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="353210768"/>
- <reference key="NSMixedImage" ref="549394948"/>
- </object>
- <object class="NSMenuItem" id="25085450">
- <reference key="NSMenu" ref="891828782"/>
- <string key="NSTitle">Item 3</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="353210768"/>
- <reference key="NSMixedImage" ref="549394948"/>
- </object>
</object>
</object>
</object>
@@ -1281,14 +1227,6 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">toggleToolbarShown:</string>
- <reference key="source" ref="1014"/>
- <reference key="destination" ref="102151532"/>
- </object>
- <int key="connectionID">366</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
<string key="label">hide:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="755159360"/>
@@ -1399,6 +1337,22 @@
</object>
<int key="connectionID">530</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">commandDispatch:</string>
+ <reference key="source" ref="1014"/>
+ <reference key="destination" ref="102151532"/>
+ </object>
+ <int key="connectionID">531</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">commandDispatch:</string>
+ <reference key="source" ref="1014"/>
+ <reference key="destination" ref="399860348"/>
+ </object>
+ <int key="connectionID">532</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2127,45 +2081,12 @@
<reference key="object" ref="891828782"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="1024441020"/>
- <reference ref="1034669272"/>
<reference ref="505033846"/>
<reference ref="399860348"/>
- <reference ref="25085450"/>
- <reference ref="968858508"/>
- <reference ref="690079652"/>
</object>
<reference key="parent" ref="299901009"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">509</int>
- <reference key="object" ref="1024441020"/>
- <reference key="parent" ref="891828782"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">506</int>
- <reference key="object" ref="1034669272"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="2554196"/>
- </object>
- <reference key="parent" ref="891828782"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">507</int>
- <reference key="object" ref="2554196"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="963150272"/>
- </object>
- <reference key="parent" ref="1034669272"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">508</int>
- <reference key="object" ref="963150272"/>
- <reference key="parent" ref="2554196"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">505</int>
<reference key="object" ref="505033846"/>
<reference key="parent" ref="891828782"/>
@@ -2176,21 +2097,6 @@
<reference key="parent" ref="891828782"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">500</int>
- <reference key="object" ref="25085450"/>
- <reference key="parent" ref="891828782"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">499</int>
- <reference key="object" ref="968858508"/>
- <reference key="parent" ref="891828782"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">498</int>
- <reference key="object" ref="690079652"/>
- <reference key="parent" ref="891828782"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">514</int>
<reference key="object" ref="445514911"/>
<object class="NSMutableArray" key="children">
@@ -2410,22 +2316,14 @@
<string>496.IBPluginDependency</string>
<string>497.IBEditorWindowLastContentRect</string>
<string>497.IBPluginDependency</string>
- <string>498.IBPluginDependency</string>
- <string>499.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>5.ImportedFromIB2</string>
- <string>500.IBPluginDependency</string>
<string>501.IBPluginDependency</string>
<string>502.IBEditorWindowLastContentRect</string>
<string>502.IBPluginDependency</string>
<string>503.IBPluginDependency</string>
<string>504.IBPluginDependency</string>
<string>505.IBPluginDependency</string>
- <string>506.IBPluginDependency</string>
- <string>507.IBEditorWindowLastContentRect</string>
- <string>507.IBPluginDependency</string>
- <string>508.IBPluginDependency</string>
- <string>509.IBPluginDependency</string>
<string>514.IBPluginDependency</string>
<string>515.IBEditorWindowLastContentRect</string>
<string>515.IBPluginDependency</string>
@@ -2490,7 +2388,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{531, 606}, {64, 6}}</string>
+ <string>{{370, 798}, {64, 6}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{436, 809}, {64, 6}}</string>
@@ -2534,7 +2432,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{249, 483}, {243, 263}}</string>
+ <string>{{262, 631}, {243, 263}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{197, 734}, {243, 243}}</string>
@@ -2584,13 +2482,13 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{525, 802}, {197, 73}}</string>
- <string>{{99, 749}, {535, 20}}</string>
+ <string>{{116, 895}, {535, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{74, 862}</string>
<string>{{11, 977}, {478, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{291, 606}, {273, 143}}</string>
+ <string>{{306, 752}, {273, 143}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{475, 832}, {234, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2634,26 +2532,18 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{408, 626}, {230, 123}}</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{425, 862}, {230, 33}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{566, 604}, {137, 23}}</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>{{572, 694}, {86, 23}}</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>{{341, 656}, {188, 93}}</string>
+ <string>{{356, 801}, {188, 93}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2662,7 +2552,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{113, 533}, {244, 213}}</string>
+ <string>{{126, 681}, {244, 213}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{23, 794}, {245, 183}}</string>
@@ -2682,7 +2572,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{205, 466}, {249, 283}}</string>
+ <string>{{220, 611}, {249, 283}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{323, 672}, {199, 203}}</string>
@@ -2714,7 +2604,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">530</int>
+ <int key="maxID">532</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/chrome/app/nibs/en.lproj/TabContents.xib b/chrome/app/nibs/en.lproj/TabContents.xib
index a084868..7f6d0b1 100644
--- a/chrome/app/nibs/en.lproj/TabContents.xib
+++ b/chrome/app/nibs/en.lproj/TabContents.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="112"/>
+ <integer value="164"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -55,6 +55,13 @@
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomView" id="741487837">
+ <reference key="NSNextResponder" ref="675542922"/>
+ <int key="NSvFlags">266</int>
+ <string key="NSFrame">{{0, 284}, {480, 38}}</string>
+ <reference key="NSSuperview" ref="675542922"/>
+ <string key="NSClassName">ToolbarView</string>
+ </object>
<object class="NSBox" id="753762894">
<reference key="NSNextResponder" ref="675542922"/>
<int key="NSvFlags">18</int>
@@ -469,6 +476,14 @@
</object>
<int key="connectionID">178</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">bookmarkView_</string>
+ <reference key="source" ref="326691890"/>
+ <reference key="destination" ref="741487837"/>
+ </object>
+ <int key="connectionID">194</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -511,6 +526,7 @@
<reference ref="588745489"/>
<reference ref="753762894"/>
<reference ref="995989345"/>
+ <reference ref="741487837"/>
</object>
<reference key="parent" ref="886393115"/>
</object>
@@ -646,6 +662,14 @@
<reference key="object" ref="995989345"/>
<reference key="parent" ref="675542922"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">179</int>
+ <reference key="object" ref="741487837"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="parent" ref="675542922"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -677,6 +701,7 @@
<string>138.IBPluginDependency</string>
<string>164.IBPluginDependency</string>
<string>175.IBPluginDependency</string>
+ <string>179.IBPluginDependency</string>
<string>93.IBEditorWindowLastContentRect</string>
<string>93.IBViewEditorWindowController.showingLayoutRectangles</string>
<string>93.IBWindowTemplateEditedContentRect</string>
@@ -713,9 +738,10 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{273, 242}, {480, 360}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{273, 255}, {480, 360}}</string>
<boolean value="YES" id="5"/>
- <string>{{273, 242}, {480, 360}}</string>
+ <string>{{273, 255}, {480, 360}}</string>
<reference ref="5"/>
<reference ref="5"/>
<string>{480, 360}</string>
@@ -743,7 +769,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">178</int>
+ <int key="maxID">194</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -822,6 +848,50 @@
</object>
</object>
</object>
+ <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">TabContentsController</string>
+ <string key="superclassName">NSViewController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <string key="NS.key.0">fullScreen:</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>backButton_</string>
+ <string>bookmarkView_</string>
+ <string>contentsBox_</string>
+ <string>forwardButton_</string>
+ <string>goButton_</string>
+ <string>growBox_</string>
+ <string>locationBar_</string>
+ <string>reloadButton_</string>
+ <string>starButton_</string>
+ <string>toolbarView_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSButton</string>
+ <string>ToolbarView</string>
+ <string>NSBox</string>
+ <string>NSButton</string>
+ <string>NSButton</string>
+ <string>GrowBoxView</string>
+ <string>NSTextField</string>
+ <string>NSButton</string>
+ <string>NSButton</string>
+ <string>ToolbarView</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBDocumentRelativeSource</string>
+ <string key="minorKey">../../../browser/cocoa/tab_contents_controller.h</string>
+ </object>
+ </object>
+ </object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">../../../chrome.xcodeproj</string>
diff --git a/chrome/browser/bookmarks/bookmark_context_menu.cc b/chrome/browser/bookmarks/bookmark_context_menu.cc
index 6e00094..0730d1f 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu.cc
+++ b/chrome/browser/bookmarks/bookmark_context_menu.cc
@@ -19,7 +19,6 @@
// TODO(port): Port these files.
#if defined(OS_WIN)
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/views/bookmark_bar_view.h"
#include "chrome/browser/views/bookmark_editor_view.h"
#include "chrome/browser/views/bookmark_manager_view.h"
#include "chrome/browser/views/input_window.h"
@@ -428,7 +427,7 @@ void BookmarkContextMenu::ExecuteCommand(int id) {
}
case IDS_BOOMARK_BAR_ALWAYS_SHOW:
- BookmarkBarView::ToggleWhenVisible(profile_);
+ bookmark_utils::ToggleWhenVisible(profile_);
break;
case IDS_BOOKMARK_MANAGER_SHOW_IN_FOLDER:
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 429c06d..c210dad 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -16,6 +16,9 @@
#include "chrome/browser/tab_contents/page_navigator.h"
#include "chrome/common/drag_drop_types.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/notification_service.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
#include "chrome/views/controls/tree/tree_node_iterator.h"
#include "chrome/views/event.h"
#include "grit/chromium_strings.h"
@@ -529,4 +532,33 @@ bool DoesBookmarkContainText(BookmarkNode* node, const std::wstring& text) {
return (node->is_url() && DoesBookmarkContainWords(node, words));
}
+// Formerly in BookmarkBarView
+void ToggleWhenVisible(Profile* profile) {
+ PrefService* prefs = profile->GetPrefs();
+ const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar);
+
+ // The user changed when the bookmark bar is shown, update the preferences.
+ prefs->SetBoolean(prefs::kShowBookmarkBar, always_show);
+ prefs->ScheduleSavePersistentPrefs(g_browser_process->file_thread());
+
+ // And notify the notification service.
+ Source<Profile> source(profile);
+ NotificationService::current()->Notify(
+ NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
+ source,
+ NotificationService::NoDetails());
+}
+
+void RegisterUserPrefs(PrefService* prefs) {
+ // Formerly in BookmarkBarView
+ prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, false);
+
+ // Formerly in BookmarkTableView
+ prefs->RegisterIntegerPref(prefs::kBookmarkTableNameWidth1, -1);
+ prefs->RegisterIntegerPref(prefs::kBookmarkTableURLWidth1, -1);
+ prefs->RegisterIntegerPref(prefs::kBookmarkTableNameWidth2, -1);
+ prefs->RegisterIntegerPref(prefs::kBookmarkTableURLWidth2, -1);
+ prefs->RegisterIntegerPref(prefs::kBookmarkTablePathWidth, -1);
+}
+
} // namespace bookmark_utils
diff --git a/chrome/browser/bookmarks/bookmark_utils.h b/chrome/browser/bookmarks/bookmark_utils.h
index 26e60ef..43966c0 100644
--- a/chrome/browser/bookmarks/bookmark_utils.h
+++ b/chrome/browser/bookmarks/bookmark_utils.h
@@ -15,6 +15,7 @@
class BookmarkModel;
class BookmarkNode;
class PageNavigator;
+class PrefService;
class Profile;
namespace views {
@@ -141,6 +142,13 @@ void GetBookmarksContainingText(BookmarkModel* model,
// Returns true if |node|'s url or title contains the string |text|.
bool DoesBookmarkContainText(BookmarkNode* node, const std::wstring& text);
+// Toggles whether the bookmark bar is shown only on the new tab page or on
+// all tabs. This is a preference modifier, not a visual modifier.
+void ToggleWhenVisible(Profile* profile);
+
+// Register user prefs for BookmarkBar, BookmarkView, ...
+void RegisterUserPrefs(PrefService* prefs);
+
// Number of bookmarks we'll open before prompting the user to see if they
// really want to open all.
//
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 7014ef7b..e582f8f 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -991,12 +991,17 @@ void Browser::OpenBugReportDialog() {
UserMetrics::RecordAction(L"ReportBug", profile_);
window_->ShowReportBugDialog();
}
+#endif // #if defined(OS_WIN)
+
+#if defined(OS_WIN) || defined(OS_MACOSX)
void Browser::ToggleBookmarkBar() {
UserMetrics::RecordAction(L"ShowBookmarksBar", profile_);
window_->ToggleBookmarkBar();
}
+#endif
+#if defined(OS_WIN)
void Browser::OpenBookmarkManager() {
UserMetrics::RecordAction(L"ShowBookmarkManager", profile_);
window_->ShowBookmarkManager();
@@ -1241,7 +1246,13 @@ void Browser::ExecuteCommand(int id) {
case IDC_SELECT_PROFILE: OpenSelectProfileDialog(); break;
case IDC_NEW_PROFILE: OpenNewProfileDialog(); break;
case IDC_REPORT_BUG: OpenBugReportDialog(); break;
+#endif
+
+#if defined(OS_WIN) || defined(OS_MACOSX)
case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break;
+#endif
+
+#if defined(OS_WIN)
case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break;
#endif
case IDC_SHOW_HISTORY: ShowHistoryTab(); break;
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index d6ead77..0526a2c 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -329,7 +329,13 @@ class Browser : public TabStripModelDelegate,
void OpenSelectProfileDialog();
void OpenNewProfileDialog();
void OpenBugReportDialog();
+#endif // defined(OS_WIN)
+
+#if defined(OS_WIN) || defined(OS_MACOSX)
void ToggleBookmarkBar();
+#endif
+
+#if defined(OS_WIN)
void OpenBookmarkManager();
#endif
void ShowHistoryTab();
diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc
index a747c31..570763f 100644
--- a/chrome/browser/browser_prefs.cc
+++ b/chrome/browser/browser_prefs.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/autofill_manager.h"
+#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/cache_manager_host.h"
@@ -23,9 +24,7 @@
#if defined(OS_WIN) // TODO(port): whittle this down as we port
#include "chrome/browser/task_manager.h"
-#include "chrome/browser/views/bookmark_bar_view.h"
#include "chrome/browser/views/bookmark_manager_view.h"
-#include "chrome/browser/views/bookmark_table_view.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/keyword_editor_view.h"
#include "chrome/browser/views/page_info_window.h"
@@ -58,10 +57,7 @@ void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) {
chrome_browser_net::RegisterUserPrefs(user_prefs);
DownloadManager::RegisterUserPrefs(user_prefs);
SSLManager::RegisterUserPrefs(user_prefs);
-#if defined(OS_WIN) // TODO(port): whittle this down as we port
- BookmarkBarView::RegisterUserPrefs(user_prefs);
- BookmarkTableView::RegisterUserPrefs(user_prefs);
-#endif
+ bookmark_utils::RegisterUserPrefs(user_prefs);
AutofillManager::RegisterUserPrefs(user_prefs);
TabContents::RegisterUserPrefs(user_prefs);
TemplateURLPrepopulateData::RegisterUserPrefs(user_prefs);
diff --git a/chrome/browser/cocoa/bookmark_bar_state_controller.h b/chrome/browser/cocoa/bookmark_bar_state_controller.h
new file mode 100644
index 0000000..b3aeafd
--- /dev/null
+++ b/chrome/browser/cocoa/bookmark_bar_state_controller.h
@@ -0,0 +1,36 @@
+// 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_COCOA_BOOKMARK_BAR_STATE_CONTROLLER_H_
+#define CHROME_BROWSER_COCOA_BOOKMARK_BAR_STATE_CONTROLLER_H_
+
+#import <Cocoa/Cocoa.h>
+
+class Browser;
+
+// A class to manage bookmark bar state (visible or not). State is
+// shared among all tabs and saved in a preference.
+@interface BookmarkBarStateController : NSObject {
+ @private
+ Browser* browser_;
+ BOOL visible_;
+}
+
+- (id)initWithBrowser:(Browser *)browser;
+
+// Return YES or NO reflecting visibility state of the bookmark bar.
+- (BOOL)visible;
+
+// Toggle (on or off) the bookmark bar visibility.
+- (void)toggleBookmarkBar;
+
+@end // BookmarkBarStateController
+
+
+@interface BookmarkBarStateController (Private)
+// Internal method exposed for unit test convenience.
+- (void)togglePreference;
+@end
+
+#endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_STATE_CONTROLLER_H_
diff --git a/chrome/browser/cocoa/bookmark_bar_state_controller.mm b/chrome/browser/cocoa/bookmark_bar_state_controller.mm
new file mode 100644
index 0000000..77d0625
--- /dev/null
+++ b/chrome/browser/cocoa/bookmark_bar_state_controller.mm
@@ -0,0 +1,38 @@
+// 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.
+
+#import "chrome/browser/cocoa/bookmark_bar_state_controller.h"
+#import "chrome/browser/bookmarks/bookmark_utils.h"
+#import "chrome/browser/browser.h"
+
+
+@implementation BookmarkBarStateController
+
+- (id)initWithBrowser:(Browser *)browser {
+ if ((self = [super init])) {
+ browser_ = browser;
+ // Initial visibility state comes from our preference.
+ if (browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) {
+ visible_ = YES;
+ }
+ }
+ return self;
+}
+
+- (BOOL)visible {
+ return visible_;
+}
+
+// Whack and save a preference change. On Windows this call
+// is made from BookmarkBarView.
+- (void)togglePreference {
+ bookmark_utils::ToggleWhenVisible(browser_->profile());
+}
+
+- (void)toggleBookmarkBar {
+ visible_ = visible_ ? NO : YES;
+ [self togglePreference];
+}
+
+@end // BookmarkBarStateController
diff --git a/chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm
new file mode 100644
index 0000000..8a86309
--- /dev/null
+++ b/chrome/browser/cocoa/bookmark_bar_state_controller_unittest.mm
@@ -0,0 +1,45 @@
+// 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/browser.h"
+#include "chrome/browser/cocoa/bookmark_bar_state_controller.h"
+#include "chrome/browser/cocoa/browser_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+@interface NoPrefSaveBBStateController : BookmarkBarStateController {
+ @public
+ BOOL toggled_;
+}
+@end
+
+@implementation NoPrefSaveBBStateController
+- (void)togglePreference {
+ toggled_ = !toggled_;
+}
+@end
+
+
+class BookmarkBarStateControllerTest : public testing::Test {
+ public:
+ BrowserTestHelper browser_test_helper_;
+};
+
+
+TEST_F(BookmarkBarStateControllerTest, MainTest) {
+ Browser* browser = browser_test_helper_.GetBrowser();
+ NoPrefSaveBBStateController *c = [[[NoPrefSaveBBStateController alloc]
+ initWithBrowser:browser]
+ autorelease];
+ EXPECT_TRUE(c);
+ EXPECT_FALSE(c->toggled_);
+ BOOL old_visible = [c visible];
+
+ [c toggleBookmarkBar];
+ EXPECT_TRUE(c->toggled_ != NO);
+ EXPECT_NE((bool)old_visible, (bool)[c visible]);
+
+ [c toggleBookmarkBar];
+ EXPECT_FALSE(c->toggled_);
+ EXPECT_EQ((bool)old_visible, (bool)[c visible]);
+}
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.h b/chrome/browser/cocoa/bookmark_menu_bridge.h
new file mode 100644
index 0000000..81ff98fc
--- /dev/null
+++ b/chrome/browser/cocoa/bookmark_menu_bridge.h
@@ -0,0 +1,56 @@
+// 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.
+
+// C++ controller for the bookmark menu. When bookmarks are changed,
+// this class takes care of updating Cocoa bookmark menus. This is
+// not named BookmarkMenuController to help avoid confusion between
+// languages. This class needs to be C++, not ObjC, since it derives
+// from BookmarkModelObserver.
+
+#ifndef CHROME_BROWSER_COCOA_BOOKMARK_MENU_BRIDGE_H_
+#define CHROME_BROWSER_COCOA_BOOKMARK_MENU_BRIDGE_H_
+
+#include "chrome/browser/bookmarks/bookmark_model.h"
+
+
+class Browser;
+@class NSMenu;
+
+class BookmarkMenuBridge : public BookmarkModelObserver {
+ public:
+ BookmarkMenuBridge(Browser* browser);
+ ~BookmarkMenuBridge();
+
+ // Overridden from BookmarkModelObserver
+ virtual void Loaded(BookmarkModel* model);
+ virtual void BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
+ int old_index,
+ BookmarkNode* new_parent,
+ int new_index);
+ virtual void BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
+ int index);
+ virtual void BookmarkNodeChanged(BookmarkModel* model,
+ BookmarkNode* node);
+ virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
+ BookmarkNode* node);
+ virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
+ BookmarkNode* node);
+
+ protected:
+ // Clear all bookmarks from the given bookmark menu.
+ void ClearBookmarkMenu(NSMenu* menu);
+
+ // Helper for recursively adding items to our bookmark menu
+ // All children of |node| will be added to |menu|.
+ // TODO(jrg): add a counter to enforce maximum nodes added
+ void AddNodeToMenu(BookmarkNode* node, NSMenu* menu);
+
+ private:
+ friend class BookmarkMenuBridgeTest;
+ Browser* browser_;
+};
+
+#endif // CHROME_BROWSER_COCOA_BOOKMARK_MENU_BRIDGE_H_
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge.mm b/chrome/browser/cocoa/bookmark_menu_bridge.mm
new file mode 100644
index 0000000..ca78da3
--- /dev/null
+++ b/chrome/browser/cocoa/bookmark_menu_bridge.mm
@@ -0,0 +1,110 @@
+// 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/cocoa/bookmark_menu_bridge.h"
+#import <AppKit/AppKit.h>
+#include "base/sys_string_conversions.h"
+#include "chrome/app/chrome_dll_resource.h" // IDC_BOOKMARK_MENU
+#include "chrome/browser/browser.h"
+#include "chrome/browser/profile.h"
+
+
+BookmarkMenuBridge::BookmarkMenuBridge(Browser* browser) : browser_(browser) {
+ browser_->profile()->GetBookmarkModel()->AddObserver(this);
+}
+
+BookmarkMenuBridge::~BookmarkMenuBridge() {
+ browser_->profile()->GetBookmarkModel()->RemoveObserver(this);
+}
+
+void BookmarkMenuBridge::Loaded(BookmarkModel* model) {
+ NSMenu *bookmark_menu = [[[NSApp mainMenu] itemWithTag:IDC_BOOKMARK_MENU]
+ submenu];
+ if (bookmark_menu == nil)
+ return;
+
+ this->ClearBookmarkMenu(bookmark_menu);
+
+ // TODO(jrg): limit the number of bookmarks in the menubar to max_nodes
+ // int max_nodes = IDC_BOOKMARK_MENUITEM_MAX - IDC_BOOKMARK_MENUITEM_BASE;
+ this->AddNodeToMenu(model->GetBookmarkBarNode(), bookmark_menu);
+}
+
+void BookmarkMenuBridge::BookmarkNodeMoved(BookmarkModel* model,
+ BookmarkNode* old_parent,
+ int old_index,
+ BookmarkNode* new_parent,
+ int new_index) {
+ // TODO(jrg): this is brute force; perhaps we should be nicer.
+ this->Loaded(model);
+}
+
+void BookmarkMenuBridge::BookmarkNodeAdded(BookmarkModel* model,
+ BookmarkNode* parent,
+ int index) {
+
+ // TODO(jrg): this is brute force; perhaps we should be nicer.
+ this->Loaded(model);
+}
+
+void BookmarkMenuBridge::BookmarkNodeChanged(BookmarkModel* model,
+ BookmarkNode* node) {
+
+ // TODO(jrg): this is brute force; perhaps we should be nicer.
+ this->Loaded(model);
+}
+
+void BookmarkMenuBridge::BookmarkNodeFavIconLoaded(BookmarkModel* model,
+ BookmarkNode* node) {
+ // Nothing to do here -- no icons in the menubar menus yet.
+ // TODO(jrg):
+ // Both Safari and FireFox have icons in their menubars for bookmarks.
+}
+
+void BookmarkMenuBridge::BookmarkNodeChildrenReordered(BookmarkModel* model,
+ BookmarkNode* node) {
+ // TODO(jrg): this is brute force; perhaps we should be nicer.
+ this->Loaded(model);
+}
+
+void BookmarkMenuBridge::ClearBookmarkMenu(NSMenu* menu) {
+ // Recursively delete all menus that look like a bookmark. Assume
+ // all items with submenus contain only bookmarks. This typically
+ // deletes everything except the first two items ("Add Bookmark..."
+ // and separator)
+ NSArray* items = [menu itemArray];
+ for (NSMenuItem* item in items) {
+ NSInteger tag = [item tag];
+ if ((tag >= IDC_BOOKMARK_MENUITEM_BASE) &&
+ (tag < IDC_BOOKMARK_MENUITEM_MAX)) {
+ [menu removeItem:item];
+ } else if ([item hasSubmenu]) {
+ [menu removeItem:item]; // Will eventually [obj release] all its kids
+ } else {
+ // Not a bookmark or item with submenu, so leave it alone.
+ }
+ }
+}
+
+// TODO(jrg): add actions for these menu items
+void BookmarkMenuBridge::AddNodeToMenu(BookmarkNode* node,
+ NSMenu* menu) {
+ for (int i = 0; i < node->GetChildCount(); i++) {
+ BookmarkNode* child = node->GetChild(i);
+ // TODO(jrg): Should we limit the title length?
+ // For the Bookmark Bar under windows, items appear trimmed to ~19
+ // chars (looks like a pixel width limit).
+ NSString* title = base::SysWideToNSString(child->GetTitle());
+ NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:title
+ action:nil
+ keyEquivalent:@""] autorelease];
+ [item setTag:IDC_BOOKMARK_MENUITEM_BASE];
+ [menu addItem:item];
+ if (child->is_folder()) {
+ NSMenu* submenu = [[[NSMenu alloc] initWithTitle:title] autorelease];
+ [menu setSubmenu:submenu forItem:item];
+ this->AddNodeToMenu(child, submenu); // recursive call
+ }
+ }
+}
diff --git a/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm b/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm
new file mode 100644
index 0000000..d00f75f
--- /dev/null
+++ b/chrome/browser/cocoa/bookmark_menu_bridge_unittest.mm
@@ -0,0 +1,107 @@
+// 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.
+
+#import <AppKit/AppKit.h>
+#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/cocoa/bookmark_menu_bridge.h"
+#include "chrome/browser/cocoa/browser_test_helper.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// TODO(jrg): see refactor comment in bookmark_bar_state_controller_unittest.mm
+class BookmarkMenuBridgeTest : public testing::Test {
+ public:
+
+ // We are a friend of BookmarkMenuBridge (and have access to
+ // protected methods), but none of the classes generated by TEST_F()
+ // are. This (and AddNodeToMenu()) are simple wrappers to let
+ // derived test classes have access to protected methods.
+ void ClearBookmarkMenu(BookmarkMenuBridge* bridge, NSMenu* menu) {
+ bridge->ClearBookmarkMenu(menu);
+ }
+
+ void AddNodeToMenu(BookmarkMenuBridge* bridge, BookmarkNode* root,
+ NSMenu* menu) {
+ bridge->AddNodeToMenu(root, menu);
+ }
+
+ NSMenuItem* AddItemToMenu(NSMenu *menu, NSString *title, NSInteger tag) {
+ NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title action:NULL
+ keyEquivalent:@""] autorelease];
+ [item setTag:tag];
+ [menu addItem:item];
+ return item;
+ }
+
+ BrowserTestHelper browser_test_helper_;
+};
+
+
+// Test that ClearBookmarkMenu() removes all bookmark menus.
+TEST_F(BookmarkMenuBridgeTest, TestClearBookmarkMenu) {
+ Browser* browser = browser_test_helper_.GetBrowser();
+ BookmarkMenuBridge* bridge = new BookmarkMenuBridge(browser);
+ EXPECT_TRUE(bridge);
+
+ NSMenu* menu = [[[NSMenu alloc] initWithTitle:@"foo"] autorelease];
+
+ AddItemToMenu(menu, @"hi mom", IDC_BOOKMARK_MENUITEM_BASE);
+ AddItemToMenu(menu, @"not", 0);
+ NSMenuItem* item = AddItemToMenu(menu, @"hi mom", 0);
+ [item setSubmenu:[[[NSMenu alloc] initWithTitle:@"bar"] autorelease]];
+ AddItemToMenu(menu, @"not", 0);
+
+ ClearBookmarkMenu(bridge, menu);
+
+ // Make sure all IDC_BOOKMARK items are removed, and all items with
+ // submenus removed.
+ EXPECT_EQ(2, [menu numberOfItems]);
+ for (NSMenuItem *item in [menu itemArray]) {
+ EXPECT_TRUE([[item title] isEqual:@"not"]);
+ }
+}
+
+// Test that AddNodeToMenu() properly adds bookmark nodes as menus,
+// including the recursive case.
+TEST_F(BookmarkMenuBridgeTest, TestAddNodeToMenu) {
+ Browser* browser = browser_test_helper_.GetBrowser();
+ Profile* profile = browser_test_helper_.GetProfile();
+
+ BookmarkMenuBridge *bridge = new BookmarkMenuBridge(browser);
+ EXPECT_TRUE(bridge);
+
+ NSMenu* menu = [[[NSMenu alloc] initWithTitle:@"foo"] autorelease];
+
+ BookmarkModel* model = new BookmarkModel(profile);
+ BookmarkNode* root = new BookmarkNode(model, GURL());
+ EXPECT_TRUE(model && root);
+
+ // 3 nodes; middle one has a child
+ BookmarkNode* node = NULL;
+ for (int x = 0; x < 3; x++) {
+ node = new BookmarkNode(model, (x==1 ? GURL() : GURL("http://foo")));
+ root->Add(x, node);
+ }
+ node = new BookmarkNode(model, GURL("http://sub"));
+ root->GetChild(1)->Add(0, node);
+
+ // Add to the NSMenu, then confirm it looks good
+ AddNodeToMenu(bridge, root, menu);
+
+ EXPECT_EQ(3, [menu numberOfItems]);
+ for (int x=0; x < 3; x++) {
+ NSMenuItem* item = [menu itemAtIndex:x];
+ NSInteger tag = [item tag];
+ EXPECT_TRUE((tag >= IDC_BOOKMARK_MENUITEM_BASE) &&
+ (tag < IDC_BOOKMARK_MENUITEM_MAX));
+ }
+ EXPECT_EQ(NO, [[menu itemAtIndex:0] hasSubmenu]);
+ EXPECT_EQ(NO, [[menu itemAtIndex:2] hasSubmenu]);
+ NSMenuItem* middle = [menu itemAtIndex:1];
+ EXPECT_NE(NO, [middle hasSubmenu]);
+ EXPECT_EQ(1, [[middle submenu] numberOfItems]);
+
+ delete root; // deletes all its kids
+ delete model;
+}
diff --git a/chrome/browser/cocoa/browser_test_helper.h b/chrome/browser/cocoa/browser_test_helper.h
new file mode 100644
index 0000000..6427547
--- /dev/null
+++ b/chrome/browser/cocoa/browser_test_helper.h
@@ -0,0 +1,38 @@
+// 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/browser.h"
+#include "chrome/browser/profile.h"
+#include "chrome/test/testing_profile.h"
+
+// Base class which contains a valid Browser*. Lots of boilerplate to
+// recycle between unit test classes.
+//
+// TODO(jrg): move up a level (chrome/browser/cocoa -->
+// chrome/browser), and use in non-Mac unit tests such as
+// back_forward_menu_model_unittest.cc,
+// navigation_controller_unittest.cc, ..
+class BrowserTestHelper {
+ public:
+ BrowserTestHelper() {
+ TestingProfile *testing_profile = new TestingProfile();
+ testing_profile->CreateBookmarkModel(true);
+ testing_profile->BlockUntilBookmarkModelLoaded();
+ profile_ = testing_profile;
+ browser_ = new Browser(Browser::TYPE_NORMAL, profile_);
+ }
+
+ ~BrowserTestHelper() {
+ delete browser_;
+ delete profile_;
+ }
+
+ Browser* GetBrowser() { return browser_; }
+ Profile* GetProfile() { return profile_; }
+
+ private:
+ Browser* browser_;
+ Profile* profile_;
+ MessageLoopForUI message_loop_;
+};
diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h
index a74ed8f..9f314ab 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/cocoa/browser_window_cocoa.h
@@ -7,9 +7,13 @@
#include "base/scoped_ptr.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/cocoa/bookmark_menu_bridge.h"
+class Browser;
@class BrowserWindowController;
@class NSWindow;
+@class NSMenu;
class StatusBubbleMac;
@@ -19,7 +23,9 @@ class StatusBubbleMac;
class BrowserWindowCocoa : public BrowserWindow {
public:
- BrowserWindowCocoa(BrowserWindowController* controller, NSWindow* window);
+ BrowserWindowCocoa(Browser* browser,
+ BrowserWindowController* controller,
+ NSWindow* window);
virtual ~BrowserWindowCocoa();
// Overridden from BrowserWindow
@@ -63,15 +69,17 @@ class BrowserWindowCocoa : public BrowserWindow {
virtual void ShowNewProfileDialog();
virtual void ShowHTMLDialog(HtmlDialogContentsDelegate* delegate,
void* parent_window);
+
protected:
virtual void DestroyBrowser();
private:
+ Browser* browser_;
BrowserWindowController* controller_; // weak, owns us
NSWindow* window_; // weak, owned by |controller_|
-
// The status bubble manager. Always non-NULL.
scoped_ptr<StatusBubbleMac> status_bubble_;
+ BookmarkMenuBridge bookmark_menu_bridge_;
};
#endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_COCOA_H_
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm
index b062a4f..0427a6b 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/cocoa/browser_window_cocoa.mm
@@ -6,11 +6,14 @@
#include "base/logging.h"
#include "chrome/browser/cocoa/browser_window_cocoa.h"
#include "chrome/browser/cocoa/browser_window_controller.h"
+#include "chrome/browser/browser.h"
#include "chrome/browser/cocoa/status_bubble_mac.h"
-BrowserWindowCocoa::BrowserWindowCocoa(BrowserWindowController* controller,
+BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
+ BrowserWindowController* controller,
NSWindow* window)
- : controller_(controller), window_(window) {
+ : browser_(browser), controller_(controller), window_(window),
+ bookmark_menu_bridge_(browser) {
status_bubble_.reset(new StatusBubbleMac(window_));
}
@@ -136,12 +139,18 @@ void BrowserWindowCocoa::FocusToolbar() {
}
bool BrowserWindowCocoa::IsBookmarkBarVisible() const {
- NOTIMPLEMENTED();
- return true;
+ // Conversion from ObjC BOOL to C++ bool.
+ return [controller_ isBookmarkBarVisible] ? true : false;
}
+// This is a little awkward. Internal to Chrome, V and C (in the MVC
+// sense) tend to smear together. Thus, we have a call chain of
+// C(browser_window)-->
+// V(me;right here)-->
+// C(BrowserWindowController)-->
+// C(TabStripController) --> ...
void BrowserWindowCocoa::ToggleBookmarkBar() {
- NOTIMPLEMENTED();
+ [controller_ toggleBookmarkBar];
}
void BrowserWindowCocoa::ShowFindBar() {
diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h
index eaf03a1..443a8d8 100644
--- a/chrome/browser/cocoa/browser_window_controller.h
+++ b/chrome/browser/cocoa/browser_window_controller.h
@@ -12,6 +12,7 @@
class Browser;
class BrowserWindow;
+class BrowserWindowCocoa;
class LocationBar;
class TabContents;
@class TabStripView;
@@ -22,7 +23,7 @@ class TabContents;
NSWindowController<NSUserInterfaceValidations> {
@private
Browser* browser_;
- BrowserWindow* windowShim_;
+ BrowserWindowCocoa* windowShim_;
TabStripController* tabStripController_;
IBOutlet NSBox* contentBox_;
@@ -70,6 +71,10 @@ class TabContents;
// Make the location bar the first responder, if possible.
- (void)focusLocationBar;
+- (BOOL)isBookmarkBarVisible;
+
+- (void)toggleBookmarkBar;
+
@end
#endif // CHROME_BROWSER_BROWSER_WINDOW_CONTROLLER_H_
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 8779fed..99499c7 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#import "chrome/app/chrome_dll_resource.h" // IDC_*
#import "chrome/browser/browser.h"
#import "chrome/browser/cocoa/browser_window_cocoa.h"
#import "chrome/browser/cocoa/browser_window_controller.h"
@@ -17,7 +18,8 @@
if ((self = [super initWithWindowNibName:@"BrowserWindow"])) {
browser_ = browser;
DCHECK(browser_);
- windowShim_ = new BrowserWindowCocoa(self, [self window]);
+ windowShim_ = new BrowserWindowCocoa(browser, self, [self window]);
+ windowShim_->Init();
}
return self;
}
@@ -40,12 +42,8 @@
// this window's Browser and the tab strip view. The controller will handle
// registering for the appropriate tab notifications from the back-end and
// managing the creation of new tabs.
- tabStripController_ =
- [[TabStripController alloc]
- initWithView:tabStripView_
- tabModel:browser_->tabstrip_model()
- toolbarModel:browser_->toolbar_model()
- commands:browser_->command_updater()];
+ tabStripController_ = [[TabStripController alloc]
+ initWithView:tabStripView_ browser:browser_];
// Place the tab bar above the content box and add it to the view hierarchy
// as a sibling of the content view so it can overlap with the window frame.
@@ -102,6 +100,27 @@
return YES;
}
+// Update a toggle state for an NSMenuItem if modified.
+// Take care to insure |item| looks like a NSMenuItem.
+// Called by validateUserInterfaceItem:.
+- (void)updateToggleStateWithTag:(NSInteger)tag forItem:(id)item {
+ if (![item respondsToSelector:@selector(state)] ||
+ ![item respondsToSelector:@selector(setState:)])
+ return;
+
+ // On Windows this logic happens in bookmark_bar_view.cc. On the
+ // Mac we're a lot more MVC happy so we've moved it into a
+ // controller. To be clear, this simply updates the menu item; it
+ // does not display the bookmark bar itself.
+ if (tag == IDC_SHOW_BOOKMARK_BAR) {
+ bool toggled = windowShim_->IsBookmarkBarVisible();
+ NSInteger oldState = [item state];
+ NSInteger newState = toggled ? NSOnState : NSOffState;
+ if (oldState != newState)
+ [item setState:newState];
+ }
+}
+
// Called to validate menu and toolbar items when this window is key. All the
// items we care about have been set with the |commandDispatch:| action and
// a target of FirstResponder in IB. If it's not one of those, let it
@@ -117,8 +136,15 @@
BOOL enable = NO;
if (action == @selector(commandDispatch:)) {
NSInteger tag = [item tag];
- if (browser_->command_updater()->SupportsCommand(tag))
+ if (browser_->command_updater()->SupportsCommand(tag)) {
+ // Generate return value (enabled state)
enable = browser_->command_updater()->IsCommandEnabled(tag) ? YES : NO;
+
+ // If the item is toggleable, find it's toggle state and
+ // try to update it. This is a little awkward, but the alternative is
+ // to check after a commandDispatch, which seems worse.
+ [self updateToggleStateWithTag:tag forItem:item];
+ }
}
return enable;
}
@@ -175,4 +201,14 @@
[tabStripController_ focusLocationBar];
}
+- (BOOL)isBookmarkBarVisible {
+ return [tabStripController_ isBookmarkBarVisible];
+
+}
+
+- (void)toggleBookmarkBar {
+ [tabStripController_ toggleBookmarkBar];
+}
+
+
@end
diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h
index bc97e4f..3a39b5d 100644
--- a/chrome/browser/cocoa/tab_contents_controller.h
+++ b/chrome/browser/cocoa/tab_contents_controller.h
@@ -7,8 +7,12 @@
#include <Cocoa/Cocoa.h>
-class CommandUpdater;
+@class BookmarkView;
@class GrowBoxView;
+@class ToolbarView;
+
+class BookmarkModel;
+class CommandUpdater;
class LocationBar;
class TabContents;
class TabContentsCommandObserver;
@@ -25,6 +29,9 @@ class ToolbarModel;
// As we hook things up, we'll see if this imposes other restrictions (such
// as command-handling or dispatch) that will require us to change the view
// layout.
+// TODO(jrg): Following on to pink's comments... each tab does in fact
+// have its own ToolbarView. Similarly, each also has its own
+// BookmarkView. That makes things marginally more expensive.
@interface TabContentsController : NSViewController {
@private
@@ -32,7 +39,15 @@ class ToolbarModel;
TabContentsCommandObserver* observer_; // nil if |commands_| is nil
LocationBar* locationBarBridge_;
TabContents* contents_; // weak
+
ToolbarModel* toolbarModel_; // weak, one per window
+ IBOutlet ToolbarView* toolbarView_;
+
+ BookmarkModel* bookmarkModel_; // weak; one per window
+
+ // TODO(jrg): write a BookmarkView
+ IBOutlet ToolbarView* /* BookmarkView* */ bookmarkView_;
+
IBOutlet NSButton* backButton_;
IBOutlet NSButton* forwardButton_;
IBOutlet NSButton* reloadButton_;
@@ -41,6 +56,10 @@ class ToolbarModel;
IBOutlet NSTextField* locationBar_;
IBOutlet NSBox* contentsBox_;
IBOutlet GrowBoxView* growBox_;
+
+ // The contents box will have an offset if shrunk to make room for
+ // the bookmark bar.
+ BOOL contentsBoxHasOffset_;
}
// Create the contents of a tab represented by |contents| and loaded from the
@@ -50,7 +69,8 @@ class ToolbarModel;
bundle:(NSBundle*)bundle
contents:(TabContents*)contents
commands:(CommandUpdater*)commands
- toolbarModel:(ToolbarModel*)toolbarModel;
+ toolbarModel:(ToolbarModel*)toolbarModel
+ bookmarkModel:(BookmarkModel*)bookmarkModel;
// Take this view (toolbar and web contents) full screen
- (IBAction)fullScreen:(id)sender;
@@ -86,6 +106,9 @@ class ToolbarModel;
// Make the location bar the first responder, if possible.
- (void)focusLocationBar;
+// Change the visibility state of the bookmark bar.
+- (void)toggleBookmarkBar:(BOOL)enable;
+
@end
#endif // CHROME_BROWSER_COCOA_TAB_COTNENTS_CONTROLLER_H_
diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm
index 69f3ba6..973e808 100644
--- a/chrome/browser/cocoa/tab_contents_controller.mm
+++ b/chrome/browser/cocoa/tab_contents_controller.mm
@@ -6,6 +6,7 @@
#import "base/sys_string_conversions.h"
#import "chrome/app/chrome_dll_resource.h"
+#import "chrome/browser/bookmarks/bookmark_model.h"
#import "chrome/browser/command_updater.h"
#import "chrome/browser/location_bar.h"
#import "chrome/browser/tab_contents/tab_contents.h"
@@ -30,6 +31,7 @@ static NSString* const kStarredImageName = @"starred";
@interface TabContentsController(Private)
- (void)updateToolbarCommandStatus;
+- (void)applyContentsBoxOffset:(BOOL)apply;
@end
// A C++ bridge class that handles listening for updates to commands and
@@ -78,7 +80,8 @@ class LocationBarBridge : public LocationBar {
bundle:(NSBundle*)bundle
contents:(TabContents*)contents
commands:(CommandUpdater*)commands
- toolbarModel:(ToolbarModel*)toolbarModel {
+ toolbarModel:(ToolbarModel*)toolbarModel
+ bookmarkModel:(BookmarkModel*)bookmarkModel {
if ((self = [super initWithNibName:name bundle:bundle])) {
commands_ = commands;
if (commands_)
@@ -86,6 +89,7 @@ class LocationBarBridge : public LocationBar {
locationBarBridge_ = new LocationBarBridge(self);
contents_ = contents;
toolbarModel_ = toolbarModel;
+ bookmarkModel_ = bookmarkModel;
}
return self;
}
@@ -100,6 +104,7 @@ class LocationBarBridge : public LocationBar {
- (void)awakeFromNib {
[contentsBox_ setContentView:contents_->GetNativeView()];
+ [self applyContentsBoxOffset:YES];
// Provide a starting point since we won't get notifications if the state
// doesn't change between tabs.
@@ -234,6 +239,47 @@ class LocationBarBridge : public LocationBar {
[goButton_ setImage:[NSImage imageNamed:imageName]];
}
+- (void)toggleBookmarkBar:(BOOL)enable {
+ contentsBoxHasOffset_ = enable;
+ [self applyContentsBoxOffset:enable];
+
+ if (enable) {
+ // TODO(jrg): display something useful in the bookmark bar
+ // TODO(jrg): use a BookmarksView, not a ToolbarView
+ // TODO(jrg): don't draw a border around it
+ // TODO(jrg): ...
+ }
+}
+
+// Apply a contents box offset to make (or remove) room for the
+// bookmark bar. If apply==YES, always make room (the contentsBox_ is
+// "full size"). If apply==NO we are trying to undo an offset. If no
+// offset there is nothing to undo.
+- (void)applyContentsBoxOffset:(BOOL)apply {
+
+ if (bookmarkView_ == nil) {
+ // We're too early, but awakeFromNib will call me again.
+ return;
+ }
+ if (!contentsBoxHasOffset_ && apply) {
+ // There is no offset to unconditionally apply.
+ return;
+ }
+
+ int offset = [bookmarkView_ frame].size.height;
+ NSRect frame = [contentsBox_ frame];
+ if (apply)
+ frame.size.height -= offset;
+ else
+ frame.size.height += offset;
+
+ // TODO(jrg): animate
+ [contentsBox_ setFrame:frame];
+
+ [bookmarkView_ setNeedsDisplay:YES];
+ [contentsBox_ setNeedsDisplay:YES];
+}
+
@end
//--------------------------------------------------------------------------
diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h
index b38bd19..0bd7df4 100644
--- a/chrome/browser/cocoa/tab_strip_controller.h
+++ b/chrome/browser/cocoa/tab_strip_controller.h
@@ -7,9 +7,13 @@
#import <Cocoa/Cocoa.h>
+@class TabStripView;
+@class BookmarkBarStateController;
+
+class BookmarkModel;
+class Browser;
class CommandUpdater;
class LocationBar;
-@class TabStripView;
class TabStripBridge;
class TabStripModel;
class TabContents;
@@ -34,6 +38,7 @@ class ToolbarModel;
TabStripBridge* bridge_;
TabStripModel* tabModel_; // weak
ToolbarModel* toolbarModel_; // weak, one per browser
+ BookmarkModel* bookmarkModel_; // weak, one per profile (= one per Browser*)
CommandUpdater* commands_; // weak, may be nil
// access to the TabContentsControllers (which own the parent view
// for the toolbar and associated tab contents) given an index. This needs
@@ -43,15 +48,15 @@ class ToolbarModel;
// an array of TabControllers which manage the actual tab views. As above,
// this is kept in the same order as the tab strip model.
NSMutableArray* tabArray_;
+
+ // Controller for bookmark bar state, shared among all TabContents.
+ BookmarkBarStateController* bookmarkBarStateController_;
}
-// Initialize the controller with a view, model, and command updater for
-// tracking what's enabled and disabled. |commands| may be nil if no updating
-// is desired.
+// Initialize the controller with a view and browser that contains
+// everything else we'll need.
- (id)initWithView:(TabStripView*)view
- tabModel:(TabStripModel*)tabModel
- toolbarModel:(ToolbarModel*)toolbarModel
- commands:(CommandUpdater*)commands;
+ browser:(Browser*)browser;
// Get the C++ bridge object representing the location bar for the current tab.
- (LocationBar*)locationBar;
@@ -76,6 +81,13 @@ class ToolbarModel;
// Make the location bar the first responder, if possible.
- (void)focusLocationBar;
+// Return a boolean (ObjC BOOL, not C++ bool) to say if the bookmark
+// bar is visible.
+- (BOOL)isBookmarkBarVisible;
+
+// Turn on or off the bookmark bar for *ALL* tabs.
+- (void)toggleBookmarkBar;
+
@end
#endif // CHROME_BROWSER_COCOA_TAB_STRIP_CONTROLLER_H_
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index b649d28..ce74d1c 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -6,6 +6,8 @@
#import "base/sys_string_conversions.h"
#import "chrome/app/chrome_dll_resource.h"
+#import "chrome/browser/browser.h"
+#import "chrome/browser/cocoa/bookmark_bar_state_controller.h"
#import "chrome/browser/cocoa/tab_strip_view.h"
#import "chrome/browser/cocoa/tab_cell.h"
#import "chrome/browser/cocoa/tab_contents_controller.h"
@@ -63,19 +65,19 @@ class TabStripBridge : public TabStripModelObserver {
@implementation TabStripController
- (id)initWithView:(TabStripView*)view
- tabModel:(TabStripModel*)tabModel
- toolbarModel:(ToolbarModel*)toolbarModel
- commands:(CommandUpdater*)commands {
- DCHECK(view && tabModel && toolbarModel);
+ browser:(Browser*)browser {
+ DCHECK(view && browser);
if ((self = [super init])) {
tabView_ = view;
- tabModel_ = tabModel;
- toolbarModel_ = toolbarModel;
- commands_ = commands;
- bridge_ = new TabStripBridge(tabModel, self);
+ tabModel_ = browser->tabstrip_model();
+ toolbarModel_ = browser->toolbar_model();
+ bookmarkModel_ = browser->profile()->GetBookmarkModel();
+ commands_ = browser->command_updater();
+ bridge_ = new TabStripBridge(tabModel_, self);
tabContentsArray_ = [[NSMutableArray alloc] init];
tabArray_ = [[NSMutableArray alloc] init];
-
+ bookmarkBarStateController_ = [[BookmarkBarStateController alloc]
+ initWithBrowser:browser];
// Take the only child view present in the nib as the new tab button. For
// some reason, if the view is present in the nib apriori, it draws
// correctly. If we create it in code and add it to the tab view, it draws
@@ -93,6 +95,7 @@ class TabStripBridge : public TabStripModelObserver {
- (void)dealloc {
delete bridge_;
+ [bookmarkBarStateController_ release];
[tabContentsArray_ release];
[tabArray_ release];
[super dealloc];
@@ -224,8 +227,11 @@ class TabStripBridge : public TabStripModelObserver {
bundle:nil
contents:contents
commands:commands_
- toolbarModel:toolbarModel_]
+ toolbarModel:toolbarModel_
+ bookmarkModel:bookmarkModel_]
autorelease];
+ if ([self isBookmarkBarVisible])
+ [contentsController toggleBookmarkBar:YES];
[tabContentsArray_ insertObject:contentsController atIndex:index];
// Make a new tab and add it to the strip. Keep track of its controller.
@@ -387,6 +393,21 @@ class TabStripBridge : public TabStripModelObserver {
[selectedController focusLocationBar];
}
+- (BOOL)isBookmarkBarVisible {
+ return [bookmarkBarStateController_ visible];
+}
+
+// Called from BrowserWindowController
+- (void)toggleBookmarkBar {
+ [bookmarkBarStateController_ toggleBookmarkBar];
+ BOOL visible = [self isBookmarkBarVisible];
+ for (TabContentsController *controller in tabContentsArray_) {
+ [controller toggleBookmarkBar:visible];
+ }
+
+}
+
+
@end
//--------------------------------------------------------------------------
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 95f80fa..b18012e 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -417,28 +417,6 @@ static const SkBitmap& GetGroupIcon() {
return *kFolderIcon;
}
-// static
-void BookmarkBarView::ToggleWhenVisible(Profile* profile) {
- PrefService* prefs = profile->GetPrefs();
- const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar);
-
- // The user changed when the bookmark bar is shown, update the preferences.
- prefs->SetBoolean(prefs::kShowBookmarkBar, always_show);
- prefs->ScheduleSavePersistentPrefs(g_browser_process->file_thread());
-
- // And notify the notification service.
- Source<Profile> source(profile);
- NotificationService::current()->Notify(
- NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
- source,
- NotificationService::NoDetails());
-}
-
-// static
-void BookmarkBarView::RegisterUserPrefs(PrefService* prefs) {
- prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, false);
-}
-
BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser)
: profile_(NULL),
browser_(browser),
@@ -1349,7 +1327,7 @@ bool BookmarkBarView::IsItemChecked(int id) const {
}
void BookmarkBarView::ExecuteCommand(int id) {
- ToggleWhenVisible(profile_);
+ bookmark_utils::ToggleWhenVisible(profile_);
}
void BookmarkBarView::Observe(NotificationType type,
diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h
index 358ce6f..0726449 100644
--- a/chrome/browser/views/bookmark_bar_view.h
+++ b/chrome/browser/views/bookmark_bar_view.h
@@ -74,12 +74,6 @@ class BookmarkBarView : public views::View,
explicit BookmarkBarView(Profile* profile, Browser* browser);
virtual ~BookmarkBarView();
- // Toggles whether the bookmark bar is shown only on the new tab page or on
- // all tabs.
- static void ToggleWhenVisible(Profile* profile);
-
- static void RegisterUserPrefs(PrefService* prefs);
-
// Resets the profile. This removes any buttons for the current profile and
// recreates the models.
void SetProfile(Profile* profile);
diff --git a/chrome/browser/views/bookmark_table_view.cc b/chrome/browser/views/bookmark_table_view.cc
index 3e82647..b080a92 100644
--- a/chrome/browser/views/bookmark_table_view.cc
+++ b/chrome/browser/views/bookmark_table_view.cc
@@ -50,15 +50,6 @@ BookmarkTableView::BookmarkTableView(Profile* profile,
UpdateColumns();
}
-// static
-void BookmarkTableView::RegisterUserPrefs(PrefService* prefs) {
- prefs->RegisterIntegerPref(prefs::kBookmarkTableNameWidth1, -1);
- prefs->RegisterIntegerPref(prefs::kBookmarkTableURLWidth1, -1);
- prefs->RegisterIntegerPref(prefs::kBookmarkTableNameWidth2, -1);
- prefs->RegisterIntegerPref(prefs::kBookmarkTableURLWidth2, -1);
- prefs->RegisterIntegerPref(prefs::kBookmarkTablePathWidth, -1);
-}
-
bool BookmarkTableView::CanDrop(const OSExchangeData& data) {
if (!parent_node_ || !profile_->GetBookmarkModel()->IsLoaded())
return false;
diff --git a/chrome/browser/views/bookmark_table_view.h b/chrome/browser/views/bookmark_table_view.h
index 272bba3..ab9b865 100644
--- a/chrome/browser/views/bookmark_table_view.h
+++ b/chrome/browser/views/bookmark_table_view.h
@@ -25,8 +25,6 @@ class BookmarkTableView : public views::TableView {
public:
BookmarkTableView(Profile* profile, BookmarkTableModel* model);
- static void RegisterUserPrefs(PrefService* prefs);
-
// Drag and drop methods.
virtual bool CanDrop(const OSExchangeData& data);
virtual void OnDragEntered(const views::DropTargetEvent& event);
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 7af2338..b405280 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -9,6 +9,7 @@
#include "base/time.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/app_modal_dialog_queue.h"
+#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/encoding_menu_controller_delegate.h"
@@ -781,7 +782,7 @@ void BrowserView::DisableInactiveFrame() {
}
void BrowserView::ToggleBookmarkBar() {
- BookmarkBarView::ToggleWhenVisible(browser_->profile());
+ bookmark_utils::ToggleWhenVisible(browser_->profile());
}
void BrowserView::ShowFindBar() {
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 65c2f4a..f772692 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -484,6 +484,11 @@
'browser/chrome_thread.h',
'browser/cocoa/base_view.h',
'browser/cocoa/base_view.mm',
+ 'browser/cocoa/bookmark_bar_state_controller.h',
+ 'browser/cocoa/bookmark_bar_state_controller.mm',
+ 'browser/cocoa/bookmark_menu_bridge.h',
+ 'browser/cocoa/bookmark_menu_bridge.mm',
+ 'browser/cocoa/browser_test_helper.h',
'browser/cocoa/browser_window_cocoa.h',
'browser/cocoa/browser_window_cocoa.mm',
'browser/cocoa/browser_window_controller.h',
@@ -1956,6 +1961,11 @@
'browser/debugger/devtools_manager_unittest.cc',
'browser/cache_manager_host_unittest.cc',
'browser/chrome_thread_unittest.cc',
+ # It is safe to list */cocoa/* files in the "common" file list
+ # without an explicit exclusion since gyp is smart enough to
+ # exclude them from non-Mac builds.
+ 'browser/cocoa/bookmark_bar_state_controller_unittest.mm',
+ 'browser/cocoa/bookmark_menu_bridge_unittest.mm',
'browser/command_updater_unittest.cc',
'browser/download/download_manager_unittest.cc',
'browser/download/download_request_manager_unittest.cc',
@@ -2092,10 +2102,6 @@
'views',
],
},],
- ['OS=="mac"', {
- # mac tests load the resources from the built app beside the test
- 'dependencies': ['app'],
- }],
['OS!="win"', {
'sources!': [
'browser/back_forward_menu_model_unittest.cc',
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 43a7efe..5037b50 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -376,11 +376,6 @@ class BookmarkEditorView {
}
};
-class BookmarkBarView {
- public:
- static void ToggleWhenVisible(Profile* profile) { NOTIMPLEMENTED(); }
-};
-
//---------------------------------------------------------------------------
// These stubs are for Browser
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index ea78459..3472e52 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/path_service.h"
#include "base/file_util.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/search_engines/template_url_model.h"
@@ -23,7 +24,6 @@
// TODO(port): Get rid of this section and finish porting.
#if defined(OS_WIN)
-#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/history/history.h"
#endif