summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_init.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 01:06:05 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 01:06:05 +0000
commitf86a07024080cd1b000105bce34ce45b2bd5159b (patch)
treed47e27fae62581ffb7f4e4209c7dd0106b88763f /chrome/browser/browser_init.cc
parent2d42a37132679537eb9e8db9f45a6dfe92dde996 (diff)
downloadchromium_src-f86a07024080cd1b000105bce34ce45b2bd5159b.zip
chromium_src-f86a07024080cd1b000105bce34ce45b2bd5159b.tar.gz
chromium_src-f86a07024080cd1b000105bce34ce45b2bd5159b.tar.bz2
Re-land 5929 (r5882) with crash fix and also this change:
http://codereview.chromium.org/11392/show which fixes the remainder of the UI test issues apparently. http://crbug.com/4620 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_init.cc')
-rw-r--r--chrome/browser/browser_init.cc53
1 files changed, 44 insertions, 9 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 209ebc3..88bb11c 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -17,14 +17,15 @@
#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/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/dom_ui/new_tab_ui.h"
#include "chrome/browser/first_run.h"
+#include "chrome/browser/infobar_delegate.h"
#include "chrome/browser/navigation_controller.h"
#include "chrome/browser/net/dns_global.h"
-#include "chrome/browser/session_crashed_view.h"
#include "chrome/browser/session_restore.h"
#include "chrome/browser/session_startup_pref.h"
#include "chrome/browser/tabs/tab_strip_model.h"
@@ -38,6 +39,7 @@
#include "chrome/common/logging_chrome.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
+#include "chrome/common/resource_bundle.h"
#include "chrome/common/win_util.h"
#include "net/base/cookie_monster.h"
#include "net/base/net_util.h"
@@ -48,6 +50,43 @@
namespace {
+// A delegate for the InfoBar shown when the previous session has crashed. The
+// bar deletes itself automatically after it is closed.
+class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ explicit SessionCrashedInfoBarDelegate(TabContents* contents)
+ : profile_(contents->profile()),
+ ConfirmInfoBarDelegate(contents) {
+ }
+
+ // Overridden from ConfirmInfoBarDelegate:
+ virtual void InfoBarClosed() {
+ delete this;
+ }
+ virtual std::wstring GetMessageText() const {
+ return l10n_util::GetString(IDS_SESSION_CRASHED_VIEW_MESSAGE);
+ }
+ virtual SkBitmap* GetIcon() const {
+ return ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_INFOBAR_RESTORE_SESSION);
+ }
+ virtual int GetButtons() const { return BUTTON_OK; }
+ virtual std::wstring GetButtonLabel(InfoBarButton button) const {
+ return l10n_util::GetString(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON);
+ }
+ virtual void Accept() {
+ // Restore the session.
+ SessionRestore::RestoreSession(profile_, NULL, false, true, false,
+ std::vector<GURL>());
+ }
+
+ private:
+ // The Profile that we restore sessions from.
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
+};
+
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)) {
@@ -502,15 +541,11 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser(
void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
TabContents* tab) {
- WebContents* web_contents = tab->AsWebContents();
- if (!profile_->DidLastSessionExitCleanly() && web_contents) {
+ if (!profile_->DidLastSessionExitCleanly()) {
// The last session didn't exit cleanly. Show an infobar to the user
- // so that they can restore if they want.
- // TODO(brettw) this should be done more cleanly, by adding a message to
- // the view and not getting the info bar from inside it directly.
- web_contents->view()->GetInfoBarView()->
- AddChildView(new SessionCrashedView(profile_));
- web_contents->view()->SetInfoBarVisible(true);
+ // so that they can restore if they want. The delegate deletes itself when
+ // it is closed.
+ tab->AddInfoBar(new SessionCrashedInfoBarDelegate(tab));
}
}