Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work around STL android bug Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | components/bookmarks.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/prefs/testing_pref_store.h" 14 #include "base/prefs/testing_pref_store.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
18 #include "chrome/browser/bookmarks/bookmark_model.h" 18 #include "chrome/browser/bookmarks/bookmark_model.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/content_settings/host_content_settings_map.h" 23 #include "chrome/browser/content_settings/host_content_settings_map.h"
23 #include "chrome/browser/extensions/extension_service.h" 24 #include "chrome/browser/extensions/extension_service.h"
24 #include "chrome/browser/extensions/extension_special_storage_policy.h" 25 #include "chrome/browser/extensions/extension_special_storage_policy.h"
25 #include "chrome/browser/extensions/extension_system_factory.h" 26 #include "chrome/browser/extensions/extension_system_factory.h"
26 #include "chrome/browser/extensions/test_extension_system.h" 27 #include "chrome/browser/extensions/test_extension_system.h"
27 #include "chrome/browser/favicon/favicon_service.h" 28 #include "chrome/browser/favicon/favicon_service.h"
28 #include "chrome/browser/favicon/favicon_service_factory.h" 29 #include "chrome/browser/favicon/favicon_service_factory.h"
29 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that 488 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that
488 // need to be run to properly shutdown. Run all pending tasks now. This is 489 // need to be run to properly shutdown. Run all pending tasks now. This is
489 // normally handled by browser_process shutdown. 490 // normally handled by browser_process shutdown.
490 if (base::MessageLoop::current()) 491 if (base::MessageLoop::current())
491 base::MessageLoop::current()->RunUntilIdle(); 492 base::MessageLoop::current()->RunUntilIdle();
492 } 493 }
493 } 494 }
494 495
495 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) { 496 static KeyedService* BuildBookmarkModel(content::BrowserContext* context) {
496 Profile* profile = static_cast<Profile*>(context); 497 Profile* profile = static_cast<Profile*>(context);
497 BookmarkModel* bookmark_model = new BookmarkModel(profile, false); 498 ChromeBookmarkClient* bookmark_client =
498 bookmark_model->Load(profile->GetIOTaskRunner()); 499 new ChromeBookmarkClient(profile, false);
499 return bookmark_model; 500 bookmark_client->model()->Load(
501 profile->GetPrefs(),
502 profile->GetPrefs()->GetString(prefs::kAcceptLanguages),
503 profile->GetPath(),
504 profile->GetIOTaskRunner(),
505 content::BrowserThread::GetMessageLoopProxyForThread(
506 content::BrowserThread::UI));
507 return bookmark_client;
500 } 508 }
501 509
502 void TestingProfile::CreateBookmarkModel(bool delete_file) { 510 void TestingProfile::CreateBookmarkModel(bool delete_file) {
503 if (delete_file) { 511 if (delete_file) {
504 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); 512 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName);
505 base::DeleteFile(path, false); 513 base::DeleteFile(path, false);
506 } 514 }
507 // This will create a bookmark model. 515 // This will create a bookmark model.
508 BookmarkModel* bookmark_service = static_cast<BookmarkModel*>( 516 BookmarkModel* bookmark_service =
509 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( 517 static_cast<ChromeBookmarkClient*>(
510 this, BuildBookmarkModel)); 518 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
519 this, BuildBookmarkModel))->model();
511 520
512 HistoryService* history_service = 521 HistoryService* history_service =
513 HistoryServiceFactory::GetForProfileWithoutCreating(this); 522 HistoryServiceFactory::GetForProfileWithoutCreating(this);
514 if (history_service) { 523 if (history_service) {
515 history_service->history_backend_->bookmark_service_ = bookmark_service; 524 history_service->history_backend_->bookmark_service_ = bookmark_service;
516 history_service->history_backend_->expirer_.bookmark_service_ = 525 history_service->history_backend_->expirer_.bookmark_service_ =
517 bookmark_service; 526 bookmark_service;
518 } 527 }
519 } 528 }
520 529
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 path_, 972 path_,
964 delegate_, 973 delegate_,
965 extension_policy_, 974 extension_policy_,
966 pref_service_.Pass(), 975 pref_service_.Pass(),
967 incognito_, 976 incognito_,
968 guest_session_, 977 guest_session_,
969 managed_user_id_, 978 managed_user_id_,
970 policy_service_.Pass(), 979 policy_service_.Pass(),
971 testing_factories_)); 980 testing_factories_));
972 } 981 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | components/bookmarks.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698