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

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

Issue 5153002: Use a service to create device management backends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/testing_profile.h" 5 #include "chrome/test/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"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/search_engines/template_url_fetcher.h" 32 #include "chrome/browser/search_engines/template_url_fetcher.h"
33 #include "chrome/browser/search_engines/template_url_model.h" 33 #include "chrome/browser/search_engines/template_url_model.h"
34 #include "chrome/browser/sessions/session_service.h" 34 #include "chrome/browser/sessions/session_service.h"
35 #include "chrome/browser/sync/profile_sync_service_mock.h" 35 #include "chrome/browser/sync/profile_sync_service_mock.h"
36 #include "chrome/browser/themes/browser_theme_provider.h" 36 #include "chrome/browser/themes/browser_theme_provider.h"
37 #include "chrome/common/chrome_constants.h" 37 #include "chrome/common/chrome_constants.h"
38 #include "chrome/common/net/url_request_context_getter.h" 38 #include "chrome/common/net/url_request_context_getter.h"
39 #include "chrome/common/notification_service.h" 39 #include "chrome/common/notification_service.h"
40 #include "chrome/common/url_constants.h" 40 #include "chrome/common/url_constants.h"
41 #include "chrome/test/testing_pref_service.h" 41 #include "chrome/test/testing_pref_service.h"
42 #include "chrome/test/test_url_request_context_getter.h"
42 #include "chrome/test/ui_test_utils.h" 43 #include "chrome/test/ui_test_utils.h"
43 #include "net/base/cookie_monster.h" 44 #include "net/base/cookie_monster.h"
44 #include "net/url_request/url_request_context.h" 45 #include "net/url_request/url_request_context.h"
45 #include "net/url_request/url_request_unittest.h" 46 #include "net/url_request/url_request_unittest.h"
46 #include "testing/gmock/include/gmock/gmock.h" 47 #include "testing/gmock/include/gmock/gmock.h"
47 #include "webkit/database/database_tracker.h" 48 #include "webkit/database/database_tracker.h"
48 49
49 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) 50 #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)
50 #include "chrome/browser/gtk/gtk_theme_provider.h" 51 #include "chrome/browser/gtk/gtk_theme_provider.h"
51 #endif 52 #endif
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const BookmarkNode* node) {} 105 const BookmarkNode* node) {}
105 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, 106 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
106 const BookmarkNode* node) {} 107 const BookmarkNode* node) {}
107 virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, 108 virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
108 const BookmarkNode* node) {} 109 const BookmarkNode* node) {}
109 110
110 private: 111 private:
111 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver); 112 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver);
112 }; 113 };
113 114
114 // Used to return a dummy context (normally the context is on the IO thread).
115 // The one here can be run on the main test thread. Note that this can lead to
116 // a leak if your test does not have a BrowserThread::IO in it because
117 // URLRequestContextGetter is defined as a ReferenceCounted object with a
118 // special trait that deletes it on the IO thread.
119 class TestURLRequestContextGetter : public URLRequestContextGetter {
120 public:
121 virtual URLRequestContext* GetURLRequestContext() {
122 if (!context_)
123 context_ = new TestURLRequestContext();
124 return context_.get();
125 }
126 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const {
127 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
128 }
129
130 private:
131 scoped_refptr<URLRequestContext> context_;
132 };
133
134 class TestExtensionURLRequestContext : public URLRequestContext { 115 class TestExtensionURLRequestContext : public URLRequestContext {
135 public: 116 public:
136 TestExtensionURLRequestContext() { 117 TestExtensionURLRequestContext() {
137 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); 118 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
138 const char* schemes[] = {chrome::kExtensionScheme}; 119 const char* schemes[] = {chrome::kExtensionScheme};
139 cookie_monster->SetCookieableSchemes(schemes, 1); 120 cookie_monster->SetCookieableSchemes(schemes, 1);
140 cookie_store_ = cookie_monster; 121 cookie_store_ = cookie_monster;
141 } 122 }
142 }; 123 };
143 124
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 501 }
521 return profile_sync_service_.get(); 502 return profile_sync_service_.get();
522 } 503 }
523 504
524 void TestingProfile::DestroyWebDataService() { 505 void TestingProfile::DestroyWebDataService() {
525 if (!web_data_service_.get()) 506 if (!web_data_service_.get())
526 return; 507 return;
527 508
528 web_data_service_->Shutdown(); 509 web_data_service_->Shutdown();
529 } 510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698