summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc8
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc6
-rw-r--r--chrome/browser/browser_init.cc10
-rw-r--r--chrome/browser/defaults.cc34
-rw-r--r--chrome/browser/defaults.h38
-rw-r--r--chrome/browser/session_startup_pref.cc67
-rw-r--r--chrome/chrome.gyp2
7 files changed, 123 insertions, 42 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 1baabef..509eaa2 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h"
#include "chrome/browser/command_updater.h"
+#include "chrome/browser/defaults.h"
#include "chrome/browser/gtk/location_bar_view_gtk.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/toolbar_model.h"
@@ -120,8 +121,11 @@ void AutocompleteEditViewGtk::Init() {
tag_table_ = gtk_text_tag_table_new();
text_buffer_ = gtk_text_buffer_new(tag_table_);
text_view_ = gtk_text_view_new_with_buffer(text_buffer_);
- // Until we switch to vector graphics, force the font size.
- gtk_util::ForceFontSizePixels(text_view_, 13.4); // 13.4px == 10pt @ 96dpi
+ if (browser_defaults::kForceAutocompleteEditFontSize) {
+ // Until we switch to vector graphics, force the font size.
+ gtk_util::ForceFontSizePixels(text_view_, 13.4); // 13.4px == 10pt @ 96dpi
+ }
+
// Override the background color for now. http://crbug.com/12195
gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL,
&LocationBarViewGtk::kBackgroundColorByLevel[scheme_security_level_]);
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
index ec74e648..260fef8 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
+#include "chrome/browser/defaults.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
@@ -248,8 +249,9 @@ AutocompletePopupViewGtk::AutocompletePopupViewGtk(
// TODO(deanm): We might want to eventually follow what Windows does and
// plumb a gfx::Font through. This is because popup windows have a
// different font size, although we could just derive that font here.
- // For now, force the font size to 10pt.
- gfx::Font font = gfx::Font::CreateFont(gfx::Font().FontName(), 10);
+ // For now, force the font size.
+ gfx::Font font = gfx::Font::CreateFont(
+ gfx::Font().FontName(), browser_defaults::kAutocompletePopupFontSize);
PangoFontDescription* pfd = PangoFontFromGfxFont(font);
pango_layout_set_font_description(layout_, pfd);
pango_font_description_free(pfd);
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 05d614a..a93bea4 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/defaults.h"
#if defined(OS_WIN) // TODO(port)
#include "chrome/browser/extensions/extension_creator.h"
#endif
@@ -513,6 +514,7 @@ bool BrowserInit::LaunchWithProfile::OpenStartupURLs(
return false;
if (!profile_->DidLastSessionExitCleanly() &&
+ !browser_defaults::kRestoreAfterCrash &&
!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.
@@ -564,7 +566,7 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser(
urls[i], GURL(), PageTransition::START_PAGE, (i == 0), -1, false, NULL);
if (i < static_cast<size_t>(pin_count))
browser->tabstrip_model()->SetTabPinned(browser->tab_count() - 1, true);
- if (i == 0 && process_startup)
+ if (i == 0 && process_startup && !browser_defaults::kSuppressCrashInfoBar)
AddCrashedInfoBarIfNecessary(tab);
}
browser->window()->Show();
@@ -577,11 +579,6 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser(
void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
TabContents* tab) {
-#if defined(OS_CHROMEOS)
- // Because of how chrome os currently shuts down chrome always appears to
- // crash. For the time being we're working around that here.
- return;
-#else
// Assume that if the user is launching incognito they were previously
// running incognito so that we have nothing to restore from.
if (!profile_->DidLastSessionExitCleanly() &&
@@ -591,7 +588,6 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
// it is closed.
tab->AddInfoBar(new SessionCrashedInfoBarDelegate(tab));
}
-#endif
}
std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc
new file mode 100644
index 0000000..73f6996
--- /dev/null
+++ b/chrome/browser/defaults.cc
@@ -0,0 +1,34 @@
+// 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 "chrome/browser/defaults.h"
+
+namespace browser_defaults {
+
+#if defined(OS_CHROMEOS)
+
+const bool kForceAutocompleteEditFontSize = false;
+const int kAutocompletePopupFontSize = 7;
+const SessionStartupPref::Type kDefaultSessionStartupType =
+ SessionStartupPref::LAST;
+const bool kSuppressCrashInfoBar = true;
+const bool kRestoreAfterCrash = true;
+
+#elif defined(OS_LINUX)
+
+const bool kForceAutocompleteEditFontSize = true;
+const int kAutocompletePopupFontSize = 10;
+
+#endif
+
+#if !defined(OS_CHROMEOS)
+
+const SessionStartupPref::Type kDefaultSessionStartupType =
+ SessionStartupPref::DEFAULT;
+const bool kSuppressCrashInfoBar = false;
+const bool kRestoreAfterCrash = false;
+
+#endif
+
+} // namespace browser_defaults
diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h
new file mode 100644
index 0000000..9ce7250
--- /dev/null
+++ b/chrome/browser/defaults.h
@@ -0,0 +1,38 @@
+// 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.
+
+// Defines various defaults whose values varies depending upon the OS.
+
+#ifndef CHROME_BROWSER_DEFAULTS_H_
+#define CHROME_BROWSER_DEFAULTS_H_
+
+#include "build/build_config.h"
+#include "chrome/browser/session_startup_pref.h"
+
+namespace browser_defaults {
+
+#if defined(OS_LINUX)
+
+// Whether the size of the autocomplete's font should be changed.
+extern const bool kForceAutocompleteEditFontSize;
+
+// Size of the font used in the autocomplete popup.
+extern const int kAutocompletePopupFontSize;
+
+#endif
+
+// The default value for session startup.
+extern const SessionStartupPref::Type kDefaultSessionStartupType;
+
+// On launching Chrome should we show the crash info bar if Chrome crashed?
+extern const bool kSuppressCrashInfoBar;
+
+// Should we restore the last session if the user opted to restore the last
+// session on startup and Chrome crashed?
+// TODO(sky): this should be removed once Chrome OS cleanly shuts down Chrome.
+extern const bool kRestoreAfterCrash;
+
+} // namespace browser_defaults
+
+#endif // CHROME_BROWSER_DEFAULTS_H_
diff --git a/chrome/browser/session_startup_pref.cc b/chrome/browser/session_startup_pref.cc
index 5e235a2..d14096b 100644
--- a/chrome/browser/session_startup_pref.cc
+++ b/chrome/browser/session_startup_pref.cc
@@ -5,14 +5,43 @@
#include "chrome/browser/session_startup_pref.h"
#include "base/string_util.h"
+#include "chrome/browser/defaults.h"
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
-#include "base/string_util.h"
+
+namespace {
+
+// For historical reasons the enum and value registered in the prefs don't line
+// up. These are the values registered in prefs.
+const int kPrefValueDefault = 0;
+const int kPrefValueLast = 1;
+const int kPrefValueURLs = 4;
+
+// Converts a SessionStartupPref::Type to an integer written to prefs.
+int TypeToPrefValue(SessionStartupPref::Type type) {
+ switch(type) {
+ case SessionStartupPref::LAST: return kPrefValueLast;
+ case SessionStartupPref::URLS: return kPrefValueURLs;
+ default: return kPrefValueDefault;
+ }
+}
+
+// Converts an integer pref value to a SessionStartupPref::Type.
+SessionStartupPref::Type PrefValueToType(int pref_value) {
+ switch (pref_value) {
+ case kPrefValueLast: return SessionStartupPref::LAST;
+ case kPrefValueURLs: return SessionStartupPref::URLS;
+ default: return SessionStartupPref::DEFAULT;
+ }
+}
+
+} // namespace
// static
void SessionStartupPref::RegisterUserPrefs(PrefService* prefs) {
- prefs->RegisterIntegerPref(prefs::kRestoreOnStartup, 0);
+ prefs->RegisterIntegerPref(prefs::kRestoreOnStartup,
+ TypeToPrefValue(browser_defaults::kDefaultSessionStartupType));
prefs->RegisterListPref(prefs::kURLsToRestoreOnStartup);
}
@@ -28,20 +57,7 @@ void SessionStartupPref::SetStartupPref(
void SessionStartupPref::SetStartupPref(PrefService* prefs,
const SessionStartupPref& pref) {
DCHECK(prefs);
- int type = 0;
- switch(pref.type) {
- case LAST:
- type = 1;
- break;
-
- case URLS:
- type = 4;
- break;
-
- default:
- break;
- }
- prefs->SetInteger(prefs::kRestoreOnStartup, type);
+ prefs->SetInteger(prefs::kRestoreOnStartup, TypeToPrefValue(pref.type));
// Always save the URLs, that way the UI can remain consistent even if the
// user changes the startup type pref.
@@ -65,22 +81,11 @@ SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) {
// static
SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) {
DCHECK(prefs);
- SessionStartupPref pref;
- switch (prefs->GetInteger(prefs::kRestoreOnStartup)) {
- case 1: {
- pref.type = LAST;
- break;
- }
-
- case 4: {
- pref.type = URLS;
- break;
- }
-
- // default case or bogus type are treated as not doing anything special
- // on startup.
- }
+ SessionStartupPref pref(
+ PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup)));
+ // Always load the urls, even if the pref type isn't URLS. This way the
+ // preferenes panels can show the user their last choice.
ListValue* url_pref_list = prefs->GetMutableList(
prefs::kURLsToRestoreOnStartup);
DCHECK(url_pref_list);
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index cb3b0a2..7068f73 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -851,6 +851,8 @@
'browser/command_updater.h',
'browser/cross_site_request_manager.cc',
'browser/cross_site_request_manager.h',
+ 'browser/defaults.cc',
+ 'browser/defaults.h',
'browser/dock_info_gtk.cc',
'browser/dock_info_win.cc',
'browser/dock_info.cc',