summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-31 20:18:52 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-31 20:18:52 +0000
commita814d863440f0a154a7299f2d8b440f405c7700e (patch)
tree9aa8723a4c235299da0f17dbef32f89e0d3a91ac /chrome
parent3dc08620970265dcca2b0d79ef9325d25a0b647b (diff)
downloadchromium_src-a814d863440f0a154a7299f2d8b440f405c7700e.zip
chromium_src-a814d863440f0a154a7299f2d8b440f405c7700e.tar.gz
chromium_src-a814d863440f0a154a7299f2d8b440f405c7700e.tar.bz2
Re-land this changelist to make BrowserInit work on Mac.
R=pinkerton,brettw Review URL: http://codereview.chromium.org/19528 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.scons2
-rw-r--r--chrome/browser/browser_init.cc225
-rw-r--r--chrome/browser/browser_init.h20
-rw-r--r--chrome/browser/browser_main.cc9
-rw-r--r--chrome/browser/browser_prefs.cc12
-rw-r--r--chrome/browser/message_window.cc3
-rw-r--r--chrome/chrome.xcodeproj/project.pbxproj4
-rw-r--r--chrome/common/temp_scaffolding_stubs.cc72
-rw-r--r--chrome/common/temp_scaffolding_stubs.h78
9 files changed, 225 insertions, 200 deletions
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons
index 09ab7e5..630259c 100644
--- a/chrome/browser/browser.scons
+++ b/chrome/browser/browser.scons
@@ -691,8 +691,6 @@ if not env.Bit('windows'):
'browser_about_handler.cc',
'browser_accessibility.cc',
'browser_accessibility_manager.cc',
- 'browser_init.cc',
- 'browser_prefs.cc',
'browser_process_impl.cc',
'browser_shutdown.cc',
'browser_url_handler.cc',
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index bf9f69bf..1ef6a9b 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -9,38 +9,43 @@
#include "base/event_recorder.h"
#include "base/path_service.h"
#include "base/string_util.h"
-#include "base/win_util.h"
-#include "chrome/app/locales/locale_settings.h"
#include "chrome/app/result_codes.h"
-#include "chrome/app/theme/theme_resources.h"
-#include "chrome/browser/automation/automation_provider.h"
-#include "chrome/browser/automation/automation_provider_list.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/net/dns_global.h"
-#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
-#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/session_startup_pref.h"
-#include "chrome/browser/sessions/session_restore.h"
-#include "chrome/browser/tab_contents/infobar_delegate.h"
-#include "chrome/browser/tab_contents/navigation_controller.h"
-#include "chrome/browser/web_app_launcher.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
-#include "chrome/common/resource_bundle.h"
#include "net/base/cookie_monster.h"
#include "webkit/glue/webkit_glue.h"
+#if defined(OS_WIN)
+
+#include "base/win_util.h"
+#include "chrome/app/locales/locale_settings.h"
+#include "chrome/app/theme/theme_resources.h"
+#include "chrome/browser/automation/automation_provider.h"
+#include "chrome/browser/automation/automation_provider_list.h"
+#include "chrome/browser/net/url_fixer_upper.h"
+#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/browser/sessions/session_restore.h"
+#include "chrome/browser/tab_contents/infobar_delegate.h"
+#include "chrome/browser/tab_contents/navigation_controller.h"
+#include "chrome/browser/web_app_launcher.h"
+#include "chrome/common/resource_bundle.h"
+
#include "chromium_strings.h"
#include "generated_resources.h"
+#endif
+
namespace {
// A delegate for the InfoBar shown when the previous session has crashed. The
@@ -59,15 +64,30 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
delete this;
}
virtual std::wstring GetMessageText() const {
+#if defined(OS_WIN)
return l10n_util::GetString(IDS_SESSION_CRASHED_VIEW_MESSAGE);
+#else
+ // TODO(port): implement session crashed info bar.
+ return L"Portme";
+#endif
}
virtual SkBitmap* GetIcon() const {
+#if defined(OS_WIN)
return ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_INFOBAR_RESTORE_SESSION);
+#else
+ // TODO(port): implement session crashed info bar.
+ return NULL;
+#endif
}
virtual int GetButtons() const { return BUTTON_OK; }
virtual std::wstring GetButtonLabel(InfoBarButton button) const {
+#if defined(OS_WIN)
return l10n_util::GetString(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON);
+#else
+ // TODO(port): implement session crashed info bar.
+ return L"Portme";
+#endif
}
virtual bool Accept() {
// Restore the session.
@@ -83,25 +103,26 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
};
-void SetOverrideHomePage(const CommandLine& command_line, PrefService* prefs) {
+void SetOverrideHomePage(PrefService* prefs) {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
// If homepage is specified on the command line, canonify & store it.
- if (command_line.HasSwitch(switches::kHomePage)) {
+ if (command_line->HasSwitch(switches::kHomePage)) {
std::wstring browser_directory;
PathService::Get(base::DIR_CURRENT, &browser_directory);
std::wstring new_homepage = URLFixerUpper::FixupRelativeFile(
browser_directory,
- command_line.GetSwitchValue(switches::kHomePage));
+ command_line->GetSwitchValue(switches::kHomePage));
prefs->transient()->SetString(prefs::kHomePage, new_homepage);
prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false);
}
}
-SessionStartupPref GetSessionStartupPref(Profile* profile,
- const CommandLine& command_line) {
+SessionStartupPref GetSessionStartupPref(Profile* profile) {
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
- if (command_line.HasSwitch(switches::kRestoreLastSession))
+ if (command_line->HasSwitch(switches::kRestoreLastSession))
pref.type = SessionStartupPref::LAST;
- if (command_line.HasSwitch(switches::kIncognito) &&
+ if (command_line->HasSwitch(switches::kIncognito) &&
pref.type == SessionStartupPref::LAST) {
// We don't store session information when incognito. If the user has
// chosen to restore last session and launched incognito, fallback to
@@ -122,10 +143,8 @@ bool BrowserInit::InProcessStartup() {
// LaunchWithProfile ----------------------------------------------------------
-BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir,
- const std::wstring& cmd_line)
- : command_line_(cmd_line),
- cur_dir_(cur_dir) {
+BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir)
+ : cur_dir_(cur_dir) {
}
bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
@@ -133,21 +152,19 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
DCHECK(profile);
profile_ = profile;
- CommandLine parsed_command_line(L"");
- parsed_command_line.ParseFromString(command_line_);
- if (parsed_command_line.HasSwitch(switches::kDnsLogDetails))
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kDnsLogDetails))
chrome_browser_net::EnableDnsDetailedLog(true);
- if (parsed_command_line.HasSwitch(switches::kDnsPrefetchDisable))
+ if (command_line->HasSwitch(switches::kDnsPrefetchDisable))
chrome_browser_net::EnableDnsPrefetch(false);
- if (parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit)) {
+ if (command_line->HasSwitch(switches::kDumpHistogramsOnExit))
StatisticsRecorder::set_dump_on_exit(true);
- }
- if (parsed_command_line.HasSwitch(switches::kRemoteShellPort)) {
+ if (command_line->HasSwitch(switches::kRemoteShellPort)) {
if (!RenderProcessHost::run_renderer_in_process()) {
std::wstring port_str =
- parsed_command_line.GetSwitchValue(switches::kRemoteShellPort);
+ command_line->GetSwitchValue(switches::kRemoteShellPort);
int64 port = StringToInt64(port_str);
if (port > 0 && port < 65535) {
g_browser_process->InitDebuggerWrapper(static_cast<int>(port));
@@ -157,29 +174,29 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
}
}
- if (parsed_command_line.HasSwitch(switches::kEnableFileCookies))
+ if (command_line->HasSwitch(switches::kEnableFileCookies))
net::CookieMonster::EnableFileScheme();
- if (parsed_command_line.HasSwitch(switches::kUserAgent)) {
+ if (command_line->HasSwitch(switches::kUserAgent)) {
+#if defined(OS_WIN)
webkit_glue::SetUserAgent(WideToUTF8(
- parsed_command_line.GetSwitchValue(switches::kUserAgent)));
+ command_line->GetSwitchValue(switches::kUserAgent)));
+ // TODO(port): hook this up when we bring in webkit.
+#endif
}
#ifndef NDEBUG
- if (parsed_command_line.HasSwitch(switches::kApp)) {
+ if (command_line->HasSwitch(switches::kApp))
NOTREACHED();
- }
#endif // NDEBUG
- std::vector<GURL> urls_to_open = GetURLsFromCommandLine(parsed_command_line,
- profile_);
+ std::vector<GURL> urls_to_open = GetURLsFromCommandLine(profile_);
Browser* browser = NULL;
// Always attempt to restore the last session. OpenStartupURLs only opens the
// home pages if no additional URLs were passed on the command line.
- bool opened_startup_urls =
- OpenStartupURLs(process_startup, parsed_command_line, urls_to_open);
+ bool opened_startup_urls = OpenStartupURLs(process_startup, urls_to_open);
if (!opened_startup_urls) {
if (urls_to_open.empty()) {
@@ -190,9 +207,14 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
// Reset the preference so we don't show the welcome page next time.
prefs->ClearPref(prefs::kShouldShowWelcomePage);
+#if defined(OS_WIN)
// Add the welcome page.
std::wstring welcome_url = l10n_util::GetString(IDS_WELCOME_PAGE_URL);
urls_to_open.push_back(GURL(welcome_url));
+#else
+ // TODO(port): implement welcome page.
+ NOTIMPLEMENTED();
+#endif
}
} else {
browser = BrowserList::GetLastActive();
@@ -207,13 +229,12 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
if (browser) {
// If we're recording or playing back, startup the EventRecorder now
// unless otherwise specified.
- if (!parsed_command_line.HasSwitch(switches::kNoEvents)) {
+ if (!command_line->HasSwitch(switches::kNoEvents)) {
std::wstring script_path;
PathService::Get(chrome::FILE_RECORDED_SCRIPT, &script_path);
- bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode);
- bool playback_mode =
- parsed_command_line.HasSwitch(switches::kPlaybackMode);
+ bool record_mode = command_line->HasSwitch(switches::kRecordMode);
+ bool playback_mode = command_line->HasSwitch(switches::kPlaybackMode);
if (record_mode && chrome::kRecordModeEnabled)
base::EventRecorder::current()->StartRecording(script_path);
@@ -227,16 +248,16 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
bool BrowserInit::LaunchWithProfile::OpenStartupURLs(
bool is_process_startup,
- const CommandLine& command_line,
const std::vector<GURL>& urls_to_open) {
- SessionStartupPref pref = GetSessionStartupPref(profile_, command_line);
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ SessionStartupPref pref = GetSessionStartupPref(profile_);
switch (pref.type) {
case SessionStartupPref::LAST:
if (!is_process_startup)
return false;
if (!profile_->DidLastSessionExitCleanly() &&
- !command_line.HasSwitch(switches::kRestoreLastSession)) {
+ !command_line->HasSwitch(switches::kRestoreLastSession)) {
// The last session crashed. It's possible automatically loading the
// page will trigger another crash, locking the user out of chrome.
// To avoid this, don't restore on startup but instead show the crashed
@@ -294,62 +315,72 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
}
std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
- const CommandLine& command_line, Profile* profile) {
+ Profile* profile) {
std::vector<GURL> urls;
- std::vector<std::wstring> params = command_line.GetLooseValues();
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ std::vector<std::wstring> params = command_line->GetLooseValues();
for (size_t i = 0; i < params.size(); ++i) {
- const std::wstring& value = params[i];
+ std::wstring& value = params[i];
// Handle Vista way of searching - "? <search-term>"
if (value.find(L"? ") == 0) {
- const TemplateURL* const default_provider =
+ const TemplateURL* default_provider =
profile->GetTemplateURLModel()->GetDefaultSearchProvider();
if (!default_provider || !default_provider->url()) {
// No search provider available. Just treat this as regular URL.
- urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_,
- value)));
+ urls.push_back(
+ GURL(WideToUTF8(URLFixerUpper::FixupRelativeFile(cur_dir_,
+ value))));
continue;
}
- const TemplateURLRef* const search_url = default_provider->url();
+ const TemplateURLRef* search_url = default_provider->url();
DCHECK(search_url->SupportsReplacement());
urls.push_back(GURL(search_url->ReplaceSearchTerms(*default_provider,
value.substr(2), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
std::wstring())));
} else {
// This will create a file URL or a regular URL.
- urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_, value)));
+ urls.push_back(GURL(WideToUTF8(
+ URLFixerUpper::FixupRelativeFile(cur_dir_, value))));
}
}
return urls;
}
-bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line,
+bool BrowserInit::ProcessCommandLine(
const std::wstring& cur_dir, PrefService* prefs, bool process_startup,
Profile* profile, int* return_code) {
DCHECK(profile);
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
if (process_startup) {
const std::wstring popup_count_string =
- parsed_command_line.GetSwitchValue(switches::kOmniBoxPopupCount);
+ command_line->GetSwitchValue(switches::kOmniBoxPopupCount);
if (!popup_count_string.empty()) {
- const int popup_count = std::max(0, _wtoi(popup_count_string.c_str()));
- AutocompleteResult::set_max_matches(popup_count);
- AutocompleteProvider::set_max_matches(popup_count / 2);
+ int count = 0;
+ if (StringToInt(popup_count_string, &count)) {
+ const int popup_count = std::max(0, count);
+ AutocompleteResult::set_max_matches(popup_count);
+ AutocompleteProvider::set_max_matches(popup_count / 2);
+ }
}
- if (parsed_command_line.HasSwitch(switches::kDisablePromptOnRepost))
+ if (command_line->HasSwitch(switches::kDisablePromptOnRepost))
NavigationController::DisablePromptOnRepost();
const std::wstring tab_count_string =
- parsed_command_line.GetSwitchValue(
- switches::kTabCountToLoadOnSessionRestore);
+ command_line->GetSwitchValue(switches::kTabCountToLoadOnSessionRestore);
if (!tab_count_string.empty()) {
- const int tab_count = std::max(0, _wtoi(tab_count_string.c_str()));
- SessionRestore::num_tabs_to_load_ = static_cast<size_t>(tab_count);
+ int count = 0;
+ if (StringToInt(tab_count_string, &count)) {
+ const int tab_count = std::max(0, count);
+ SessionRestore::num_tabs_to_load_ = static_cast<size_t>(tab_count);
+ }
}
-
+
+#if defined(OS_WIN)
// Look for the testing channel ID ONLY during process startup
- if (parsed_command_line.HasSwitch(switches::kTestingChannelID)) {
+ if (command_line->HasSwitch(switches::kTestingChannelID)) {
std::wstring testing_channel_id =
- parsed_command_line.GetSwitchValue(switches::kTestingChannelID);
+ command_line->GetSwitchValue(switches::kTestingChannelID);
// TODO(sanjeevr) Check if we need to make this a singleton for
// compatibility with the old testing code
// If there are any loose parameters, we expect each one to generate a
@@ -357,39 +388,42 @@ bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line,
CreateAutomationProvider<TestingAutomationProvider>(
testing_channel_id,
profile,
- std::max(static_cast<int>(parsed_command_line.GetLooseValues().size()),
+ std::max(static_cast<int>(command_line->GetLooseValues().size()),
1));
}
+#endif
}
// Allow the command line to override the persisted setting of home page.
- SetOverrideHomePage(parsed_command_line, profile->GetPrefs());
+ SetOverrideHomePage(profile->GetPrefs());
- if (parsed_command_line.HasSwitch(switches::kBrowserStartRenderersManually))
+ if (command_line->HasSwitch(switches::kBrowserStartRenderersManually))
prefs->transient()->SetBoolean(prefs::kStartRenderersManually, true);
bool silent_launch = false;
- if (parsed_command_line.HasSwitch(switches::kAutomationClientChannelID)) {
+#if defined(OS_WIN)
+ if (command_line->HasSwitch(switches::kAutomationClientChannelID)) {
std::wstring automation_channel_id =
- parsed_command_line.GetSwitchValue(switches::kAutomationClientChannelID);
+ command_line->GetSwitchValue(switches::kAutomationClientChannelID);
// If there are any loose parameters, we expect each one to generate a
// new tab; if there are none then we have no tabs
size_t expected_tabs =
- std::max(static_cast<int>(parsed_command_line.GetLooseValues().size()),
+ std::max(static_cast<int>(command_line->GetLooseValues().size()),
0);
- if (expected_tabs == 0) {
+ if (expected_tabs == 0)
silent_launch = true;
- }
CreateAutomationProvider<AutomationProvider>(automation_channel_id,
profile, expected_tabs);
}
- // Start up the extensions service
+ // Start up the extensions service http://crbug.com/7265
profile->InitExtensions();
+ // TODO(port): figure out why this call crashes.
+#endif
- if (parsed_command_line.HasSwitch(switches::kInstallExtension)) {
+ if (command_line->HasSwitch(switches::kInstallExtension)) {
std::wstring path_string =
- parsed_command_line.GetSwitchValue(switches::kInstallExtension);
+ command_line->GetSwitchValue(switches::kInstallExtension);
FilePath path = FilePath::FromWStringHack(path_string);
profile->GetExtensionsService()->InstallExtension(path);
silent_launch = true;
@@ -397,23 +431,21 @@ bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line,
// If we don't want to launch a new browser window or tab (in the case
// of an automation request), we are done here.
- if (!silent_launch) {
- return LaunchBrowser(parsed_command_line, profile, cur_dir,
- process_startup, return_code);
- }
+ if (!silent_launch)
+ return LaunchBrowser(profile, cur_dir, process_startup, return_code);
return true;
}
-
-bool BrowserInit::LaunchBrowser(const CommandLine& parsed_command_line,
- Profile* profile, const std::wstring& cur_dir,
+
+bool BrowserInit::LaunchBrowser(Profile* profile, const std::wstring& cur_dir,
bool process_startup, int* return_code) {
in_startup = process_startup;
- bool result = LaunchBrowserImpl(parsed_command_line, profile, cur_dir,
- process_startup, return_code);
+ bool result = LaunchBrowserImpl(profile, cur_dir, process_startup,
+ return_code);
in_startup = false;
return result;
}
+#if defined(OS_WIN)
template <class AutomationProviderClass>
void BrowserInit::CreateAutomationProvider(const std::wstring& channel_id,
Profile* profile,
@@ -424,26 +456,27 @@ void BrowserInit::CreateAutomationProvider(const std::wstring& channel_id,
automation->SetExpectedTabCount(expected_tabs);
AutomationProviderList* list =
- g_browser_process->InitAutomationProviderList();
- DCHECK(list);
+ g_browser_process->InitAutomationProviderList(); DCHECK(list);
list->AddProvider(automation);
}
+#endif
-bool BrowserInit::LaunchBrowserImpl(const CommandLine& parsed_command_line,
- Profile* profile,
+bool BrowserInit::LaunchBrowserImpl(Profile* profile,
const std::wstring& cur_dir,
bool process_startup,
int* return_code) {
DCHECK(profile);
+
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
// Continue with the off-the-record profile from here on if --incognito
- if (parsed_command_line.HasSwitch(switches::kIncognito))
+ if (command_line->HasSwitch(switches::kIncognito))
profile = profile->GetOffTheRecordProfile();
// Are we starting an application?
- std::wstring app_url = parsed_command_line.GetSwitchValue(switches::kApp);
+ std::wstring app_url = command_line->GetSwitchValue(switches::kApp);
if (!app_url.empty()) {
- GURL url(app_url);
+ GURL url(WideToUTF8(app_url));
// If the application is started for a mailto:url, this machine has some
// old configuration that we should ignore. This hack saves us from some
// infinite loops where we keep forwarding mailto: to the system, resulting
@@ -455,7 +488,7 @@ bool BrowserInit::LaunchBrowserImpl(const CommandLine& parsed_command_line,
return true;
}
- LaunchWithProfile lwp(cur_dir, parsed_command_line.command_line_string());
+ LaunchWithProfile lwp(cur_dir);
bool launched = lwp.Launch(profile, process_startup);
if (!launched) {
LOG(ERROR) << "launch error";
diff --git a/chrome/browser/browser_init.h b/chrome/browser/browser_init.h
index 5e11811..6475b9f 100644
--- a/chrome/browser/browser_init.h
+++ b/chrome/browser/browser_init.h
@@ -11,7 +11,6 @@
#include "base/basictypes.h"
class Browser;
-class CommandLine;
class GURL;
class PrefService;
class Profile;
@@ -31,8 +30,7 @@ class BrowserInit {
class LaunchWithProfile {
public:
- LaunchWithProfile(const std::wstring& cur_dir,
- const std::wstring& cmd_line);
+ explicit LaunchWithProfile(const std::wstring& cur_dir);
~LaunchWithProfile() { }
// Creates the necessary windows for startup. Returns true on success,
@@ -51,7 +49,6 @@ class BrowserInit {
//
// Otherwise false is returned.
bool OpenStartupURLs(bool is_process_startup,
- const CommandLine& command_line,
const std::vector<GURL>& urls_to_open);
// Opens the list of urls. If browser is non-null and a tabbed browser, the
@@ -68,11 +65,9 @@ class BrowserInit {
// Returns the list of URLs to open from the command line. The returned
// vector is empty if the user didn't specify any URLs on the command line.
- std::vector<GURL> GetURLsFromCommandLine(const CommandLine& command_line,
- Profile* profile);
+ std::vector<GURL> GetURLsFromCommandLine(Profile* profile);
std::wstring cur_dir_;
- std::wstring command_line_;
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile);
@@ -83,26 +78,25 @@ class BrowserInit {
// process (via the WM_COPYDATA message). The process_startup flag
// indicates if this is being called from the process startup code or
// the WM_COPYDATA handler.
- static bool ProcessCommandLine(const CommandLine& parsed_command_line,
- const std::wstring& cur_dir,
+ static bool ProcessCommandLine(const std::wstring& cur_dir,
PrefService* prefs, bool process_startup,
Profile* profile, int* return_code);
// Helper function to launch a new browser based on command-line arguments
// This function takes in a specific profile to use.
- static bool LaunchBrowser(const CommandLine& parsed_command_line,
- Profile* profile, const std::wstring& cur_dir,
+ static bool LaunchBrowser(Profile* profile, const std::wstring& cur_dir,
bool process_startup, int* return_code);
+#if defined(OS_WIN)
template <class AutomationProviderClass>
static void CreateAutomationProvider(const std::wstring& channel_id,
Profile* profile,
size_t expected_tabs);
+#endif
private:
// Does the work of LaunchBrowser returning the result.
- static bool LaunchBrowserImpl(const CommandLine& parsed_command_line,
- Profile* profile, const std::wstring& cur_dir,
+ static bool LaunchBrowserImpl(Profile* profile, const std::wstring& cur_dir,
bool process_startup, int* return_code);
// This class is for scoping purposes.
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 5d2b149..0898d44 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -20,6 +20,9 @@
#include "base/values.h"
#include "chrome/app/result_codes.h"
#include "chrome/browser/browser_main_win.h"
+#include "chrome/browser/browser_init.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/profile_manager.h"
@@ -56,9 +59,6 @@
#include "base/win_util.h"
#include "chrome/browser/automation/automation_provider.h"
#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_init.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_trial.h"
@@ -547,8 +547,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
if (parameters.ui_task) {
MessageLoopForUI::current()->PostTask(FROM_HERE, parameters.ui_task);
RunUIMessageLoop(browser_process.get());
- } else if (BrowserInit::ProcessCommandLine(parsed_command_line,
- std::wstring(), local_state, true,
+ } else if (BrowserInit::ProcessCommandLine(std::wstring(), local_state, true,
profile, &result_code)) {
RunUIMessageLoop(browser_process.get());
}
diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc
index a33c68a..ca50616 100644
--- a/chrome/browser/browser_prefs.cc
+++ b/chrome/browser/browser_prefs.cc
@@ -5,6 +5,9 @@
#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/session_startup_pref.h"
+
+#if defined(OS_WIN)
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/cache_manager_host.h"
#include "chrome/browser/net/dns_global.h"
@@ -15,10 +18,8 @@
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
-#include "chrome/browser/session_startup_pref.h"
#include "chrome/browser/spellchecker.h"
#include "chrome/browser/ssl/ssl_manager.h"
-#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/task_manager.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/views/bookmark_bar_view.h"
@@ -28,11 +29,13 @@
#include "chrome/browser/views/keyword_editor_view.h"
#include "chrome/browser/views/page_info_window.h"
#include "chrome/browser/tab_contents/web_contents.h"
+#endif
namespace browser {
void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) {
// Prefs in Local State
+#if defined(OS_WIN)
BookmarkManagerView::RegisterPrefs(local_state);
Browser::RegisterPrefs(local_state);
BrowserView::RegisterBrowserViewPrefs(local_state);
@@ -47,19 +50,22 @@ void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state) {
TaskManager::RegisterPrefs(local_state);
ExternalProtocolHandler::RegisterPrefs(local_state);
SafeBrowsingService::RegisterPrefs(local_state);
+#endif
// User prefs
+ SessionStartupPref::RegisterUserPrefs(user_prefs);
+#if defined(OS_WIN)
BookmarkBarView::RegisterUserPrefs(user_prefs);
BookmarkTableView::RegisterUserPrefs(user_prefs);
Browser::RegisterUserPrefs(user_prefs);
chrome_browser_net::RegisterUserPrefs(user_prefs);
DownloadManager::RegisterUserPrefs(user_prefs);
PasswordManager::RegisterUserPrefs(user_prefs);
- SessionStartupPref::RegisterUserPrefs(user_prefs);
SSLManager::RegisterUserPrefs(user_prefs);
TabContents::RegisterUserPrefs(user_prefs);
TemplateURLPrepopulateData::RegisterUserPrefs(user_prefs);
WebContents::RegisterUserPrefs(user_prefs);
+#endif
}
} // namespace browser
diff --git a/chrome/browser/message_window.cc b/chrome/browser/message_window.cc
index 1def5a7..0375a5d 100644
--- a/chrome/browser/message_window.cc
+++ b/chrome/browser/message_window.cc
@@ -209,8 +209,7 @@ LRESULT MessageWindow::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
NOTREACHED();
return TRUE;
}
- BrowserInit::ProcessCommandLine(parsed_command_line, cur_dir, prefs, false,
- profile, NULL);
+ BrowserInit::ProcessCommandLine(cur_dir, prefs, false, profile, NULL);
return TRUE;
}
return TRUE;
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj
index 31d013f..71fbd8a 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -261,6 +261,8 @@
B5FDC1D40EE48ADB00BEC6E6 /* libicudata.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFE690E9D52DC009A6919 /* libicudata.a */; };
B5FDC1D60EE48ADB00BEC6E6 /* libicuuc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFE710E9D52DC009A6919 /* libicuuc.a */; };
B5FDC2180EE48F4100BEC6E6 /* libicui18n.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFE6D0E9D52DC009A6919 /* libicui18n.a */; };
+ B61C4C1F0F3284A700489E0F /* browser_init.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF83A0E9D4839009A6919 /* browser_init.cc */; };
+ B61C4CFA0F329ACE00489E0F /* browser_prefs.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF83F0E9D4839009A6919 /* browser_prefs.cc */; };
B6CCB9FA0F1EC33100106F0D /* provisional_load_details.cc in Sources */ = {isa = PBXBuildFile; fileRef = B6CCB9DE0F1EC32700106F0D /* provisional_load_details.cc */; };
B9BF55F87A4BB2FD366B6DDC /* template_url_parser.cc in Sources */ = {isa = PBXBuildFile; fileRef = 28AA584AB2ECFB33C7C7FD8A /* template_url_parser.cc */; };
E40CC5E30F2E348900708647 /* history_contents_provider.cc in Sources */ = {isa = PBXBuildFile; fileRef = E40CC5E10F2E348900708647 /* history_contents_provider.cc */; };
@@ -4504,9 +4506,11 @@
E45075B40F1505C9003BE099 /* bookmark_html_writer.cc in Sources */,
E40CC5F70F2E351A00708647 /* bookmark_table_model.cc in Sources */,
E46C4C2E0F212CAF00B393B8 /* browser.cc in Sources */,
+ B61C4C1F0F3284A700489E0F /* browser_init.cc in Sources */,
E46C4D0F0F2138D400B393B8 /* browser_list.cc in Sources */,
E45063530EE9BF31003BE099 /* browser_main.cc in Sources */,
E450634F0EE9BE29003BE099 /* browser_main_mac.mm in Sources */,
+ B61C4CFA0F329ACE00489E0F /* browser_prefs.cc in Sources */,
4D7BF97B0E9D4857009A6919 /* browser_process.cc in Sources */,
A76E43A40F29039C009A7E88 /* browser_render_process_host.cc in Sources */,
E45075B80F15060C003BE099 /* browser_trial.cc in Sources */,
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index 735a48e7..c6812d8 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -20,6 +20,9 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_service.h"
+// static
+size_t SessionRestore::num_tabs_to_load_ = 0;
+
BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
: main_notification_service_(new NotificationService),
memory_model_(HIGH_MEMORY_MODEL),
@@ -75,63 +78,6 @@ PrefService* BrowserProcessImpl::local_state() {
//--------------------------------------------------------------------------
-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);
-
- // this code is a simplification of BrowserInit::LaunchWithProfile::Launch()
- std::vector<GURL> urls_to_open;
- urls_to_open.push_back(GURL("http://dev.chromium.org"));
- urls_to_open.push_back(GURL("http://crbug.com"));
- urls_to_open.push_back(GURL("http://icanhascheezeburger.com"));
- Browser* browser = NULL;
- browser = OpenURLsInBrowser(browser, profile, urls_to_open);
-
- return true;
-}
-
-// a simplification of BrowserInit::LaunchWithProfile::OpenURLsInBrowser
-Browser* BrowserInit::OpenURLsInBrowser(
- Browser* browser,
- Profile* profile,
- const std::vector<GURL>& urls) {
- DCHECK(!urls.empty());
- if (!browser || browser->type() != Browser::TYPE_NORMAL)
- browser = Browser::Create(profile);
-
- for (size_t i = 0; i < urls.size(); ++i) {
- browser->AddTabWithURL(
- urls[i], GURL(), PageTransition::START_PAGE, (i == 0), NULL);
- }
- browser->window()->Show();
- return browser;
-}
-
-//--------------------------------------------------------------------------
-
UserDataManager* UserDataManager::instance_ = NULL;
UserDataManager* UserDataManager::Create() {
@@ -157,10 +103,6 @@ bool ShellIntegration::IsDefaultBrowser() {
//--------------------------------------------------------------------------
-namespace browser {
-void RegisterAllPrefs(PrefService*, PrefService*) { }
-} // namespace browser
-
namespace browser_shutdown {
void ReadLastShutdownInfo() { }
void Shutdown() { }
@@ -253,3 +195,11 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
return NULL;
}
#endif
+
+//--------------------------------------------------------------------------
+
+namespace chrome_browser_net {
+
+void EnableDnsPrefetch(bool) {}
+
+} // namespace chrome_browser_net
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 79ea9c5..45f2925 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -37,6 +37,8 @@ class SessionID;
class SiteInstance;
class SpellChecker;
class TabContents;
+class TemplateURL;
+class TemplateURLRef;
class URLRequestContext;
class UserScriptMaster;
class VisitedLinkMaster;
@@ -68,24 +70,6 @@ class MessageWindow {
void Unlock() { }
};
-class BrowserInit {
- public:
- 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);
- static Browser* OpenURLsInBrowser(Browser* browser,
- Profile* profile,
- const std::vector<GURL>& urls);
-};
-
class FirstRun {
public:
static bool IsChromeFirstRun() { return false; }
@@ -188,6 +172,20 @@ class SessionService : public base::RefCountedThreadSafe<SessionService> {
void TabRestored(NavigationController*) { }
};
+class SessionRestore {
+ public:
+ static void RestoreSession(Profile* profile,
+ Browser* browser,
+ bool clobber_existing_window,
+ bool always_create_tabbed_browser,
+ const std::vector<GURL>& urls_to_open) {}
+ static void RestoreSessionSynchronously(
+ Profile* profile,
+ const std::vector<GURL>& urls_to_open) {}
+
+ static size_t num_tabs_to_load_;
+};
+
class TabRestoreService : public base::RefCountedThreadSafe<TabRestoreService> {
public:
explicit TabRestoreService(Profile* profile) { }
@@ -290,6 +288,8 @@ class NavigationController {
NavigationEntry* GetActiveEntry() const { return entry_.get(); }
void LoadURL(const GURL& url, const GURL& referrer,
PageTransition::Type type) { }
+ static void DisablePromptOnRepost() {}
+
private:
scoped_ptr<NavigationEntry> entry_;
};
@@ -306,6 +306,20 @@ class InterstitialPage {
virtual void DontProceed() { }
};
+class InfoBarDelegate {
+};
+
+class ConfirmInfoBarDelegate : public InfoBarDelegate {
+ public:
+ explicit ConfirmInfoBarDelegate(TabContents* contents) {}
+
+ enum InfoBarButton {
+ BUTTON_NONE = 0,
+ BUTTON_OK,
+ BUTTON_CANCEL
+ };
+};
+
class RenderViewHost {
public:
bool HasUnloadListener() const { return false; }
@@ -333,6 +347,9 @@ class TabContents {
static TabContents* CreateWithType(TabContentsType type,
Profile* profile,
SiteInstance* instance);
+ void AddInfoBar(InfoBarDelegate* delegate) {}
+
+ Profile* profile() const { return NULL; }
private:
GURL url_;
std::wstring title_;
@@ -433,6 +450,30 @@ class SpellChecker : public base::RefCountedThreadSafe<SpellChecker> {
const std::wstring& custom_dictionary_file_name) {}
};
+class WebAppLauncher {
+ public:
+ static void Launch(Profile* profile, const GURL& url) {
+ }
+};
+
+class AutocompleteResult {
+ public:
+ static void set_max_matches(int) { }
+};
+
+class AutocompleteProvider {
+ public:
+ static void set_max_matches(int) {}
+};
+
+class URLFixerUpper {
+ public:
+ static std::wstring FixupRelativeFile(const std::wstring& base_dir,
+ const std::wstring& text) {
+ return L"about:blank";
+ }
+};
+
class TemplateURLModel {
public:
explicit TemplateURLModel(Profile* profile) { }
@@ -440,6 +481,7 @@ class TemplateURLModel {
return L"";
}
static GURL GenerateSearchURL(const TemplateURL* t_url) { return GURL(); }
+ TemplateURL* GetDefaultSearchProvider() { return NULL; }
};
#endif // CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_