diff options
author | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 17:47:57 +0000 |
---|---|---|
committer | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-16 17:47:57 +0000 |
commit | 1bcdb53dbddb785f5538cb7081b073db90c822d1 (patch) | |
tree | 9b67e0a51f98ff2d0f0bb3462f530a08a8b7e6c4 /chrome/common | |
parent | 091db5d0615084d28dfbb78d8dd6c0e169b510a4 (diff) | |
download | chromium_src-1bcdb53dbddb785f5538cb7081b073db90c822d1.zip chromium_src-1bcdb53dbddb785f5538cb7081b073db90c822d1.tar.gz chromium_src-1bcdb53dbddb785f5538cb7081b073db90c822d1.tar.bz2 |
mac bootstrapping of browser main and app startup bits
Review URL: http://codereview.chromium.org/18112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8185 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/chrome_paths.cc | 8 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.cpp | 204 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.h | 195 |
3 files changed, 405 insertions, 2 deletions
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index 7b2abc5..297b963 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -35,8 +35,12 @@ bool GetDefaultUserDataDirectory(std::wstring* result) { file_util::AppendToPath(result, chrome::kBrowserAppName); file_util::AppendToPath(result, chrome::kUserDataDirname); return true; -#else // defined(OS_WIN) - // TODO(port): Decide what to do on other platforms. +#elif defined(OS_MACOSX) + if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) + return false; + return true; +#elif defined(OS_LINUX) + // TODO(port): Decide what to do on linux. NOTIMPLEMENTED(); return false; #endif // defined(OS_WIN) diff --git a/chrome/common/temp_scaffolding_stubs.cpp b/chrome/common/temp_scaffolding_stubs.cpp new file mode 100644 index 0000000..756c8c2 --- /dev/null +++ b/chrome/common/temp_scaffolding_stubs.cpp @@ -0,0 +1,204 @@ +// Copyright (c) 2009 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 "temp_scaffolding_stubs.h" + +#include "base/file_util.h" +#include "base/thread.h" +#include "base/path_service.h" +#include "base/singleton.h" +#include "chrome/browser/plugin_service.h" +#include "chrome/browser/shell_integration.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/pref_service.h" + +BrowserProcessImpl::BrowserProcessImpl(CommandLine& command_line) + : created_local_state_(), created_metrics_service_(), + created_profile_manager_() { + g_browser_process = this; +} + +BrowserProcessImpl::~BrowserProcessImpl() { + g_browser_process = NULL; +} + +void BrowserProcessImpl::CreateLocalState() { + DCHECK(!created_local_state_ && local_state_.get() == NULL); + created_local_state_ = true; + + std::wstring local_state_path; + PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); + local_state_.reset(new PrefService(local_state_path)); +} + +void BrowserProcessImpl::CreateMetricsService() { + DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); + created_metrics_service_ = true; + + metrics_service_.reset(new MetricsService); +} + +void BrowserProcessImpl::CreateProfileManager() { + DCHECK(!created_profile_manager_ && profile_manager_.get() == NULL); + created_profile_manager_ = true; + + profile_manager_.reset(new ProfileManager()); +} + +MetricsService* BrowserProcessImpl::metrics_service() { + if (!created_metrics_service_) + CreateMetricsService(); + return metrics_service_.get(); +} + +ProfileManager* BrowserProcessImpl::profile_manager() { + if (!created_profile_manager_) + CreateProfileManager(); + return profile_manager_.get(); +} + +PrefService* BrowserProcessImpl::local_state() { + if (!created_local_state_) + CreateLocalState(); + return local_state_.get(); +} + +//-------------------------------------------------------------------------- + +static bool s_in_startup = false; + +bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line, + const std::wstring& cur_dir, + PrefService* prefs, bool process_startup, + Profile* profile, int* return_code) { + return LaunchBrowser(parsed_command_line, profile, cur_dir, + process_startup, return_code); +} + +bool BrowserInit::LaunchBrowser(const CommandLine& parsed_command_line, + Profile* profile, const std::wstring& cur_dir, + bool process_startup, int* return_code) { + s_in_startup = process_startup; + bool result = LaunchBrowserImpl(parsed_command_line, profile, cur_dir, + process_startup, return_code); + s_in_startup = false; + return result; +} + +bool BrowserInit::LaunchBrowserImpl(const CommandLine& parsed_command_line, + Profile* profile, + const std::wstring& cur_dir, + bool process_startup, + int* return_code) { + DCHECK(profile); + + // LAUNCH BROWSER WITH PROFILE HERE! + + return true; +} + +//-------------------------------------------------------------------------- + +UserDataManager* UserDataManager::instance_ = NULL; + +void UserDataManager::Create() { + DCHECK(!instance_); + std::wstring user_data; + PathService::Get(chrome::DIR_USER_DATA, &user_data); + instance_ = new UserDataManager(user_data); +} + +UserDataManager* UserDataManager::Get() { + DCHECK(instance_); + return instance_; +} + +//-------------------------------------------------------------------------- + +std::wstring ProfileManager::GetDefaultProfileDir( + const std::wstring& user_data_dir) { + std::wstring default_profile_dir(user_data_dir); + file_util::AppendToPath(&default_profile_dir, chrome::kNotSignedInProfile); + return default_profile_dir; +} + +std::wstring ProfileManager::GetDefaultProfilePath( + const std::wstring &profile_dir) { + std::wstring default_prefs_path(profile_dir); + file_util::AppendToPath(&default_prefs_path, chrome::kPreferencesFilename); + return default_prefs_path; +} + +Profile* ProfileManager::GetDefaultProfile(const std::wstring& user_data_dir) { + std::wstring default_profile_dir = GetDefaultProfileDir(user_data_dir); + return new Profile(default_profile_dir); +} + +//-------------------------------------------------------------------------- + +Profile::Profile(const std::wstring& path) + : path_(path) { +} + +std::wstring Profile::GetPrefFilePath() { + std::wstring pref_file_path = path_; + file_util::AppendToPath(&pref_file_path, chrome::kPreferencesFilename); + return pref_file_path; +} + +PrefService* Profile::GetPrefs() { + if (!prefs_.get()) + prefs_.reset(new PrefService(GetPrefFilePath())); + return prefs_.get(); +} + +//-------------------------------------------------------------------------- + +bool ShellIntegration::SetAsDefaultBrowser() { + return true; +} + +bool ShellIntegration::IsDefaultBrowser() { + return true; +} + +//-------------------------------------------------------------------------- + +namespace browser { +void RegisterAllPrefs(PrefService*, PrefService*) { } +} // namespace browser + +namespace browser_shutdown { +void ReadLastShutdownInfo() { } +void Shutdown() { } +} + +void OpenFirstRunDialog(Profile* profile) { } + +//-------------------------------------------------------------------------- + +PluginService* PluginService::GetInstance() { + return Singleton<PluginService>::get(); +} + +PluginService::PluginService() + : main_message_loop_(MessageLoop::current()), + resource_dispatcher_host_(NULL), + ui_locale_(g_browser_process->GetApplicationLocale()), + plugin_shutdown_handler_(NULL) { +} + +PluginService::~PluginService() { +} + +void PluginService::SetChromePluginDataDir(const std::wstring& data_dir) { + AutoLock lock(lock_); + chrome_plugin_data_dir_ = data_dir; +} + +//-------------------------------------------------------------------------- + +void InstallJankometer(const CommandLine&) { +} diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h new file mode 100644 index 0000000..f7f2bbb --- /dev/null +++ b/chrome/common/temp_scaffolding_stubs.h @@ -0,0 +1,195 @@ +// Copyright (c) 2009 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. + +#ifndef CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_ +#define CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_ + +// This file provides declarations and stub definitions for classes we encouter +// during the porting effort. It is not meant to be perminent, and classes will +// be removed from here as they are fleshed out more completely. + +#include <string> + +#include "base/basictypes.h" +#include "chrome/browser/browser_process.h" + +class CommandLine; +class ProfileManager; +class Profile; +class MetricsService; + +class Upgrade { + public: + static bool IsBrowserAlreadyRunning() { return false; } + static bool RelaunchChromeBrowser(const CommandLine& command_line) { + return true; + } + static bool SwapNewChromeExeIfPresent() { return true; } +}; + +class BrowserInit { + public: + // TODO(port): MessageWindow is very windows specific and shouldn't be part of + // BrowserInit at all. + class MessageWindow { + public: + explicit MessageWindow(const std::wstring& user_data_dir) { } + ~MessageWindow() { } + bool NotifyOtherProcess() { return false; } + void HuntForZombieChromeProcesses() { } + void Create() { } + void Lock() { } + void Unlock() { } + }; + static bool ProcessCommandLine(const CommandLine& parsed_command_line, + const std::wstring& cur_dir, + PrefService* prefs, bool process_startup, + Profile* profile, int* return_code); + static bool LaunchBrowser(const CommandLine& parsed_command_line, + Profile* profile, const std::wstring& cur_dir, + bool process_startup, int* return_code); + private: + static bool LaunchBrowserImpl(const CommandLine& parsed_command_line, + Profile* profile, const std::wstring& cur_dir, + bool process_startup, int* return_code); +}; + +class FirstRun { + public: + static bool IsChromeFirstRun() { return false; } + static bool ProcessMasterPreferences(const std::wstring& user_data_dir, + const std::wstring& master_prefs_path, + int* preference_details) { + return false; + } + static int ImportNow(Profile* profile, const CommandLine& cmdline) { + return 0; + } +}; + +class GoogleUpdateSettings { + public: + static bool GetCollectStatsConsent() { return false; } + static bool SetCollectStatsConsent(bool consented) { return false; } + static bool GetBrowser(std::wstring* browser) { return false; } + static bool GetLanguage(std::wstring* language) { return false; } + static bool GetBrand(std::wstring* brand) { return false; } + static bool GetReferral(std::wstring* referral) { return false; } + static bool ClearReferral() { return false; } + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(GoogleUpdateSettings); +}; + +class BrowserProcessImpl : public BrowserProcess { + public: + BrowserProcessImpl(CommandLine& command_line); + virtual ~BrowserProcessImpl(); + + virtual void EndSession() { } + virtual ResourceDispatcherHost* resource_dispatcher_host() { return NULL; } + virtual MetricsService* metrics_service(); + virtual ProfileManager* profile_manager(); + virtual PrefService* local_state(); + virtual DebuggerWrapper* debugger_wrapper() { return NULL; } + virtual ClipboardService* clipboard_service() { return NULL; } + virtual base::Thread* io_thread() { return NULL; } + virtual base::Thread* file_thread() { return NULL; } + virtual base::Thread* db_thread() { return NULL; } + virtual sandbox::BrokerServices* broker_services() { return NULL; } + virtual IconManager* icon_manager() { return NULL; } + virtual void InitBrokerServices(sandbox::BrokerServices*) { } + virtual AutomationProviderList* InitAutomationProviderList() { return NULL; } + virtual void InitDebuggerWrapper(int port) { } + virtual unsigned int AddRefModule() { return NULL; } + virtual unsigned int ReleaseModule() { return NULL; } + virtual bool IsShuttingDown() { return NULL; } + virtual views::AcceleratorHandler* accelerator_handler() { return NULL; } + virtual printing::PrintJobManager* print_job_manager() { return NULL; } + virtual GoogleURLTracker* google_url_tracker() { return NULL; } + virtual const std::wstring& GetApplicationLocale() { return locale_; } + virtual MemoryModel memory_model() { return MEDIUM_MEMORY_MODEL; } + virtual base::WaitableEvent* shutdown_event() { return NULL; } + private: + void CreateLocalState(); + void CreateProfileManager(); + void CreateMetricsService(); + + bool created_local_state_; + scoped_ptr<PrefService> local_state_; + bool created_metrics_service_; + scoped_ptr<MetricsService> metrics_service_; + bool created_profile_manager_; + scoped_ptr<ProfileManager> profile_manager_; + std::wstring locale_; +}; + +class FirstRunBrowserProcess : public BrowserProcessImpl { + public: + FirstRunBrowserProcess(CommandLine& command_line) + : BrowserProcessImpl(command_line) { + } + virtual ~FirstRunBrowserProcess() { } + virtual GoogleURLTracker* google_url_tracker() { return NULL; } + private: + DISALLOW_COPY_AND_ASSIGN(FirstRunBrowserProcess); +}; + +class UserDataManager { + public: + static void Create(); + static UserDataManager* Get(); + + explicit UserDataManager(const std::wstring& user_data_root) { } + private: + // Shared instance. + static UserDataManager* instance_; +}; + +class Profile { + public: + Profile(const std::wstring& user_data_dir); + virtual std::wstring GetPath() { return path_; } + virtual PrefService* GetPrefs(); + private: + std::wstring GetPrefFilePath(); + + std::wstring path_; + scoped_ptr<PrefService> prefs_; +}; + +class ProfileManager : NonThreadSafe { + public: + ProfileManager() { } + virtual ~ProfileManager() { } + Profile* GetDefaultProfile(const std::wstring& user_data_dir); + static std::wstring GetDefaultProfileDir(const std::wstring& user_data_dir); + static std::wstring GetDefaultProfilePath(const std::wstring& profile_dir); + private: + DISALLOW_EVIL_CONSTRUCTORS(ProfileManager); +}; + +class MetricsService { + public: + MetricsService() { } + ~MetricsService() { } + void Start() { } + void StartRecordingOnly() { } + void Stop() { } + void SetUserPermitsUpload(bool enabled) { } +}; + +namespace browser { +void RegisterAllPrefs(PrefService*, PrefService*); +} + +namespace browser_shutdown { +void ReadLastShutdownInfo(); +void Shutdown(); +} + +void OpenFirstRunDialog(Profile* profile); + +void InstallJankometer(const CommandLine&); + +#endif // CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_ |