diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 15:49:40 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 15:49:40 +0000 |
commit | 44cbd9e3734527f73a83f8a864be0bb5ccae0a7a (patch) | |
tree | a997fb0565558d63e0eab62b631ef984de3e9596 /chrome/browser/ui/cocoa | |
parent | 0c1c047d641a599ffffa280ab50d564cedb3e436 (diff) | |
download | chromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.zip chromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.tar.gz chromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.tar.bz2 |
Move models from app to ui/base/models
BUG=none
TEST=none
TBR=brettw
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/cocoa')
22 files changed, 118 insertions, 107 deletions
diff --git a/chrome/browser/ui/cocoa/accelerators_cocoa.h b/chrome/browser/ui/cocoa/accelerators_cocoa.h index 9b0a555..c4c5521 100644 --- a/chrome/browser/ui/cocoa/accelerators_cocoa.h +++ b/chrome/browser/ui/cocoa/accelerators_cocoa.h @@ -8,7 +8,7 @@ #include <map> -#include "app/menus/accelerator_cocoa.h" +#include "ui/base/models/accelerator_cocoa.h" template <typename T> struct DefaultSingletonTraits; @@ -26,10 +26,10 @@ template <typename T> struct DefaultSingletonTraits; // class AcceleratorsCocoa { public: - typedef std::map<int, menus::AcceleratorCocoa> AcceleratorCocoaMap; + typedef std::map<int, ui::AcceleratorCocoa> AcceleratorCocoaMap; // Returns NULL if there is no accelerator for the command. - const menus::AcceleratorCocoa* GetAcceleratorForCommand(int command_id); + const ui::AcceleratorCocoa* GetAcceleratorForCommand(int command_id); // Returns the singleton instance. static AcceleratorsCocoa* GetInstance(); diff --git a/chrome/browser/ui/cocoa/accelerators_cocoa.mm b/chrome/browser/ui/cocoa/accelerators_cocoa.mm index 6f28a0f..f62bd50 100644 --- a/chrome/browser/ui/cocoa/accelerators_cocoa.mm +++ b/chrome/browser/ui/cocoa/accelerators_cocoa.mm @@ -44,7 +44,7 @@ const struct AcceleratorMapping { AcceleratorsCocoa::AcceleratorsCocoa() { for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) { const AcceleratorMapping& entry = kAcceleratorMap[i]; - menus::AcceleratorCocoa accelerator(entry.key, entry.modifiers); + ui::AcceleratorCocoa accelerator(entry.key, entry.modifiers); accelerators_.insert(std::make_pair(entry.command_id, accelerator)); } } @@ -54,7 +54,7 @@ AcceleratorsCocoa* AcceleratorsCocoa::GetInstance() { return Singleton<AcceleratorsCocoa>::get(); } -const menus::AcceleratorCocoa* AcceleratorsCocoa::GetAcceleratorForCommand( +const ui::AcceleratorCocoa* AcceleratorsCocoa::GetAcceleratorForCommand( int command_id) { AcceleratorCocoaMap::iterator it = accelerators_.find(command_id); if (it == accelerators_.end()) diff --git a/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm b/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm index ef1436d..2a39ffe 100644 --- a/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm +++ b/chrome/browser/ui/cocoa/accelerators_cocoa_unittest.mm @@ -4,16 +4,16 @@ #import <Cocoa/Cocoa.h> -#include "app/menus/accelerator_cocoa.h" #include "base/singleton.h" #include "chrome/app/chrome_command_ids.h" #import "chrome/browser/ui/cocoa/accelerators_cocoa.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest_mac.h" +#include "ui/base/models/accelerator_cocoa.h" TEST(AcceleratorsCocoaTest, GetAccelerator) { AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance(); - const menus::AcceleratorCocoa* accelerator = + const ui::AcceleratorCocoa* accelerator = keymap->GetAcceleratorForCommand(IDC_COPY); ASSERT_TRUE(accelerator); EXPECT_NSEQ(@"c", accelerator->characters()); @@ -22,7 +22,7 @@ TEST(AcceleratorsCocoaTest, GetAccelerator) { TEST(AcceleratorsCocoaTest, GetNullAccelerator) { AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance(); - const menus::AcceleratorCocoa* accelerator = + const ui::AcceleratorCocoa* accelerator = keymap->GetAcceleratorForCommand(314159265); EXPECT_FALSE(accelerator); } diff --git a/chrome/browser/ui/cocoa/content_exceptions_window_controller.mm b/chrome/browser/ui/cocoa/content_exceptions_window_controller.mm index c85ceab..1adf875 100644 --- a/chrome/browser/ui/cocoa/content_exceptions_window_controller.mm +++ b/chrome/browser/ui/cocoa/content_exceptions_window_controller.mm @@ -6,7 +6,6 @@ #include "app/l10n_util.h" #include "app/l10n_util_mac.h" -#include "app/table_model_observer.h" #include "base/command_line.h" #import "base/mac/mac_util.h" #import "base/scoped_nsobject.h" @@ -17,6 +16,7 @@ #include "chrome/common/notification_service.h" #include "grit/generated_resources.h" #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" +#include "ui/base/models/table_model_observer.h" @interface ContentExceptionsWindowController (Private) - (id)initWithType:(ContentSettingsType)settingsType diff --git a/chrome/browser/ui/cocoa/cookie_tree_node.h b/chrome/browser/ui/cocoa/cookie_tree_node.h index ec1b2d2..400244c 100644 --- a/chrome/browser/ui/cocoa/cookie_tree_node.h +++ b/chrome/browser/ui/cocoa/cookie_tree_node.h @@ -24,7 +24,7 @@ // Common getters.. - (NSString*)title; - (CocoaCookieDetailsType)nodeType; -- (TreeModelNode*)treeNode; +- (ui::TreeModelNode*)treeNode; // |-mutableChildren| exists so that the CookiesTreeModelObserverBridge can // operate on the children. Note that this lazily creates children. diff --git a/chrome/browser/ui/cocoa/cookie_tree_node.mm b/chrome/browser/ui/cocoa/cookie_tree_node.mm index fa4da84..eeddadd 100644 --- a/chrome/browser/ui/cocoa/cookie_tree_node.mm +++ b/chrome/browser/ui/cocoa/cookie_tree_node.mm @@ -33,7 +33,7 @@ return [details_.get() type]; } -- (TreeModelNode*)treeNode { +- (ui::TreeModelNode*)treeNode { return treeNode_; } diff --git a/chrome/browser/ui/cocoa/cookies_window_controller.h b/chrome/browser/ui/cocoa/cookies_window_controller.h index 658bfa7..85d8b3e 100644 --- a/chrome/browser/ui/cocoa/cookies_window_controller.h +++ b/chrome/browser/ui/cocoa/cookies_window_controller.h @@ -14,13 +14,16 @@ @class CookiesWindowController; @class CookieDetailsViewController; class Profile; -class TreeModel; -class TreeModelNode; namespace { class CookiesWindowControllerTest; } +namespace ui { +class TreeModel; +class TreeModelNode; +} + // Thin bridge to the window controller that performs model update actions // directly on the treeController_. class CookiesTreeModelObserverBridge : public CookiesTreeModel::Observer { @@ -28,15 +31,15 @@ class CookiesTreeModelObserverBridge : public CookiesTreeModel::Observer { explicit CookiesTreeModelObserverBridge(CookiesWindowController* controller); // Begin TreeModelObserver implementation. - virtual void TreeNodesAdded(TreeModel* model, - TreeModelNode* parent, + virtual void TreeNodesAdded(ui::TreeModel* model, + ui::TreeModelNode* parent, int start, int count); - virtual void TreeNodesRemoved(TreeModel* model, - TreeModelNode* parent, + virtual void TreeNodesRemoved(ui::TreeModel* model, + ui::TreeModelNode* parent, int start, int count); - virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node); + virtual void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node); // End TreeModelObserver implementation. virtual void TreeModelBeginBatch(CookiesTreeModel* model); @@ -51,12 +54,12 @@ class CookiesTreeModelObserverBridge : public CookiesTreeModel::Observer { // Creates a CocoaCookieTreeNode from a platform-independent one. // Return value is autoreleased. This creates child nodes recusively. - CocoaCookieTreeNode* CocoaNodeFromTreeNode(TreeModelNode* node); + CocoaCookieTreeNode* CocoaNodeFromTreeNode(ui::TreeModelNode* node); // Finds the Cocoa model node based on a platform-independent one. This is // done by comparing the treeNode pointers. |start| is the node to start // searching at. If |start| is nil, the root is used. - CocoaCookieTreeNode* FindCocoaNode(TreeModelNode* node, + CocoaCookieTreeNode* FindCocoaNode(ui::TreeModelNode* node, CocoaCookieTreeNode* start); // Returns whether or not the Cocoa tree model is built. diff --git a/chrome/browser/ui/cocoa/cookies_window_controller.mm b/chrome/browser/ui/cocoa/cookies_window_controller.mm index 5e5f74f..33cb858 100644 --- a/chrome/browser/ui/cocoa/cookies_window_controller.mm +++ b/chrome/browser/ui/cocoa/cookies_window_controller.mm @@ -31,8 +31,8 @@ CookiesTreeModelObserverBridge::CookiesTreeModelObserverBridge( } // Notification that nodes were added to the specified parent. -void CookiesTreeModelObserverBridge::TreeNodesAdded(TreeModel* model, - TreeModelNode* parent, +void CookiesTreeModelObserverBridge::TreeNodesAdded(ui::TreeModel* model, + ui::TreeModelNode* parent, int start, int count) { // We're in for a major rebuild. Ignore this request. @@ -53,8 +53,8 @@ void CookiesTreeModelObserverBridge::TreeNodesAdded(TreeModel* model, } // Notification that nodes were removed from the specified parent. -void CookiesTreeModelObserverBridge::TreeNodesRemoved(TreeModel* model, - TreeModelNode* parent, +void CookiesTreeModelObserverBridge::TreeNodesRemoved(ui::TreeModel* model, + ui::TreeModelNode* parent, int start, int count) { // We're in for a major rebuild. Ignore this request. @@ -71,8 +71,8 @@ void CookiesTreeModelObserverBridge::TreeNodesRemoved(TreeModel* model, } // Notification that the contents of a node has changed. -void CookiesTreeModelObserverBridge::TreeNodeChanged(TreeModel* model, - TreeModelNode* node) { +void CookiesTreeModelObserverBridge::TreeNodeChanged(ui::TreeModel* model, + ui::TreeModelNode* node) { // If we don't have a Cocoa model, only let the root node change. if (batch_update_ || (!HasCocoaModel() && model->GetRoot() != node)) return; @@ -107,7 +107,7 @@ void CookiesTreeModelObserverBridge::InvalidateCocoaModel() { } CocoaCookieTreeNode* CookiesTreeModelObserverBridge::CocoaNodeFromTreeNode( - TreeModelNode* node) { + ui::TreeModelNode* node) { CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); return [[[CocoaCookieTreeNode alloc] initWithNode:cookie_node] autorelease]; } @@ -116,7 +116,7 @@ CocoaCookieTreeNode* CookiesTreeModelObserverBridge::CocoaNodeFromTreeNode( // commonly used to find origin/folder nodes, which are at the first level off // the root (hence breadth-first search). CocoaCookieTreeNode* CookiesTreeModelObserverBridge::FindCocoaNode( - TreeModelNode* target, CocoaCookieTreeNode* start) { + ui::TreeModelNode* target, CocoaCookieTreeNode* start) { if (!start) { start = [window_controller_ cocoaTreeModel]; } diff --git a/chrome/browser/ui/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/ui/cocoa/cookies_window_controller_unittest.mm index 5272cd2..0cd8d1d8 100644 --- a/chrome/browser/ui/cocoa/cookies_window_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/cookies_window_controller_unittest.mm @@ -5,7 +5,6 @@ #import <Cocoa/Cocoa.h> #include "app/l10n_util_mac.h" -#include "app/tree_model.h" #import "base/scoped_nsobject.h" #include "base/scoped_ptr.h" #include "base/utf_string_conversions.h" @@ -28,23 +27,24 @@ #import "testing/gtest_mac.h" #include "testing/platform_test.h" #import "third_party/ocmock/OCMock/OCMock.h" +#include "ui/base/models/tree_model.h" // Used to test FindCocoaNode. This only sets the title and node, without // initializing any other members. @interface FakeCocoaCookieTreeNode : CocoaCookieTreeNode { - TreeModelNode* testNode_; + ui::TreeModelNode* testNode_; } -- (id)initWithTreeNode:(TreeModelNode*)node; +- (id)initWithTreeNode:(ui::TreeModelNode*)node; @end @implementation FakeCocoaCookieTreeNode -- (id)initWithTreeNode:(TreeModelNode*)node { +- (id)initWithTreeNode:(ui::TreeModelNode*)node { if ((self = [super init])) { testNode_ = node; children_.reset([[NSMutableArray alloc] init]); } return self; } -- (TreeModelNode*)treeNode { +- (ui::TreeModelNode*)treeNode { return testNode_; } @end @@ -73,11 +73,11 @@ class CookiesWindowControllerTest : public CocoaTest { CocoaTest::TearDown(); } - CocoaCookieTreeNode* CocoaNodeFromTreeNode(TreeModelNode* node) { + CocoaCookieTreeNode* CocoaNodeFromTreeNode(ui::TreeModelNode* node) { return [controller_ modelObserver]->CocoaNodeFromTreeNode(node); } - CocoaCookieTreeNode* FindCocoaNode(TreeModelNode* node, + CocoaCookieTreeNode* FindCocoaNode(ui::TreeModelNode* node, CocoaCookieTreeNode* start) { return [controller_ modelObserver]->FindCocoaNode(node, start); } @@ -98,16 +98,20 @@ TEST_F(CookiesWindowControllerTest, Construction) { } TEST_F(CookiesWindowControllerTest, FindCocoaNodeRoot) { - scoped_ptr< TreeNodeWithValue<int> > search(new TreeNodeWithValue<int>(42)); + scoped_ptr< ui::TreeNodeWithValue<int> > search( + new TreeNodeWithValue<int>(42)); scoped_nsobject<FakeCocoaCookieTreeNode> node( [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:search.get()]); EXPECT_EQ(node.get(), FindCocoaNode(search.get(), node.get())); } TEST_F(CookiesWindowControllerTest, FindCocoaNodeImmediateChild) { - scoped_ptr< TreeNodeWithValue<int> > parent(new TreeNodeWithValue<int>(100)); - scoped_ptr< TreeNodeWithValue<int> > child1(new TreeNodeWithValue<int>(10)); - scoped_ptr< TreeNodeWithValue<int> > child2(new TreeNodeWithValue<int>(20)); + scoped_ptr< ui::TreeNodeWithValue<int> > parent( + new TreeNodeWithValue<int>(100)); + scoped_ptr< ui::TreeNodeWithValue<int> > child1( + new TreeNodeWithValue<int>(10)); + scoped_ptr< ui::TreeNodeWithValue<int> > child2( + new TreeNodeWithValue<int>(20)); scoped_nsobject<FakeCocoaCookieTreeNode> cocoaParent( [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:parent.get()]); scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild1( @@ -121,9 +125,12 @@ TEST_F(CookiesWindowControllerTest, FindCocoaNodeImmediateChild) { } TEST_F(CookiesWindowControllerTest, FindCocoaNodeRecursive) { - scoped_ptr< TreeNodeWithValue<int> > parent(new TreeNodeWithValue<int>(100)); - scoped_ptr< TreeNodeWithValue<int> > child1(new TreeNodeWithValue<int>(10)); - scoped_ptr< TreeNodeWithValue<int> > child2(new TreeNodeWithValue<int>(20)); + scoped_ptr< ui::TreeNodeWithValue<int> > parent( + new TreeNodeWithValue<int>(100)); + scoped_ptr< ui::TreeNodeWithValue<int> > child1( + new TreeNodeWithValue<int>(10)); + scoped_ptr< ui::TreeNodeWithValue<int> > child2( + new TreeNodeWithValue<int>(20)); scoped_nsobject<FakeCocoaCookieTreeNode> cocoaParent( [[FakeCocoaCookieTreeNode alloc] initWithTreeNode:parent.get()]); scoped_nsobject<FakeCocoaCookieTreeNode> cocoaChild1( @@ -142,7 +149,8 @@ TEST_F(CookiesWindowControllerTest, CocoaNodeFromTreeNodeCookie) { CookiesTreeModel model(cm, database_helper_, local_storage_helper_, nil, nil); // Root --> foo.com --> Cookies --> A. Create node for 'A'. - TreeModelNode* node = model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0); + ui::TreeModelNode* node = + model.GetRoot()->GetChild(0)->GetChild(0)->GetChild(0); CocoaCookieTreeNode* cookie = CocoaNodeFromTreeNode(node); CocoaCookieDetails* details = [cookie details]; diff --git a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h index 6acc829..252f557 100644 --- a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h +++ b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.h @@ -4,7 +4,6 @@ #import <Cocoa/Cocoa.h> -#include "app/table_model_observer.h" #import "base/mac/cocoa_protocols.h" #include "base/scoped_ptr.h" #include "base/string16.h" @@ -12,6 +11,7 @@ #include "chrome/browser/search_engines/keyword_editor_controller.h" #include "chrome/browser/search_engines/template_url_model_observer.h" #include "chrome/browser/ui/cocoa/table_row_nsimage_cache.h" +#include "ui/base/models/table_model_observer.h" class EditSearchEngineControllerDelegate; @class KeywordEditorCocoaController; @@ -21,7 +21,7 @@ class Profile; // Very thin bridge that simply pushes notifications from C++ to ObjC. class KeywordEditorModelObserver : public TemplateURLModelObserver, public EditSearchEngineControllerDelegate, - public TableModelObserver, + public ui::TableModelObserver, public TableRowNSImageCache::Table { public: explicit KeywordEditorModelObserver(KeywordEditorCocoaController* controller); @@ -40,7 +40,7 @@ class KeywordEditorModelObserver : public TemplateURLModelObserver, const string16& keyword, const std::string& url); - // TableModelObserver overrides. Invalidate icon cache. + // ui::TableModelObserver overrides. Invalidate icon cache. virtual void OnModelChanged(); virtual void OnItemsChanged(int start, int length); virtual void OnItemsAdded(int start, int length); diff --git a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm index 2ae0fa6..64ce03c 100644 --- a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm +++ b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm @@ -293,7 +293,7 @@ static base::LazyInstance<ProfileControllerMap> g_profile_controller_map( row:(NSInteger)row { if ([self tableView:tv isGroupRow:row]) { DCHECK(!tableColumn); - TableModel::Groups groups = controller_->table_model()->GetGroups(); + ui::TableModel::Groups groups = controller_->table_model()->GetGroups(); if (row == 0) { return base::SysUTF16ToNSString(groups[0].title); } else { diff --git a/chrome/browser/ui/cocoa/menu_controller.h b/chrome/browser/ui/cocoa/menu_controller.h index c198c70..4be9b0d 100644 --- a/chrome/browser/ui/cocoa/menu_controller.h +++ b/chrome/browser/ui/cocoa/menu_controller.h @@ -10,7 +10,7 @@ #include "base/scoped_nsobject.h" -namespace menus { +namespace ui { class MenuModel; } @@ -22,12 +22,12 @@ class MenuModel; // as it only maintains weak references. @interface MenuController : NSObject { @protected - menus::MenuModel* model_; // weak + ui::MenuModel* model_; // weak scoped_nsobject<NSMenu> menu_; BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank } -@property (nonatomic, assign) menus::MenuModel* model; +@property (nonatomic, assign) ui::MenuModel* model; // Note that changing this will have no effect if you use // |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|. @property (nonatomic) BOOL useWithPopUpButtonCell; @@ -42,7 +42,7 @@ class MenuModel; // the menu will be displayed by a NSPopUpButtonCell, it needs to be of a // slightly different form (0th item is empty). Note this attribute of the menu // cannot be changed after it has been created. -- (id)initWithModel:(menus::MenuModel*)model +- (id)initWithModel:(ui::MenuModel*)model useWithPopUpButtonCell:(BOOL)useWithCell; // Access to the constructed menu if the complex initializer was used. If the @@ -60,7 +60,7 @@ class MenuModel; @interface MenuController (Protected) - (void)addItemToMenu:(NSMenu*)menu atIndex:(NSInteger)index - fromModel:(menus::MenuModel*)model + fromModel:(ui::MenuModel*)model modelIndex:(int)modelIndex; @end diff --git a/chrome/browser/ui/cocoa/menu_controller.mm b/chrome/browser/ui/cocoa/menu_controller.mm index a6d314d..9a1d5a8 100644 --- a/chrome/browser/ui/cocoa/menu_controller.mm +++ b/chrome/browser/ui/cocoa/menu_controller.mm @@ -5,15 +5,15 @@ #import "chrome/browser/ui/cocoa/menu_controller.h" #include "app/l10n_util_mac.h" -#include "app/menus/accelerator_cocoa.h" -#include "app/menus/simple_menu_model.h" #include "base/logging.h" #include "base/sys_string_conversions.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/models/accelerator_cocoa.h" +#include "ui/base/models/simple_menu_model.h" @interface MenuController (Private) -- (NSMenu*)menuFromModel:(menus::MenuModel*)model; +- (NSMenu*)menuFromModel:(ui::MenuModel*)model; - (void)addSeparatorToMenu:(NSMenu*)menu atIndex:(int)index; @end @@ -28,7 +28,7 @@ return self; } -- (id)initWithModel:(menus::MenuModel*)model +- (id)initWithModel:(ui::MenuModel*)model useWithPopUpButtonCell:(BOOL)useWithCell { if ((self = [super init])) { model_ = model; @@ -45,7 +45,7 @@ // Creates a NSMenu from the given model. If the model has submenus, this can // be invoked recursively. -- (NSMenu*)menuFromModel:(menus::MenuModel*)model { +- (NSMenu*)menuFromModel:(ui::MenuModel*)model { NSMenu* menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; // The indices may not always start at zero (the windows system menu is one @@ -56,7 +56,7 @@ const int count = model->GetItemCount(); for (int index = firstItemIndex; index < firstItemIndex + count; index++) { int modelIndex = index - firstItemIndex; - if (model->GetTypeAt(modelIndex) == menus::MenuModel::TYPE_SEPARATOR) { + if (model->GetTypeAt(modelIndex) == ui::MenuModel::TYPE_SEPARATOR) { [self addSeparatorToMenu:menu atIndex:index]; } else { [self addItemToMenu:menu atIndex:index fromModel:model @@ -80,7 +80,7 @@ // associated with the entry in the model indentifed by |modelIndex|. - (void)addItemToMenu:(NSMenu*)menu atIndex:(NSInteger)index - fromModel:(menus::MenuModel*)model + fromModel:(ui::MenuModel*)model modelIndex:(int)modelIndex { NSString* label = l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex)); @@ -98,14 +98,14 @@ } } - menus::MenuModel::ItemType type = model->GetTypeAt(modelIndex); - if (type == menus::MenuModel::TYPE_SUBMENU) { + ui::MenuModel::ItemType type = model->GetTypeAt(modelIndex); + if (type == ui::MenuModel::TYPE_SUBMENU) { // Recursively build a submenu from the sub-model at this index. [item setTarget:nil]; [item setAction:nil]; - menus::MenuModel* submenuModel = model->GetSubmenuModelAt(modelIndex); + ui::MenuModel* submenuModel = model->GetSubmenuModelAt(modelIndex); NSMenu* submenu = - [self menuFromModel:(menus::SimpleMenuModel*)submenuModel]; + [self menuFromModel:(ui::SimpleMenuModel*)submenuModel]; [item setSubmenu:submenu]; } else { // The MenuModel works on indexes so we can't just set the command id as the @@ -117,7 +117,7 @@ [item setTarget:self]; NSValue* modelObject = [NSValue valueWithPointer:model]; [item setRepresentedObject:modelObject]; // Retains |modelObject|. - menus::AcceleratorCocoa accelerator; + ui::AcceleratorCocoa accelerator; if (model->GetAcceleratorAt(modelIndex, &accelerator)) { [item setKeyEquivalent:accelerator.characters()]; [item setKeyEquivalentModifierMask:accelerator.modifiers()]; @@ -135,8 +135,8 @@ return NO; NSInteger modelIndex = [item tag]; - menus::MenuModel* model = - static_cast<menus::MenuModel*>( + ui::MenuModel* model = + static_cast<ui::MenuModel*>( [[(id)item representedObject] pointerValue]); DCHECK(model); if (model) { @@ -164,8 +164,8 @@ // item chosen. - (void)itemSelected:(id)sender { NSInteger modelIndex = [sender tag]; - menus::MenuModel* model = - static_cast<menus::MenuModel*>( + ui::MenuModel* model = + static_cast<ui::MenuModel*>( [[sender representedObject] pointerValue]); DCHECK(model); if (model) diff --git a/chrome/browser/ui/cocoa/menu_controller_unittest.mm b/chrome/browser/ui/cocoa/menu_controller_unittest.mm index 8e00c53..f3d40bb 100644 --- a/chrome/browser/ui/cocoa/menu_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/menu_controller_unittest.mm @@ -4,7 +4,6 @@ #import <Cocoa/Cocoa.h> -#include "app/menus/simple_menu_model.h" #include "app/resource_bundle.h" #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" @@ -13,13 +12,14 @@ #include "grit/app_resources.h" #include "grit/generated_resources.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/models/simple_menu_model.h" class MenuControllerTest : public CocoaTest { }; // 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 { +class Delegate : public ui::SimpleMenuModel::Delegate { public: Delegate() : execute_count_(0), enable_count_(0) { } @@ -30,7 +30,7 @@ class Delegate : public menus::SimpleMenuModel::Delegate { } virtual bool GetAcceleratorForCommandId( int command_id, - menus::Accelerator* accelerator) { return false; } + ui::Accelerator* accelerator) { return false; } virtual void ExecuteCommand(int command_id) { ++execute_count_; } int execute_count_; @@ -62,7 +62,7 @@ class DynamicDelegate : public Delegate { TEST_F(MenuControllerTest, EmptyMenu) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); scoped_nsobject<MenuController> menu( [[MenuController alloc] initWithModel:&model useWithPopUpButtonCell:NO]); EXPECT_EQ([[menu menu] numberOfItems], 0); @@ -70,7 +70,7 @@ TEST_F(MenuControllerTest, EmptyMenu) { TEST_F(MenuControllerTest, BasicCreation) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("one")); model.AddItem(2, ASCIIToUTF16("two")); model.AddItem(3, ASCIIToUTF16("three")); @@ -95,9 +95,9 @@ TEST_F(MenuControllerTest, BasicCreation) { TEST_F(MenuControllerTest, Submenus) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("one")); - menus::SimpleMenuModel submodel(&delegate); + ui::SimpleMenuModel submodel(&delegate); submodel.AddItem(2, ASCIIToUTF16("sub-one")); submodel.AddItem(3, ASCIIToUTF16("sub-two")); submodel.AddItem(4, ASCIIToUTF16("sub-three")); @@ -132,9 +132,9 @@ TEST_F(MenuControllerTest, Submenus) { TEST_F(MenuControllerTest, EmptySubmenu) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("one")); - menus::SimpleMenuModel submodel(&delegate); + ui::SimpleMenuModel submodel(&delegate); model.AddSubMenuWithStringId(2, IDS_ZOOM_MENU, &submodel); scoped_nsobject<MenuController> menu( @@ -144,7 +144,7 @@ TEST_F(MenuControllerTest, EmptySubmenu) { TEST_F(MenuControllerTest, PopUpButton) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("one")); model.AddItem(2, ASCIIToUTF16("two")); model.AddItem(3, ASCIIToUTF16("three")); @@ -164,7 +164,7 @@ TEST_F(MenuControllerTest, PopUpButton) { TEST_F(MenuControllerTest, Execute) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("one")); scoped_nsobject<MenuController> menu( [[MenuController alloc] initWithModel:&model useWithPopUpButtonCell:NO]); @@ -188,10 +188,10 @@ void Validate(MenuController* controller, NSMenu* menu) { TEST_F(MenuControllerTest, Validate) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("one")); model.AddItem(2, ASCIIToUTF16("two")); - menus::SimpleMenuModel submodel(&delegate); + ui::SimpleMenuModel submodel(&delegate); submodel.AddItem(2, ASCIIToUTF16("sub-one")); model.AddSubMenuWithStringId(3, IDS_ZOOM_MENU, &submodel); @@ -204,7 +204,7 @@ TEST_F(MenuControllerTest, Validate) { TEST_F(MenuControllerTest, DefaultInitializer) { Delegate delegate; - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("one")); model.AddItem(2, ASCIIToUTF16("two")); model.AddItem(3, ASCIIToUTF16("three")); @@ -230,7 +230,7 @@ TEST_F(MenuControllerTest, Dynamic) { // no icon. string16 initial = ASCIIToUTF16("initial"); delegate.SetDynamicLabel(initial); - menus::SimpleMenuModel model(&delegate); + ui::SimpleMenuModel model(&delegate); model.AddItem(1, ASCIIToUTF16("foo")); scoped_nsobject<MenuController> menu( [[MenuController alloc] initWithModel:&model useWithPopUpButtonCell:NO]); diff --git a/chrome/browser/ui/cocoa/simple_content_exceptions_window_controller.mm b/chrome/browser/ui/cocoa/simple_content_exceptions_window_controller.mm index 7b4c1f8..213e449 100644 --- a/chrome/browser/ui/cocoa/simple_content_exceptions_window_controller.mm +++ b/chrome/browser/ui/cocoa/simple_content_exceptions_window_controller.mm @@ -5,13 +5,13 @@ #import "chrome/browser/ui/cocoa/simple_content_exceptions_window_controller.h" #include "app/l10n_util_mac.h" -#include "app/table_model_observer.h" #include "base/logging.h" #import "base/mac/mac_util.h" #import "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" #include "grit/generated_resources.h" #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" +#include "ui/base/models/table_model_observer.h" @interface SimpleContentExceptionsWindowController (Private) - (id)initWithTableModel:(RemoveRowsTableModel*)model; diff --git a/chrome/browser/ui/cocoa/status_icons/status_icon_mac.h b/chrome/browser/ui/cocoa/status_icons/status_icon_mac.h index c414ec90..7c2c84e 100644 --- a/chrome/browser/ui/cocoa/status_icons/status_icon_mac.h +++ b/chrome/browser/ui/cocoa/status_icons/status_icon_mac.h @@ -28,7 +28,7 @@ class StatusIconMac : public StatusIcon { protected: // Overridden from StatusIcon. - virtual void UpdatePlatformContextMenu(menus::MenuModel* menu); + virtual void UpdatePlatformContextMenu(ui::MenuModel* menu); private: // Getter for item_ that allows lazy initialization. diff --git a/chrome/browser/ui/cocoa/status_icons/status_icon_mac.mm b/chrome/browser/ui/cocoa/status_icons/status_icon_mac.mm index 3f3d5a1..9ac39bf 100644 --- a/chrome/browser/ui/cocoa/status_icons/status_icon_mac.mm +++ b/chrome/browser/ui/cocoa/status_icons/status_icon_mac.mm @@ -76,7 +76,7 @@ void StatusIconMac::SetToolTip(const string16& tool_tip) { [item() setToolTip:base::SysUTF16ToNSString(tool_tip)]; } -void StatusIconMac::UpdatePlatformContextMenu(menus::MenuModel* menu) { +void StatusIconMac::UpdatePlatformContextMenu(ui::MenuModel* menu) { // TODO(atwilson): Add support for context menus for Mac when actually needed // (not yet used by anything) - http://crbug.com/37375. } diff --git a/chrome/browser/ui/cocoa/tab_controller.mm b/chrome/browser/ui/cocoa/tab_controller.mm index f05bb21..fb8c6b1 100644 --- a/chrome/browser/ui/cocoa/tab_controller.mm +++ b/chrome/browser/ui/cocoa/tab_controller.mm @@ -30,13 +30,13 @@ namespace TabControllerInternal { // A C++ delegate that handles enabling/disabling menu items and handling when // a menu command is chosen. Also fixes up the menu item label for "pin/unpin // tab". -class MenuDelegate : public menus::SimpleMenuModel::Delegate { +class MenuDelegate : public ui::SimpleMenuModel::Delegate { public: explicit MenuDelegate(id<TabControllerTarget> target, TabController* owner) : target_(target), owner_(owner) {} - // Overridden from menus::SimpleMenuModel::Delegate + // Overridden from ui::SimpleMenuModel::Delegate virtual bool IsCommandIdChecked(int command_id) const { return false; } virtual bool IsCommandIdEnabled(int command_id) const { TabStripModel::ContextMenuCommand command = @@ -45,7 +45,7 @@ class MenuDelegate : public menus::SimpleMenuModel::Delegate { } virtual bool GetAcceleratorForCommandId( int command_id, - menus::Accelerator* accelerator) { return false; } + ui::Accelerator* accelerator) { return false; } virtual void ExecuteCommand(int command_id) { TabStripModel::ContextMenuCommand command = static_cast<TabStripModel::ContextMenuCommand>(command_id); diff --git a/chrome/browser/ui/cocoa/table_model_array_controller.h b/chrome/browser/ui/cocoa/table_model_array_controller.h index 63cf4c8..850bf6d 100644 --- a/chrome/browser/ui/cocoa/table_model_array_controller.h +++ b/chrome/browser/ui/cocoa/table_model_array_controller.h @@ -8,10 +8,10 @@ #import <Cocoa/Cocoa.h> -#include "app/table_model_observer.h" #import "base/mac/cocoa_protocols.h" #include "base/scoped_nsobject.h" #include "base/scoped_ptr.h" +#include "ui/base/models/table_model_observer.h" class RemoveRowsObserverBridge; class RemoveRowsTableModel; diff --git a/chrome/browser/ui/cocoa/table_model_array_controller.mm b/chrome/browser/ui/cocoa/table_model_array_controller.mm index dcc2e6a..8678fa8 100644 --- a/chrome/browser/ui/cocoa/table_model_array_controller.mm +++ b/chrome/browser/ui/cocoa/table_model_array_controller.mm @@ -4,10 +4,10 @@ #import "chrome/browser/ui/cocoa/table_model_array_controller.h" -#include "app/table_model.h" #include "base/logging.h" #include "base/sys_string_conversions.h" #include "chrome/browser/remove_rows_table_model.h" +#include "ui/base/models/table_model.h" @interface TableModelArrayController () @@ -24,13 +24,13 @@ @end // Observer for a RemoveRowsTableModel. -class RemoveRowsObserverBridge : public TableModelObserver { +class RemoveRowsObserverBridge : public ui::TableModelObserver { public: RemoveRowsObserverBridge(TableModelArrayController* controller) : controller_(controller) {} virtual ~RemoveRowsObserverBridge() {} - // TableModelObserver methods + // ui::TableModelObserver methods virtual void OnModelChanged(); virtual void OnItemsChanged(int start, int length); virtual void OnItemsAdded(int start, int length); @@ -78,9 +78,9 @@ static NSString* const kGroupID = @"_group_id"; NSMakeRange(0, [[self arrangedObjects] count])]; [self removeObjectsAtArrangedObjectIndexes:indexes]; if (model_->HasGroups()) { - const TableModel::Groups& groups = model_->GetGroups(); + const ui::TableModel::Groups& groups = model_->GetGroups(); DCHECK(groupTitle_.get()); - for (TableModel::Groups::const_iterator it = groups.begin(); + for (ui::TableModel::Groups::const_iterator it = groups.begin(); it != groups.end(); ++it) { NSDictionary* group = [NSDictionary dictionaryWithObjectsAndKeys: base::SysUTF16ToNSString(it->title), groupTitle_.get(), @@ -93,7 +93,7 @@ static NSString* const kGroupID = @"_group_id"; } - (NSUInteger)offsetForGroupID:(int)groupID startingOffset:(NSUInteger)offset { - const TableModel::Groups& groups = model_->GetGroups(); + const ui::TableModel::Groups& groups = model_->GetGroups(); DCHECK_GT(offset, 0u); for (NSUInteger i = offset - 1; i < groups.size(); ++i) { if (groups[i].id == groupID) diff --git a/chrome/browser/ui/cocoa/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar_controller.mm index 3147738..92afce8 100644 --- a/chrome/browser/ui/cocoa/toolbar_controller.mm +++ b/chrome/browser/ui/cocoa/toolbar_controller.mm @@ -9,8 +9,6 @@ #include "app/l10n_util.h" #include "app/l10n_util_mac.h" #include "app/mac/nsimage_cache.h" -#include "app/menus/accelerator_cocoa.h" -#include "app/menus/menu_model.h" #include "app/resource_bundle.h" #include "base/mac/mac_util.h" #include "base/singleton.h" @@ -57,6 +55,8 @@ #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" +#include "ui/base/models/accelerator_cocoa.h" +#include "ui/base/models/menu_model.h" namespace { @@ -101,16 +101,16 @@ const CGFloat kWrenchMenuLeftPadding = 3.0; namespace ToolbarControllerInternal { // A C++ delegate that handles the accelerators in the wrench menu. -class WrenchAcceleratorDelegate : public menus::AcceleratorProvider { +class WrenchAcceleratorDelegate : public ui::AcceleratorProvider { public: virtual bool GetAcceleratorForCommandId(int command_id, - menus::Accelerator* accelerator_generic) { + ui::Accelerator* accelerator_generic) { // Downcast so that when the copy constructor is invoked below, the key // string gets copied, too. - menus::AcceleratorCocoa* out_accelerator = - static_cast<menus::AcceleratorCocoa*>(accelerator_generic); + ui::AcceleratorCocoa* out_accelerator = + static_cast<ui::AcceleratorCocoa*>(accelerator_generic); AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance(); - const menus::AcceleratorCocoa* accelerator = + const ui::AcceleratorCocoa* accelerator = keymap->GetAcceleratorForCommand(command_id); if (accelerator) { *out_accelerator = *accelerator; diff --git a/chrome/browser/ui/cocoa/wrench_menu_controller.mm b/chrome/browser/ui/cocoa/wrench_menu_controller.mm index c57528b4..fdedecd 100644 --- a/chrome/browser/ui/cocoa/wrench_menu_controller.mm +++ b/chrome/browser/ui/cocoa/wrench_menu_controller.mm @@ -5,7 +5,6 @@ #import "chrome/browser/ui/cocoa/wrench_menu_controller.h" #include "app/l10n_util.h" -#include "app/menus/menu_model.h" #include "base/sys_string_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/background_page_tracker.h" @@ -21,6 +20,7 @@ #include "chrome/common/notification_type.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" +#include "ui/base/models/menu_model.h" @interface WrenchMenuController (Private) - (void)adjustPositioning; @@ -67,11 +67,11 @@ class ZoomLevelObserver : public NotificationObserver { - (void)addItemToMenu:(NSMenu*)menu atIndex:(NSInteger)index - fromModel:(menus::MenuModel*)model + fromModel:(ui::MenuModel*)model modelIndex:(int)modelIndex { // Non-button item types should be built as normal items. - menus::MenuModel::ItemType type = model->GetTypeAt(modelIndex); - if (type != menus::MenuModel::TYPE_BUTTON_ITEM) { + ui::MenuModel::ItemType type = model->GetTypeAt(modelIndex); + if (type != ui::MenuModel::TYPE_BUTTON_ITEM) { [super addItemToMenu:menu atIndex:index fromModel:model |