summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 22:34:41 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 22:34:41 +0000
commite587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad (patch)
tree04883155bf0e43a7dba6717d5f3ce4526c34712e
parent61206e0c3dfcf17e748dec65139d7e8e3449c8a3 (diff)
downloadchromium_src-e587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad.zip
chromium_src-e587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad.tar.gz
chromium_src-e587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad.tar.bz2
Show a warning when the history files can't be read correctly.
This re-plumbs the existing "TooNew" codepath to handle arbitrary error messages. BUG=25822 TEST=Make your history files non-readable, run Chrome (Release), make sure you get a warning dialog. Review URL: http://codereview.chromium.org/342048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30642 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd5
-rw-r--r--chrome/browser/browser.cc7
-rw-r--r--chrome/browser/browser_window.h6
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.h2
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.mm2
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc4
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h2
-rw-r--r--chrome/browser/history/history.cc10
-rw-r--r--chrome/browser/history/history.h6
-rw-r--r--chrome/browser/history/history_backend.cc6
-rw-r--r--chrome/browser/history/history_backend.h5
-rw-r--r--chrome/browser/history/history_backend_unittest.cc6
-rw-r--r--chrome/browser/history/history_unittest.cc4
-rw-r--r--chrome/browser/views/frame/browser_view.cc6
-rw-r--r--chrome/browser/views/frame/browser_view.h2
-rw-r--r--chrome/common/notification_type.h7
-rw-r--r--chrome/test/test_browser_window.h2
17 files changed, 45 insertions, 37 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 1dd6357..275e7a7a6 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5074,6 +5074,11 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OPTIONS_RESET_CANCELLABEL" desc="The label of the Cancel button in the 'Reset Chrome options' confirmation dialog box">
Don't reset
</message>
+
+ <!-- General app failure messages -->
+ <message name="IDS_COULDNT_OPEN_PROFILE_ERROR" desc="Error displayed on startup when the profile can not be opened correctly due to problems reading or writing files in it">
+ Your profile could not be opened correctly.\n\nSome features may be unavailable. Please check that the profile exists and you have permission to read and write its contents.
+ </message>
<!-- Can't write to user data directory dialog -->
<message name="IDS_CANT_WRITE_USER_DIRECTORY_TITLE" desc="Title of dialog that is displayed when we can't create a directory for this user.">
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 71ef534..295beff 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -140,7 +140,7 @@ Browser::Browser(Type type, Profile* profile)
NotificationService::AllSources());
registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
NotificationService::AllSources());
- registrar_.Add(this, NotificationType::HISTORY_TOO_NEW,
+ registrar_.Add(this, NotificationType::PROFILE_ERROR,
NotificationService::AllSources());
// Need to know when to alert the user of theme install delay.
@@ -2264,10 +2264,11 @@ void Browser::Observe(NotificationType type,
break;
}
- case NotificationType::HISTORY_TOO_NEW: {
+ case NotificationType::PROFILE_ERROR: {
if (BrowserList::GetLastActive() != this)
break;
- window()->ShowHistoryTooNewDialog();
+ int* message_id = Details<int>(details).ptr();
+ window()->ShowProfileErrorDialog(*message_id);
break;
}
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h
index ccbbf32..e1a59a4 100644
--- a/chrome/browser/browser_window.h
+++ b/chrome/browser/browser_window.h
@@ -205,8 +205,10 @@ class BrowserWindow {
// Shows the repost form confirmation dialog box.
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) = 0;
- // Shows a dialog to the user that the history is too new.
- virtual void ShowHistoryTooNewDialog() = 0;
+ // Shows a dialog to the user that something is wrong with the profile.
+ // |message_id| is the ID for a string in the string table which will be
+ // displayed in the dialog.
+ virtual void ShowProfileErrorDialog(int message_id) = 0;
// Show the bubble that indicates to the user that a theme is being installed.
virtual void ShowThemeInstallBubble() = 0;
diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h
index 1b7cec2..11cc840 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/cocoa/browser_window_cocoa.h
@@ -75,7 +75,7 @@ class BrowserWindowCocoa : public BrowserWindow,
virtual void ShowSelectProfileDialog();
virtual void ShowNewProfileDialog();
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents);
- virtual void ShowHistoryTooNewDialog();
+ virtual void ShowProfileErrorDialog(int message_id);
virtual void ShowThemeInstallBubble();
virtual void ConfirmBrowserCloseWithPendingDownloads();
virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm
index e00f73d..398948e 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/cocoa/browser_window_cocoa.mm
@@ -281,7 +281,7 @@ void BrowserWindowCocoa::ShowRepostFormWarningDialog(
new RepostFormWarningMac(GetNativeHandle(), &tab_contents->controller());
}
-void BrowserWindowCocoa::ShowHistoryTooNewDialog() {
+void BrowserWindowCocoa::ShowProfileErrorDialog(int message_id) {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 1d084f2..a3108b7 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -1127,9 +1127,9 @@ void BrowserWindowGtk::ShowRepostFormWarningDialog(
new RepostFormWarningGtk(GetNativeHandle(), &tab_contents->controller());
}
-void BrowserWindowGtk::ShowHistoryTooNewDialog() {
+void BrowserWindowGtk::ShowProfileErrorDialog(int message_id) {
std::string title = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
- std::string message = l10n_util::GetStringUTF8(IDS_PROFILE_TOO_NEW_ERROR);
+ std::string message = l10n_util::GetStringUTF8(message_id);
GtkWidget* dialog = gtk_message_dialog_new(window_,
static_cast<GtkDialogFlags>(0), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
"%s", message.c_str());
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index 4b01239..1f5f91c 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -104,7 +104,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual void ShowSelectProfileDialog();
virtual void ShowNewProfileDialog();
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents);
- virtual void ShowHistoryTooNewDialog();
+ virtual void ShowProfileErrorDialog(int message_id);
virtual void ShowThemeInstallBubble();
virtual void ConfirmBrowserCloseWithPendingDownloads();
virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index a7bf774..ee13114 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -94,10 +94,10 @@ class HistoryService::BackendDelegate : public HistoryBackend::Delegate {
message_loop_(MessageLoop::current()) {
}
- virtual void NotifyTooNew() {
+ virtual void NotifyProfileError(int message_id) {
// Send the backend to the history service on the main thread.
message_loop_->PostTask(FROM_HERE, NewRunnableMethod(history_service_.get(),
- &HistoryService::NotifyTooNew));
+ &HistoryService::NotifyProfileError, message_id));
}
virtual void SetInMemoryBackend(
@@ -666,10 +666,10 @@ void HistoryService::SetInMemoryBackend(
in_memory_backend_->AttachToHistoryService(profile_);
}
-void HistoryService::NotifyTooNew() {
+void HistoryService::NotifyProfileError(int message_id) {
Source<HistoryService> source(this);
- NotificationService::current()->Notify(NotificationType::HISTORY_TOO_NEW,
- source, NotificationService::NoDetails());
+ NotificationService::current()->Notify(NotificationType::PROFILE_ERROR,
+ source, Details<int>(&message_id));
}
void HistoryService::DeleteURL(const GURL& url) {
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index 13bbf4c..d6dab37 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -613,9 +613,9 @@ class HistoryService : public CancelableRequestProvider,
// database is loaded to make it available.
void SetInMemoryBackend(history::InMemoryHistoryBackend* mem_backend);
- // Called by our BackendDelegate when the database version is too new to be
- // read properly.
- void NotifyTooNew();
+ // Called by our BackendDelegate when there is a problem reading the database.
+ // |message_id| is the relevant message in the string table to display.
+ void NotifyProfileError(int message_id);
// Call to schedule a given task for running on the history thread with the
// specified priority. The task will have ownership taken.
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index f9855f4..b7d1a47 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -25,6 +25,8 @@
#include "chrome/common/sqlite_utils.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
#include "net/base/registry_controlled_domain.h"
using base::Time;
@@ -501,11 +503,11 @@ void HistoryBackend::InitImpl() {
case INIT_FAILURE:
// A NULL db_ will cause all calls on this object to notice this error
// and to not continue.
- LOG(WARNING) << "Unable to initialize history DB.";
+ delegate_->NotifyProfileError(IDS_COULDNT_OPEN_PROFILE_ERROR);
db_.reset();
return;
case INIT_TOO_NEW:
- delegate_->NotifyTooNew();
+ delegate_->NotifyProfileError(IDS_PROFILE_TOO_NEW_ERROR);
db_.reset();
return;
default:
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index 4effaca..34481ce 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -52,9 +52,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
public:
virtual ~Delegate() {}
- // Called when the database is from a future version of the product and can
- // not be used.
- virtual void NotifyTooNew() = 0;
+ // Called when the database cannot be read correctly for some reason.
+ virtual void NotifyProfileError(int message_id) = 0;
// Sets the in-memory history backend. The in-memory backend is created by
// the main backend. For non-unit tests, this happens on the background
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index 7270a3d..833059e 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -32,11 +32,9 @@ class HistoryBackendTest;
// This just forwards the messages we're interested in to the test object.
class HistoryBackendTestDelegate : public HistoryBackend::Delegate {
public:
- explicit HistoryBackendTestDelegate(HistoryBackendTest* test) : test_(test) {
- }
+ explicit HistoryBackendTestDelegate(HistoryBackendTest* test) : test_(test) {}
- virtual void NotifyTooNew() {
- }
+ virtual void NotifyProfileError(int message_id) {}
virtual void SetInMemoryBackend(InMemoryHistoryBackend* backend);
virtual void BroadcastNotifications(NotificationType type,
HistoryDetails* details);
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index ce6121a..4316c27 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -96,7 +96,7 @@ class BackendDelegate : public HistoryBackend::Delegate {
: history_test_(history_test) {
}
- virtual void NotifyTooNew();
+ virtual void NotifyProfileError(int message_id);
virtual void SetInMemoryBackend(InMemoryHistoryBackend* backend);
virtual void BroadcastNotifications(NotificationType type,
HistoryDetails* details);
@@ -294,7 +294,7 @@ class HistoryTest : public testing::Test {
HistoryDatabase* db_; // Cached reference to the backend's database.
};
-void BackendDelegate::NotifyTooNew() {
+void BackendDelegate::NotifyProfileError(int message_id) {
}
void BackendDelegate::SetInMemoryBackend(InMemoryHistoryBackend* backend) {
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 8034fb6..57e864c 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -1093,15 +1093,15 @@ void BrowserView::ShowRepostFormWarningDialog(TabContents* tab_contents) {
browser::ShowRepostFormWarningDialog(GetNativeHandle(), tab_contents);
}
-void BrowserView::ShowHistoryTooNewDialog() {
+void BrowserView::ShowProfileErrorDialog(int message_id) {
#if defined(OS_WIN)
std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME);
- std::wstring message = l10n_util::GetString(IDS_PROFILE_TOO_NEW_ERROR);
+ std::wstring message = l10n_util::GetString(message_id);
win_util::MessageBox(GetNativeHandle(), message, title,
MB_OK | MB_ICONWARNING | MB_TOPMOST);
#elif defined(OS_LINUX)
std::string title = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
- std::string message = l10n_util::GetStringUTF8(IDS_PROFILE_TOO_NEW_ERROR);
+ std::string message = l10n_util::GetStringUTF8(message_id);
GtkWidget* dialog = gtk_message_dialog_new(GetNativeHandle(),
static_cast<GtkDialogFlags>(0), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
"%s", message.c_str());
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 5aa5c3c..497ec49 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -255,7 +255,7 @@ class BrowserView : public BrowserWindow,
virtual void ShowSelectProfileDialog();
virtual void ShowNewProfileDialog();
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents);
- virtual void ShowHistoryTooNewDialog();
+ virtual void ShowProfileErrorDialog(int message_id);
virtual void ShowThemeInstallBubble();
virtual void ConfirmBrowserCloseWithPendingDownloads();
virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index 86e09fd..de00154 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -518,9 +518,10 @@ class NotificationType {
// history_notifications.h).
FAVICON_CHANGED,
- // Sent by history if the history database is too new. The active browser
- // window should notify the user of this error.
- HISTORY_TOO_NEW,
+ // Sent by history if there is a problem reading the profile. The details
+ // is an int that's one of the message IDs in the string table. The active
+ // browser window should notify the user of this error.
+ PROFILE_ERROR,
// Thumbnails---------------------------------------------------------------
diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h
index e667746..c8fb5e5 100644
--- a/chrome/test/test_browser_window.h
+++ b/chrome/test/test_browser_window.h
@@ -74,7 +74,7 @@ class TestBrowserWindow : public BrowserWindow {
virtual void ShowSelectProfileDialog() {}
virtual void ShowNewProfileDialog() {}
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) {}
- virtual void ShowHistoryTooNewDialog() {}
+ virtual void ShowProfileErrorDialog(int message_id) {}
virtual void ShowThemeInstallBubble() {}
virtual void ConfirmBrowserCloseWithPendingDownloads() {}
virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate,