summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_init.cc227
-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.cc74
-rw-r--r--chrome/common/temp_scaffolding_stubs.h86
8 files changed, 199 insertions, 236 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 5deb406..bf9f69bf 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -9,43 +9,38 @@
#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/dns_global.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
@@ -64,30 +59,15 @@ 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.
@@ -103,26 +83,25 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
};
-void SetOverrideHomePage(PrefService* prefs) {
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
+void SetOverrideHomePage(const CommandLine& command_line, PrefService* prefs) {
// 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 = CommandLine::ForCurrentProcess();
+SessionStartupPref GetSessionStartupPref(Profile* profile,
+ const CommandLine& command_line) {
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
@@ -143,8 +122,10 @@ bool BrowserInit::InProcessStartup() {
// LaunchWithProfile ----------------------------------------------------------
-BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir)
- : cur_dir_(cur_dir) {
+BrowserInit::LaunchWithProfile::LaunchWithProfile(const std::wstring& cur_dir,
+ const std::wstring& cmd_line)
+ : command_line_(cmd_line),
+ cur_dir_(cur_dir) {
}
bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
@@ -152,19 +133,21 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
DCHECK(profile);
profile_ = profile;
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kDnsLogDetails))
+ CommandLine parsed_command_line(L"");
+ parsed_command_line.ParseFromString(command_line_);
+ if (parsed_command_line.HasSwitch(switches::kDnsLogDetails))
chrome_browser_net::EnableDnsDetailedLog(true);
- if (command_line->HasSwitch(switches::kDnsPrefetchDisable))
+ if (parsed_command_line.HasSwitch(switches::kDnsPrefetchDisable))
chrome_browser_net::EnableDnsPrefetch(false);
- if (command_line->HasSwitch(switches::kDumpHistogramsOnExit))
+ if (parsed_command_line.HasSwitch(switches::kDumpHistogramsOnExit)) {
StatisticsRecorder::set_dump_on_exit(true);
+ }
- if (command_line->HasSwitch(switches::kRemoteShellPort)) {
+ if (parsed_command_line.HasSwitch(switches::kRemoteShellPort)) {
if (!RenderProcessHost::run_renderer_in_process()) {
std::wstring port_str =
- command_line->GetSwitchValue(switches::kRemoteShellPort);
+ parsed_command_line.GetSwitchValue(switches::kRemoteShellPort);
int64 port = StringToInt64(port_str);
if (port > 0 && port < 65535) {
g_browser_process->InitDebuggerWrapper(static_cast<int>(port));
@@ -174,29 +157,29 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
}
}
- if (command_line->HasSwitch(switches::kEnableFileCookies))
+ if (parsed_command_line.HasSwitch(switches::kEnableFileCookies))
net::CookieMonster::EnableFileScheme();
- if (command_line->HasSwitch(switches::kUserAgent)) {
-#if defined(OS_WIN)
+ if (parsed_command_line.HasSwitch(switches::kUserAgent)) {
webkit_glue::SetUserAgent(WideToUTF8(
- command_line->GetSwitchValue(switches::kUserAgent)));
- // TODO(port): hook this up when we bring in webkit.
-#endif
+ parsed_command_line.GetSwitchValue(switches::kUserAgent)));
}
#ifndef NDEBUG
- if (command_line->HasSwitch(switches::kApp))
+ if (parsed_command_line.HasSwitch(switches::kApp)) {
NOTREACHED();
+ }
#endif // NDEBUG
- std::vector<GURL> urls_to_open = GetURLsFromCommandLine(profile_);
+ std::vector<GURL> urls_to_open = GetURLsFromCommandLine(parsed_command_line,
+ 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, urls_to_open);
+ bool opened_startup_urls =
+ OpenStartupURLs(process_startup, parsed_command_line, urls_to_open);
if (!opened_startup_urls) {
if (urls_to_open.empty()) {
@@ -207,14 +190,9 @@ 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();
@@ -229,12 +207,13 @@ bool BrowserInit::LaunchWithProfile::Launch(Profile* profile,
if (browser) {
// If we're recording or playing back, startup the EventRecorder now
// unless otherwise specified.
- if (!command_line->HasSwitch(switches::kNoEvents)) {
+ if (!parsed_command_line.HasSwitch(switches::kNoEvents)) {
std::wstring script_path;
PathService::Get(chrome::FILE_RECORDED_SCRIPT, &script_path);
- bool record_mode = command_line->HasSwitch(switches::kRecordMode);
- bool playback_mode = command_line->HasSwitch(switches::kPlaybackMode);
+ bool record_mode = parsed_command_line.HasSwitch(switches::kRecordMode);
+ bool playback_mode =
+ parsed_command_line.HasSwitch(switches::kPlaybackMode);
if (record_mode && chrome::kRecordModeEnabled)
base::EventRecorder::current()->StartRecording(script_path);
@@ -248,16 +227,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) {
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- SessionStartupPref pref = GetSessionStartupPref(profile_);
+ SessionStartupPref pref = GetSessionStartupPref(profile_, command_line);
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
@@ -315,72 +294,62 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
}
std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
- Profile* profile) {
+ const CommandLine& command_line, Profile* profile) {
std::vector<GURL> urls;
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- std::vector<std::wstring> params = command_line->GetLooseValues();
+ std::vector<std::wstring> params = command_line.GetLooseValues();
for (size_t i = 0; i < params.size(); ++i) {
- std::wstring& value = params[i];
+ const std::wstring& value = params[i];
// Handle Vista way of searching - "? <search-term>"
if (value.find(L"? ") == 0) {
- const TemplateURL* default_provider =
+ const TemplateURL* const 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(WideToUTF8(URLFixerUpper::FixupRelativeFile(cur_dir_,
- value))));
+ urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_,
+ value)));
continue;
}
- const TemplateURLRef* search_url = default_provider->url();
+ const TemplateURLRef* const 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(WideToUTF8(
- URLFixerUpper::FixupRelativeFile(cur_dir_, value))));
+ urls.push_back(GURL(URLFixerUpper::FixupRelativeFile(cur_dir_, value)));
}
}
return urls;
}
-bool BrowserInit::ProcessCommandLine(
+bool BrowserInit::ProcessCommandLine(const CommandLine& parsed_command_line,
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 =
- command_line->GetSwitchValue(switches::kOmniBoxPopupCount);
+ parsed_command_line.GetSwitchValue(switches::kOmniBoxPopupCount);
if (!popup_count_string.empty()) {
- 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);
- }
+ 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);
}
- if (command_line->HasSwitch(switches::kDisablePromptOnRepost))
+ if (parsed_command_line.HasSwitch(switches::kDisablePromptOnRepost))
NavigationController::DisablePromptOnRepost();
const std::wstring tab_count_string =
- command_line->GetSwitchValue(switches::kTabCountToLoadOnSessionRestore);
+ parsed_command_line.GetSwitchValue(
+ switches::kTabCountToLoadOnSessionRestore);
if (!tab_count_string.empty()) {
- 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);
- }
+ const int tab_count = std::max(0, _wtoi(tab_count_string.c_str()));
+ 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 (command_line->HasSwitch(switches::kTestingChannelID)) {
+ if (parsed_command_line.HasSwitch(switches::kTestingChannelID)) {
std::wstring testing_channel_id =
- command_line->GetSwitchValue(switches::kTestingChannelID);
+ parsed_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
@@ -388,42 +357,39 @@ bool BrowserInit::ProcessCommandLine(
CreateAutomationProvider<TestingAutomationProvider>(
testing_channel_id,
profile,
- std::max(static_cast<int>(command_line->GetLooseValues().size()),
+ std::max(static_cast<int>(parsed_command_line.GetLooseValues().size()),
1));
}
-#endif
}
// Allow the command line to override the persisted setting of home page.
- SetOverrideHomePage(profile->GetPrefs());
+ SetOverrideHomePage(parsed_command_line, profile->GetPrefs());
- if (command_line->HasSwitch(switches::kBrowserStartRenderersManually))
+ if (parsed_command_line.HasSwitch(switches::kBrowserStartRenderersManually))
prefs->transient()->SetBoolean(prefs::kStartRenderersManually, true);
bool silent_launch = false;
-#if defined(OS_WIN)
- if (command_line->HasSwitch(switches::kAutomationClientChannelID)) {
+ if (parsed_command_line.HasSwitch(switches::kAutomationClientChannelID)) {
std::wstring automation_channel_id =
- command_line->GetSwitchValue(switches::kAutomationClientChannelID);
+ parsed_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>(command_line->GetLooseValues().size()),
+ std::max(static_cast<int>(parsed_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 http://crbug.com/7265
+ // Start up the extensions service
profile->InitExtensions();
- // TODO(port): figure out why this call crashes.
-#endif
- if (command_line->HasSwitch(switches::kInstallExtension)) {
+ if (parsed_command_line.HasSwitch(switches::kInstallExtension)) {
std::wstring path_string =
- command_line->GetSwitchValue(switches::kInstallExtension);
+ parsed_command_line.GetSwitchValue(switches::kInstallExtension);
FilePath path = FilePath::FromWStringHack(path_string);
profile->GetExtensionsService()->InstallExtension(path);
silent_launch = true;
@@ -431,21 +397,23 @@ bool BrowserInit::ProcessCommandLine(
// 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(profile, cur_dir, process_startup, return_code);
+ if (!silent_launch) {
+ return LaunchBrowser(parsed_command_line, profile, cur_dir,
+ process_startup, return_code);
+ }
return true;
}
-
-bool BrowserInit::LaunchBrowser(Profile* profile, const std::wstring& cur_dir,
+
+bool BrowserInit::LaunchBrowser(const CommandLine& parsed_command_line,
+ Profile* profile, const std::wstring& cur_dir,
bool process_startup, int* return_code) {
in_startup = process_startup;
- bool result = LaunchBrowserImpl(profile, cur_dir, process_startup,
- return_code);
+ bool result = LaunchBrowserImpl(parsed_command_line, 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,
@@ -456,27 +424,26 @@ 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(Profile* profile,
+bool BrowserInit::LaunchBrowserImpl(const CommandLine& parsed_command_line,
+ 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 (command_line->HasSwitch(switches::kIncognito))
+ if (parsed_command_line.HasSwitch(switches::kIncognito))
profile = profile->GetOffTheRecordProfile();
// Are we starting an application?
- std::wstring app_url = command_line->GetSwitchValue(switches::kApp);
+ std::wstring app_url = parsed_command_line.GetSwitchValue(switches::kApp);
if (!app_url.empty()) {
- GURL url(WideToUTF8(app_url));
+ GURL url(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
@@ -488,7 +455,7 @@ bool BrowserInit::LaunchBrowserImpl(Profile* profile,
return true;
}
- LaunchWithProfile lwp(cur_dir);
+ LaunchWithProfile lwp(cur_dir, parsed_command_line.command_line_string());
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 6475b9f..5e11811 100644
--- a/chrome/browser/browser_init.h
+++ b/chrome/browser/browser_init.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
class Browser;
+class CommandLine;
class GURL;
class PrefService;
class Profile;
@@ -30,7 +31,8 @@ class BrowserInit {
class LaunchWithProfile {
public:
- explicit LaunchWithProfile(const std::wstring& cur_dir);
+ LaunchWithProfile(const std::wstring& cur_dir,
+ const std::wstring& cmd_line);
~LaunchWithProfile() { }
// Creates the necessary windows for startup. Returns true on success,
@@ -49,6 +51,7 @@ 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
@@ -65,9 +68,11 @@ 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(Profile* profile);
+ std::vector<GURL> GetURLsFromCommandLine(const CommandLine& command_line,
+ Profile* profile);
std::wstring cur_dir_;
+ std::wstring command_line_;
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(LaunchWithProfile);
@@ -78,25 +83,26 @@ 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 std::wstring& cur_dir,
+ static bool ProcessCommandLine(const CommandLine& parsed_command_line,
+ 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(Profile* profile, const std::wstring& cur_dir,
+ static bool LaunchBrowser(const CommandLine& parsed_command_line,
+ 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(Profile* profile, const std::wstring& cur_dir,
+ static bool LaunchBrowserImpl(const CommandLine& parsed_command_line,
+ 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 0898d44..5d2b149 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -20,9 +20,6 @@
#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"
@@ -59,6 +56,9 @@
#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,7 +547,8 @@ 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(std::wstring(), local_state, true,
+ } else if (BrowserInit::ProcessCommandLine(parsed_command_line,
+ 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 ca50616..a33c68a 100644
--- a/chrome/browser/browser_prefs.cc
+++ b/chrome/browser/browser_prefs.cc
@@ -5,9 +5,6 @@
#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"
@@ -18,8 +15,10 @@
#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"
@@ -29,13 +28,11 @@
#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);
@@ -50,22 +47,19 @@ 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 0375a5d..1def5a7 100644
--- a/chrome/browser/message_window.cc
+++ b/chrome/browser/message_window.cc
@@ -209,7 +209,8 @@ LRESULT MessageWindow::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
NOTREACHED();
return TRUE;
}
- BrowserInit::ProcessCommandLine(cur_dir, prefs, false, profile, NULL);
+ BrowserInit::ProcessCommandLine(parsed_command_line, 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 71fbd8a..31d013f 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -261,8 +261,6 @@
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 */; };
@@ -4506,11 +4504,9 @@
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 957f32b..735a48e7 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -20,9 +20,6 @@
#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),
@@ -78,6 +75,63 @@ 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() {
@@ -103,6 +157,10 @@ bool ShellIntegration::IsDefaultBrowser() {
//--------------------------------------------------------------------------
+namespace browser {
+void RegisterAllPrefs(PrefService*, PrefService*) { }
+} // namespace browser
+
namespace browser_shutdown {
void ReadLastShutdownInfo() { }
void Shutdown() { }
@@ -195,13 +253,3 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
return NULL;
}
#endif
-
-//--------------------------------------------------------------------------
-
-namespace chrome_browser_net {
-
-void EnableDnsDetailedLog(bool) {}
-
-void EnableDnsPrefetch(bool) {}
-
-} // namespace chrome_browser_net
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 8dbcfcd..79ea9c5 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -37,8 +37,6 @@ class SessionID;
class SiteInstance;
class SpellChecker;
class TabContents;
-class TemplateURL;
-class TemplateURLRef;
class URLRequestContext;
class UserScriptMaster;
class VisitedLinkMaster;
@@ -70,6 +68,24 @@ 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; }
@@ -172,20 +188,6 @@ 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) { }
@@ -288,8 +290,6 @@ 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,20 +306,6 @@ 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; }
@@ -347,9 +333,6 @@ 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_;
@@ -450,30 +433,6 @@ 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) { }
@@ -481,15 +440,6 @@ class TemplateURLModel {
return L"";
}
static GURL GenerateSearchURL(const TemplateURL* t_url) { return GURL(); }
- TemplateURL* GetDefaultSearchProvider() { return NULL; }
};
-namespace chrome_browser_net {
-
-void EnableDnsDetailedLog(bool);
-
-void EnableDnsPrefetch(bool);
-
-} // namespace chrome_browser_net
-
#endif // CHROME_COMMON_TEMP_SCAFFOLDING_STUBS_H_