Commit c88c900a authored by rlp@chromium.org's avatar rlp@chromium.org

Removing instances of profile_->GetBookmarkModel() as part of converting BookmarkModel to a PKS.

BUG=112525
TEST=unittests, manual 

Review URL: https://chromiumcodereview.appspot.com/10827060

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148791 0039d316-1c4b-4281-b951-d872f2087c98
parent 0115f04b
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_bridge.h"
#include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
......@@ -95,7 +96,7 @@ class BookmarkBarBridgeTest : public CocoaProfileTest {
// Call all the callbacks; make sure they are all redirected to the objc object.
TEST_F(BookmarkBarBridgeTest, TestRedirect) {
BookmarkModel* model = profile()->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
scoped_nsobject<NSView> parentView([[NSView alloc]
initWithFrame:NSMakeRect(0,0,100,100)]);
......
......@@ -10,6 +10,7 @@
#include "base/sys_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
......@@ -242,7 +243,7 @@ void RecordAppLaunch(Profile* profile, GURL url) {
browser_ = browser;
initialWidth_ = initialWidth;
bookmarkModel_ = browser_->profile()->GetBookmarkModel();
bookmarkModel_ = BookmarkModelFactory::GetForProfile(browser_->profile());
buttons_.reset([[NSMutableArray alloc] init]);
delegate_ = delegate;
resizeDelegate_ = resizeDelegate;
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.
......@@ -6,6 +6,7 @@
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/profiles/profile.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h"
......@@ -212,7 +213,8 @@ TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) {
[view_ setController:info.get()];
[info reset];
BookmarkModel* bookmark_model = profile()->GetBookmarkModel();
BookmarkModel* bookmark_model =
BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* node =
bookmark_model->AddURL(bookmark_model->bookmark_bar_node(),
0,
......@@ -251,7 +253,8 @@ TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDropAcrossProfiles) {
other_profile->CreateBookmarkModel(true);
other_profile->BlockUntilBookmarkModelLoaded();
BookmarkModel* bookmark_model = profile()->GetBookmarkModel();
BookmarkModel* bookmark_model =
BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* node =
bookmark_model->AddURL(bookmark_model->bookmark_bar_node(),
0,
......@@ -268,7 +271,7 @@ TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDropAcrossProfiles) {
[info setDraggingSource:dragged_button.get()];
[info setDragDataType:kBookmarkButtonDragType];
[info setButton:dragged_button.get()];
[info setBookmarkModel:other_profile->GetBookmarkModel()];
[info setBookmarkModel:BookmarkModelFactory::GetForProfile(other_profile)];
EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove);
EXPECT_TRUE([view_ performDragOperation:(id)info.get()]);
EXPECT_TRUE([info dragButtonToPong]);
......
......@@ -8,6 +8,7 @@
#include "base/memory/scoped_nsobject.h"
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h"
#include "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
......@@ -79,7 +80,8 @@ class BookmarkBubbleControllerTest : public CocoaProfileTest {
}
controller_ = [[BookmarkBubbleController alloc]
initWithParentWindow:test_window()
model:profile()->GetBookmarkModel()
model:BookmarkModelFactory::GetForProfile(
profile())
node:node
alreadyBookmarked:YES];
EXPECT_TRUE([controller_ window]);
......@@ -90,7 +92,7 @@ class BookmarkBubbleControllerTest : public CocoaProfileTest {
}
BookmarkModel* GetBookmarkModel() {
return profile()->GetBookmarkModel();
return BookmarkModelFactory::GetForProfile(profile());
}
bool IsWindowClosing() {
......@@ -395,7 +397,7 @@ TEST_F(BookmarkBubbleControllerTest, EscapeRemovesNewBookmark) {
BookmarkBubbleController* controller =
[[BookmarkBubbleController alloc]
initWithParentWindow:test_window()
model:profile()->GetBookmarkModel()
model:BookmarkModelFactory::GetForProfile(profile())
node:node
alreadyBookmarked:NO]; // The last param is the key difference.
EXPECT_TRUE([controller window]);
......
......@@ -5,6 +5,7 @@
#include "base/memory/scoped_nsobject.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
......@@ -95,7 +96,7 @@ TEST_F(BookmarkButtonCellTest, MouseEnterStuff) {
[cell setMenu:[[[BookmarkMenu alloc] initWithTitle:@"foo"] autorelease]];
EXPECT_FALSE([cell menu]);
BookmarkModel* model = profile()->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* node = model->bookmark_bar_node();
[cell setEmpty:NO];
[cell setBookmarkNode:node];
......@@ -108,7 +109,7 @@ TEST_F(BookmarkButtonCellTest, MouseEnterStuff) {
}
TEST_F(BookmarkButtonCellTest, BookmarkNode) {
BookmarkModel& model(*(profile()->GetBookmarkModel()));
BookmarkModel& model(*(BookmarkModelFactory::GetForProfile(profile())));
scoped_nsobject<BookmarkButtonCell> cell(
[[BookmarkButtonCell alloc] initTextCell:@"Testing"]);
......@@ -157,7 +158,7 @@ TEST_F(BookmarkButtonCellTest, Awake) {
// Subfolder arrow details.
TEST_F(BookmarkButtonCellTest, FolderArrow) {
BookmarkModel* model = profile()->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* bar = model->bookmark_bar_node();
const BookmarkNode* node = model->AddURL(bar, bar->child_count(),
ASCIIToUTF16("title"),
......@@ -181,7 +182,7 @@ TEST_F(BookmarkButtonCellTest, FolderArrow) {
}
TEST_F(BookmarkButtonCellTest, VerticalTextOffset) {
BookmarkModel* model = profile()->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* bar = model->bookmark_bar_node();
const BookmarkNode* node = model->AddURL(bar, bar->child_count(),
ASCIIToUTF16("title"),
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/scoped_nsobject.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
......@@ -86,7 +87,7 @@ TEST_F(BookmarkButtonTest, FolderAndEmptyOrNot) {
// Since this returns (does not actually begin a modal drag), success!
[button beginDrag:downEvent];
BookmarkModel* model = profile()->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* node = model->bookmark_bar_node();
[cell setBookmarkNode:node];
EXPECT_FALSE([button isEmpty]);
......@@ -139,7 +140,7 @@ TEST_F(BookmarkButtonTest, DragToTrash) {
[button setDelegate:delegate];
// Add a deletable bookmark to the button.
BookmarkModel* model = profile()->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* barNode = model->bookmark_bar_node();
const BookmarkNode* node = model->AddURL(barNode, 0, ASCIIToUTF16("hi mom"),
GURL("http://www.google.com"));
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 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.
......@@ -8,6 +8,7 @@
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "chrome/test/base/test_browser_window.h"
......@@ -37,7 +38,7 @@ class BookmarkEditorBaseControllerTest : public CocoaProfileTest {
// b-30
// b-31
// b-4
BookmarkModel& model(*(profile()->GetBookmarkModel()));
BookmarkModel& model(*(BookmarkModelFactory::GetForProfile(profile())));
const BookmarkNode* root = model.bookmark_bar_node();
folder_a_ = model.AddFolder(root, 0, ASCIIToUTF16("a"));
model.AddURL(folder_a_, 0, ASCIIToUTF16("a-0"), GURL("http://a-0.com"));
......@@ -96,7 +97,7 @@ class BookmarkEditorBaseControllerTest : public CocoaProfileTest {
};
TEST_F(BookmarkEditorBaseControllerTest, VerifyBookmarkTestModel) {
BookmarkModel& model(*(profile()->GetBookmarkModel()));
BookmarkModel& model(*(BookmarkModelFactory::GetForProfile(profile())));
const BookmarkNode& root(*model.bookmark_bar_node());
EXPECT_EQ(4, root.child_count());
// a
......@@ -176,7 +177,7 @@ TEST_F(BookmarkEditorBaseControllerTest, CreateFolder) {
}
TEST_F(BookmarkEditorBaseControllerTest, CreateTwoFolders) {
BookmarkModel* model = profile()->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
const BookmarkNode* bar = model->bookmark_bar_node();
// Create 2 folders which are children of the bar.
[controller_ selectTestNodeInBrowser:bar];
......@@ -190,7 +191,7 @@ TEST_F(BookmarkEditorBaseControllerTest, CreateTwoFolders) {
}
TEST_F(BookmarkEditorBaseControllerTest, SelectedFolderDeleted) {
BookmarkModel& model(*(profile()->GetBookmarkModel()));
BookmarkModel& model(*(BookmarkModelFactory::GetForProfile(profile())));
[controller_ selectTestNodeInBrowser:folder_b_3_];
EXPECT_EQ(folder_b_3_, [controller_ selectedNode]);
......@@ -202,7 +203,7 @@ TEST_F(BookmarkEditorBaseControllerTest, SelectedFolderDeleted) {
}
TEST_F(BookmarkEditorBaseControllerTest, SelectedFoldersParentDeleted) {
BookmarkModel& model(*(profile()->GetBookmarkModel()));
BookmarkModel& model(*(BookmarkModelFactory::GetForProfile(profile())));
const BookmarkNode* root = model.bookmark_bar_node();
[controller_ selectTestNodeInBrowser:folder_b_3_];
EXPECT_EQ(folder_b_3_, [controller_ selectedNode]);
......@@ -215,7 +216,7 @@ TEST_F(BookmarkEditorBaseControllerTest, SelectedFoldersParentDeleted) {
}
TEST_F(BookmarkEditorBaseControllerTest, FolderAdded) {
BookmarkModel& model(*(profile()->GetBookmarkModel()));
BookmarkModel& model(*(BookmarkModelFactory::GetForProfile(profile())));
const BookmarkNode* root = model.bookmark_bar_node();
// Add a folder node to the model, and verify it can be selected in the tree:
......@@ -229,7 +230,7 @@ TEST_F(BookmarkEditorBaseControllerTest, FolderAdded) {
// Verifies expandeNodes and getExpandedNodes.
TEST_F(BookmarkEditorBaseControllerTest, ExpandedState) {
BookmarkModel& model(*(profile()->GetBookmarkModel()));
BookmarkModel& model(*(BookmarkModelFactory::GetForProfile(profile())));
// Sets up the state we're going to expand.
BookmarkExpandedStateTracker::Nodes nodes;
......
......@@ -8,6 +8,7 @@
#include "chrome/app/chrome_command_ids.h"
#import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_list.h"
......@@ -171,7 +172,7 @@ void BookmarkMenuBridge::ObserveBookmarkModel() {
BookmarkModel* BookmarkMenuBridge::GetBookmarkModel() {
if (!profile_)
return NULL;
return profile_->GetBookmarkModel();
return BookmarkModelFactory::GetForProfile(profile_);
}
Profile* BookmarkMenuBridge::GetProfile() {
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/string16.h"
#import "base/memory/scoped_nsobject.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/ui/browser.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h"
......@@ -27,7 +28,7 @@
- (id)initWithProfile:(Profile*)profile {
if ((self = [super init])) {
string16 empty;
BookmarkModel* model = profile->GetBookmarkModel();
BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile);
const BookmarkNode* bookmark_bar = model->bookmark_bar_node();
nodes_[0] = model->AddURL(bookmark_bar, 0, empty, GURL("http://0.com"));
nodes_[1] = model->AddURL(bookmark_bar, 1, empty, GURL("http://1.com"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment