summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 20:47:40 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 20:47:40 +0000
commitf26be845e5a2ac82133bae82c3e7429af1f52eb3 (patch)
tree24b2c7967c451b16a01e2e72be6feeb68997c9a2 /chrome
parentd6021e59dd2c10a8dc6caf46832101d542c8cc11 (diff)
downloadchromium_src-f26be845e5a2ac82133bae82c3e7429af1f52eb3.zip
chromium_src-f26be845e5a2ac82133bae82c3e7429af1f52eb3.tar.gz
chromium_src-f26be845e5a2ac82133bae82c3e7429af1f52eb3.tar.bz2
Revert 31284 - Added menu item for sync to wrench menu.
Wrench menu item is right above "Preferences...". Chrome menu item will be added in a future CL right above "Clear Browsing Data...". Sync menu items are hidden if bookmark sync is disabled (the current default for OS X). UI decisions were made after consulting with Cole. Added code in browser_window_controller.mm to update sync menu item dynamically. Added unit tests. BUG=23073 TEST=manual testing, trybots, unittests Review URL: http://codereview.chromium.org/363017 TBR=akalin@chromium.org Review URL: http://codereview.chromium.org/374017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/nibs/Toolbar.xib57
-rw-r--r--chrome/browser/cocoa/browser_window_controller.h7
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm67
-rw-r--r--chrome/browser/cocoa/browser_window_controller_unittest.mm75
4 files changed, 4 insertions, 202 deletions
diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib
index 06b94b1..92ba964 100644
--- a/chrome/app/nibs/Toolbar.xib
+++ b/chrome/app/nibs/Toolbar.xib
@@ -2,13 +2,12 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9L31a</string>
+ <string key="IBDocument.SystemVersion">9L30</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.54</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="48"/>
<integer value="42"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
@@ -643,28 +642,6 @@
<reference key="NSOnImage" ref="610745052"/>
<reference key="NSMixedImage" ref="1070349142"/>
</object>
- <object class="NSMenuItem" id="141550343">
- <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="610745052"/>
- <reference key="NSMixedImage" ref="1070349142"/>
- <int key="NSTag">41108</int>
- </object>
- <object class="NSMenuItem" id="892721848">
- <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="610745052"/>
- <reference key="NSMixedImage" ref="1070349142"/>
- </object>
<object class="NSMenuItem" id="510846575">
<reference key="NSMenu" ref="558188039"/>
<string key="NSTitle">^IDS_PREFERENCES_MAC</string>
@@ -1053,14 +1030,6 @@
</object>
<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="141550343"/>
- </object>
- <int key="connectionID">142</int>
- </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1292,8 +1261,6 @@
<reference ref="922630377"/>
<reference ref="510846575"/>
<reference ref="306298564"/>
- <reference ref="141550343"/>
- <reference ref="892721848"/>
</object>
<reference key="parent" ref="465075988"/>
</object>
@@ -1514,16 +1481,6 @@
<reference key="object" ref="306232897"/>
<reference key="parent" ref="465075988"/>
</object>
- <object class="IBObjectRecord">
- <int key="objectID">140</int>
- <reference key="object" ref="141550343"/>
- <reference key="parent" ref="558188039"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">141</int>
- <reference key="object" ref="892721848"/>
- <reference key="parent" ref="558188039"/>
- </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1552,8 +1509,6 @@
<string>13.IBPluginDependency</string>
<string>14.CustomClassName</string>
<string>14.IBPluginDependency</string>
- <string>140.IBPluginDependency</string>
- <string>141.IBPluginDependency</string>
<string>15.CustomClassName</string>
<string>15.IBPluginDependency</string>
<string>2.CustomClassName</string>
@@ -1649,8 +1604,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>ClickHoldButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>DelayedMenuButton</string>
@@ -1710,12 +1663,12 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>AutocompleteTextField</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{1454, 785}, {235, 293}}</string>
+ <string>{{979, 432}, {235, 293}}</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>{{362, 493}, {335, 263}}</string>
+ <string>{{362, 523}, {306, 233}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1793,7 +1746,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">142</int>
+ <int key="maxID">139</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2029,7 +1982,6 @@
<string>customPagesArrayController_</string>
<string>downloadLocationButton_</string>
<string>downloadLocationControl_</string>
- <string>enableLoggingCheckbox_</string>
<string>personalStuffGroupAutofill_</string>
<string>personalStuffGroupBrowserData_</string>
<string>personalStuffGroupPasswords_</string>
@@ -2051,7 +2003,6 @@
<string>NSArrayController</string>
<string>NSButton</string>
<string>NSPathControl</string>
- <string>NSButton</string>
<string>NSArray</string>
<string>NSArray</string>
<string>NSArray</string>
diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h
index de3451d..49ebe34 100644
--- a/chrome/browser/cocoa/browser_window_controller.h
+++ b/chrome/browser/cocoa/browser_window_controller.h
@@ -19,7 +19,6 @@
#import "chrome/browser/cocoa/bookmark_bubble_controller.h"
#import "chrome/browser/cocoa/browser_command_executor.h"
#import "chrome/browser/cocoa/view_resizer.h"
-#include "chrome/browser/sync/sync_status_ui_helper.h"
#import "third_party/GTM/AppKit/GTMTheme.h"
class Browser;
@@ -185,12 +184,6 @@ class TabStripModelObserverBridge;
// Return a point suitable for the topLeft for a bookmark bubble.
- (NSPoint)topLeftForBubble;
-// Updates a bookmark sync UI item (expected to be a menu item). This is
-// called every time the menu containing the sync UI item is displayed.
-- (void)updateSyncItem:(id)syncItem
- syncEnabled:(BOOL)syncEnabled
- status:(SyncStatusUIHelper::MessageType)status;
-
@end // BrowserWindowController(TestingAPI)
#endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index ef50ceb..f310c07 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -4,7 +4,6 @@
#include <Carbon/Carbon.h>
-#include "app/l10n_util_mac.h"
#include "base/mac_util.h"
#include "base/scoped_nsdisable_screen_updates.h"
#import "base/scoped_nsobject.h"
@@ -40,10 +39,8 @@
#import "chrome/browser/cocoa/tab_view.h"
#import "chrome/browser/cocoa/toolbar_controller.h"
#import "chrome/browser/browser_theme_provider.h"
-#include "chrome/browser/sync/sync_status_ui_helper.h"
#include "chrome/common/pref_service.h"
#import "chrome/browser/cocoa/background_gradient_view.h"
-#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#import "third_party/GTM/AppKit/GTMTheme.h"
@@ -582,19 +579,6 @@ willPositionSheet:(NSWindow*)sheet
case IDC_FULLSCREEN:
enable &= [self supportsFullscreen];
break;
- case IDC_SYNC_BOOKMARKS:
- {
- Profile* profile = browser_->profile()->GetOriginalProfile();
- ProfileSyncService* syncService = profile->GetProfileSyncService();
- // TODO(timsteele): Need a ui helper method to just get the type
- // without needing labels.
- string16 label, link;
- SyncStatusUIHelper::MessageType status =
- SyncStatusUIHelper::GetLabels(syncService, &label, &link);
- enable &= (syncService != NULL);
- [self updateSyncItem:item syncEnabled:enable status:status];
- }
- break;
default:
// Special handling for the contents of the Text Encoding submenu. On
// Mac OS, instead of enabling/disabling the top-level menu item, we
@@ -615,57 +599,6 @@ willPositionSheet:(NSWindow*)sheet
return enable;
}
-// TODO(akalin): We need to add a menu item to the main Chrome menu (near
-// "Clear browsing data..."). However, this is tricky as no browsers may
-// actually be open. Refactor the sync UI code so that it doesn't depend
-// on a browser being present.
-
-- (void)updateSyncItem:(id)syncItem
- syncEnabled:(BOOL)syncEnabled
- status:(SyncStatusUIHelper::MessageType)status {
- DCHECK([syncItem isKindOfClass:[NSMenuItem class]]);
- NSMenuItem* syncMenuItem = (NSMenuItem*)syncItem;
- // Look for a separator immediately after the menu item.
- NSMenuItem* followingSeparator = nil;
- NSMenu* menu = [syncItem menu];
- if (menu) {
- NSInteger syncItemIndex = [menu indexOfItem:syncMenuItem];
- DCHECK_NE(syncItemIndex, -1);
- if ((syncItemIndex + 1) < [menu numberOfItems]) {
- NSMenuItem* menuItem = [menu itemAtIndex:(syncItemIndex + 1)];
- if ([menuItem isSeparatorItem]) {
- followingSeparator = menuItem;
- }
- }
- }
-
- // TODO(akalin): consolidate this code with the equivalent Windows code in
- // chrome/browser/views/toolbar_view.cc.
- int titleId;
- switch (status) {
- case SyncStatusUIHelper::SYNCED:
- titleId = IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL;
- break;
- case SyncStatusUIHelper::SYNC_ERROR:
- titleId = IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL;
- break;
- case SyncStatusUIHelper::PRE_SYNCED:
- titleId = IDS_SYNC_START_SYNC_BUTTON_LABEL;
- break;
- default:
- NOTREACHED();
- break;
- }
- NSString* title = l10n_util::GetNSStringWithFixup(titleId);
- [syncMenuItem setTitle:title];
-
- // If we don't have a sync service, hide any sync-related menu
- // items. However, sync_menu_item is enabled/disabled outside of this
- // function so we don't touch it here, and separators are always disabled.
- [syncMenuItem setHidden:!syncEnabled];
- [followingSeparator setHidden:!syncEnabled];
-}
-
// Called when the user picks a menu or toolbar item when this window is key.
// Calls through to the browser object to execute the command. This assumes that
// the command is supported and doesn't check, otherwise it would have been
diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm
index e2b7451..b5f504e 100644
--- a/chrome/browser/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/browser_window_controller_unittest.mm
@@ -2,23 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "app/l10n_util_mac.h"
#include "base/scoped_nsobject.h"
#include "base/scoped_nsautorelease_pool.h"
#include "base/scoped_ptr.h"
-#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/cocoa/browser_test_helper.h"
#include "chrome/browser/cocoa/browser_window_controller.h"
#include "chrome/browser/cocoa/cocoa_test_helper.h"
#include "chrome/browser/cocoa/find_bar_bridge.h"
-#include "chrome/browser/sync/sync_status_ui_helper.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/test/testing_browser_process.h"
#include "chrome/test/testing_profile.h"
-#include "grit/generated_resources.h"
@interface BrowserWindowController (JustForTesting)
// Already defined in BWC.
@@ -433,77 +429,6 @@ TEST_F(BrowserWindowControllerTest, TestFindBarOnTop) {
EXPECT_GT(findBar_index, bookmark_index);
}
-TEST_F(BrowserWindowControllerTest, TestSyncMenuItem) {
- scoped_nsobject<NSMenuItem> syncMenuItem(
- [[NSMenuItem alloc] initWithTitle:@""
- action:@selector(commandDispatch)
- keyEquivalent:@""]);
- [syncMenuItem setTag:IDC_SYNC_BOOKMARKS];
-
- NSString* bookmarksSynced =
- l10n_util::GetNSStringWithFixup(IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL);
- NSString* bookmarkSyncError =
- l10n_util::GetNSStringWithFixup(IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL);
- NSString* startSync =
- l10n_util::GetNSStringWithFixup(IDS_SYNC_START_SYNC_BUTTON_LABEL);
-
- [syncMenuItem setTitle:@""];
- [syncMenuItem setHidden:NO];
- [controller_ updateSyncItem:syncMenuItem
- syncEnabled:NO
- status:SyncStatusUIHelper::PRE_SYNCED];
- EXPECT_TRUE([[syncMenuItem title] isEqualTo:startSync]);
- EXPECT_TRUE([syncMenuItem isHidden]);
-
- [syncMenuItem setTitle:@""];
- [syncMenuItem setHidden:YES];
- [controller_ updateSyncItem:syncMenuItem
- syncEnabled:YES
- status:SyncStatusUIHelper::SYNC_ERROR];
- EXPECT_TRUE([[syncMenuItem title] isEqualTo:bookmarkSyncError]);
- EXPECT_FALSE([syncMenuItem isHidden]);
-
- [syncMenuItem setTitle:@""];
- [syncMenuItem setHidden:NO];
- [controller_ updateSyncItem:syncMenuItem
- syncEnabled:NO
- status:SyncStatusUIHelper::SYNCED];
- EXPECT_TRUE([[syncMenuItem title] isEqualTo:bookmarksSynced]);
- EXPECT_TRUE([syncMenuItem isHidden]);
-}
-
-TEST_F(BrowserWindowControllerTest, TestSyncMenuItemWithSeparator) {
- scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@""]);
- NSMenuItem* syncMenuItem =
- [menu addItemWithTitle:@""
- action:@selector(commandDispatch)
- keyEquivalent:@""];
- [syncMenuItem setTag:IDC_SYNC_BOOKMARKS];
- NSMenuItem* following_separator = [NSMenuItem separatorItem];
- [menu addItem:following_separator];
-
- const SyncStatusUIHelper::MessageType kStatus =
- SyncStatusUIHelper::PRE_SYNCED;
-
- [syncMenuItem setHidden:NO];
- [following_separator setHidden:NO];
- [controller_ updateSyncItem:syncMenuItem
- syncEnabled:NO
- status:kStatus];
- EXPECT_FALSE([following_separator isEnabled]);
- EXPECT_TRUE([syncMenuItem isHidden]);
- EXPECT_TRUE([following_separator isHidden]);
-
- [syncMenuItem setHidden:YES];
- [following_separator setHidden:YES];
- [controller_ updateSyncItem:syncMenuItem
- syncEnabled:YES
- status:kStatus];
- EXPECT_FALSE([following_separator isEnabled]);
- EXPECT_FALSE([syncMenuItem isHidden]);
- EXPECT_FALSE([following_separator isHidden]);
-}
-
@interface BrowserWindowControllerFakeFullscreen : BrowserWindowController {
@private
// We release the window ourselves, so we don't have to rely on the unittest