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 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_TEST_TEST_CONTENT_BROWSER_CLIENT_H_ 6 #define CONTENT_TEST_TEST_CONTENT_BROWSER_CLIENT_H_ 7 8 #include <string> 9 10 #include "base/compiler_specific.h" 11 #include "base/files/scoped_temp_dir.h" 12 #include "base/macros.h" 13 #include "build/build_config.h" 14 #include "content/public/browser/content_browser_client.h" 15 16 namespace content { 17 18 // Base for unit tests that need a ContentBrowserClient. 19 class TestContentBrowserClient : public ContentBrowserClient { 20 public: 21 TestContentBrowserClient(); 22 ~TestContentBrowserClient() override; 23 24 static TestContentBrowserClient* GetInstance(); 25 set_application_locale(const std::string & locale)26 void set_application_locale(const std::string& locale) { 27 application_locale_ = locale; 28 } 29 30 // ContentBrowserClient: 31 base::FilePath GetDefaultDownloadDirectory() override; 32 GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings( 33 content::BrowserContext* context) override; 34 std::string GetUserAgent() override; 35 std::string GetApplicationLocale() override; 36 #if defined(OS_ANDROID) 37 void GetAdditionalMappedFilesForChildProcess( 38 const base::CommandLine& command_line, 39 int child_process_id, 40 content::PosixFileDescriptorInfo* mappings) override; 41 #endif // defined(OS_ANDROID) 42 43 private: 44 // Temporary directory for GetDefaultDownloadDirectory. 45 base::ScopedTempDir download_dir_; 46 std::string application_locale_; 47 static TestContentBrowserClient* instance_; 48 49 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); 50 }; 51 52 } // namespace content 53 54 #endif // CONTENT_TEST_TEST_CONTENT_BROWSER_CLIENT_H_ 55