diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-05 00:05:08 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-05 00:05:08 +0000 |
commit | 0e30ef7b4eed575d9f4efd42ca23c18c7ca8bd6a (patch) | |
tree | 8c088e1f17834ca98961f006868886c32bd46062 /chrome | |
parent | 66de4f091a069b7d34a1afc16d6f1429a2b65781 (diff) | |
download | chromium_src-0e30ef7b4eed575d9f4efd42ca23c18c7ca8bd6a.zip chromium_src-0e30ef7b4eed575d9f4efd42ca23c18c7ca8bd6a.tar.gz chromium_src-0e30ef7b4eed575d9f4efd42ca23c18c7ca8bd6a.tar.bz2 |
Move the "history is too new" dialog out of
chrome/browser/history/history.cc. Instead use a notification
that Browser picks up and delegates to BrowserWindow.
Include implementations for Windows, Linux GTK+, and Linux Views
(sorry, no mac impl).
Review URL: http://codereview.chromium.org/200023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 10 | ||||
-rw-r--r-- | chrome/browser/browser_window.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 14 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/history/history.cc | 20 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 21 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 1 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 4 | ||||
-rw-r--r-- | chrome/test/test_browser_window.h | 1 |
11 files changed, 62 insertions, 18 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index dfeb73c..8227425 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -202,6 +202,8 @@ Browser::Browser(Type type, Profile* profile) NotificationService::AllSources()); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); + registrar_.Add(this, NotificationType::HISTORY_TOO_NEW, + NotificationService::AllSources()); // Need to know when to alert the user of theme install delay. registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, @@ -2177,11 +2179,17 @@ void Browser::Observe(NotificationType type, if (platform_util::IsVisible(tab_contents->GetNativeView())) ThemeInstallBubbleView::Show(tab_contents); #else - NOTIMPLEMENTED(); + NOTIMPLEMENTED(); #endif break; } + case NotificationType::HISTORY_TOO_NEW: { + if (BrowserList::GetLastActive() != this) + break; + window()->ShowHistoryTooNewDialog(); + break; + } default: NOTREACHED() << "Got a notification we didn't register for."; diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index 5268318..cae21a5 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -196,6 +196,9 @@ 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 the confirmation dialog box warning that the browser is closing with // in-progress downloads. // This method should call Browser::InProgressDownloadResponse once the user diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 7258d43..bdc105b 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -74,6 +74,7 @@ class BrowserWindowCocoa : public BrowserWindow, virtual void ShowSelectProfileDialog(); virtual void ShowNewProfileDialog(); virtual void ShowRepostFormWarningDialog(TabContents* tab_contents); + virtual void ShowHistoryTooNewDialog(); virtual void ConfirmBrowserCloseWithPendingDownloads(); virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window); diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 377309c..b51ab8c 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -259,6 +259,10 @@ void BrowserWindowCocoa::ShowRepostFormWarningDialog( NOTIMPLEMENTED(); } +void BrowserWindowCocoa::ShowHistoryTooNewDialog() { + NOTIMPLEMENTED(); +} + // We allow closing the window here since the real quit decision on Mac is made // in [AppController quit:]. void BrowserWindowCocoa::ConfirmBrowserCloseWithPendingDownloads() { diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 1fea967..c0a6b61 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -9,6 +9,7 @@ #include <string> +#include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" #include "base/base_paths_linux.h" @@ -69,6 +70,8 @@ #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "grit/app_resources.h" +#include "grit/generated_resources.h" +#include "grit/google_chrome_strings.h" #include "grit/theme_resources.h" #include "skia/ext/skia_utils.h" #include "skia/ext/skia_utils_gtk.h" @@ -1073,6 +1076,17 @@ void BrowserWindowGtk::ShowRepostFormWarningDialog( new RepostFormWarningGtk(GetNativeHandle(), &tab_contents->controller()); } +void BrowserWindowGtk::ShowHistoryTooNewDialog() { + std::string title = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); + std::string message = l10n_util::GetStringUTF8(IDS_PROFILE_TOO_NEW_ERROR); + GtkWidget* dialog = gtk_message_dialog_new(window_, + static_cast<GtkDialogFlags>(0), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, + "%s", message.c_str()); + gtk_window_set_title(GTK_WINDOW(dialog), title.c_str()); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); +} + void BrowserWindowGtk::ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) { NOTIMPLEMENTED(); diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index c4426a71..d83b46b 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -105,6 +105,7 @@ class BrowserWindowGtk : public BrowserWindow, virtual void ShowSelectProfileDialog(); virtual void ShowNewProfileDialog(); virtual void ShowRepostFormWarningDialog(TabContents* tab_contents); + virtual void ShowHistoryTooNewDialog(); virtual void ConfirmBrowserCloseWithPendingDownloads(); virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window); diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index 5cf61a9..8310c23 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -620,23 +620,9 @@ void HistoryService::SetInMemoryBackend( } void HistoryService::NotifyTooNew() { -#if defined(OS_WIN) - // Find the last browser window to display our message box from. - Browser* cur_browser = BrowserList::GetLastActive(); - // TODO(brettw): Do this some other way or beng will kick you. e.g. move to - // BrowserView. - HWND parent_hwnd = - reinterpret_cast<HWND>(cur_browser->window()->GetNativeHandle()); - HWND cur_hwnd = cur_browser ? parent_hwnd : NULL; - - std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); - std::wstring message = l10n_util::GetString(IDS_PROFILE_TOO_NEW_ERROR); - MessageBox(cur_hwnd, message.c_str(), title.c_str(), - MB_OK | MB_ICONWARNING | MB_TOPMOST); -#else - // TODO(port): factor this out into platform-specific code. - NOTIMPLEMENTED(); -#endif + Source<HistoryService> source(this); + NotificationService::current()->Notify(NotificationType::HISTORY_TOO_NEW, + source, NotificationService::NoDetails()); } void HistoryService::DeleteURL(const GURL& url) { diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 490109c..08487fc 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -66,6 +66,7 @@ #include "views/window/window.h" #if defined(OS_WIN) +#include "app/win_util.h" #include "chrome/browser/jumplist.h" #include "views/controls/scrollbar/native_scroll_bar.h" #elif defined(OS_LINUX) @@ -1203,6 +1204,26 @@ void BrowserView::ShowRepostFormWarningDialog(TabContents* tab_contents) { browser::ShowRepostFormWarningDialog(GetNativeHandle(), tab_contents); } +void BrowserView::ShowHistoryTooNewDialog() { +#if defined(OS_WIN) + std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); + std::wstring message = l10n_util::GetString(IDS_PROFILE_TOO_NEW_ERROR); + 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); + GtkWidget* dialog = gtk_message_dialog_new(GetNativeHandle(), + static_cast<GtkDialogFlags>(0), GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, + "%s", message.c_str()); + gtk_window_set_title(GTK_WINDOW(dialog), title.c_str()); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); +#else + NOTIMPLEMENTED(); +#endif +} + void BrowserView::ConfirmBrowserCloseWithPendingDownloads() { DownloadInProgressConfirmDialogDelegate* delegate = new DownloadInProgressConfirmDialogDelegate(browser_.get()); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 0b97b33..2d06f98 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -246,6 +246,7 @@ class BrowserView : public BrowserWindow, virtual void ShowSelectProfileDialog(); virtual void ShowNewProfileDialog(); virtual void ShowRepostFormWarningDialog(TabContents* tab_contents); + virtual void ShowHistoryTooNewDialog(); virtual void ConfirmBrowserCloseWithPendingDownloads(); virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window); diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index 9fa13ae..1e445a6 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -494,6 +494,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, + // Thumbnails--------------------------------------------------------------- // Set by ThumbnailStore when it was finished loading data from disk on diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h index 62c7291..f9cf838 100644 --- a/chrome/test/test_browser_window.h +++ b/chrome/test/test_browser_window.h @@ -72,6 +72,7 @@ class TestBrowserWindow : public BrowserWindow { virtual void ShowSelectProfileDialog() {} virtual void ShowNewProfileDialog() {} virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) {} + virtual void ShowHistoryTooNewDialog() {} virtual void ConfirmBrowserCloseWithPendingDownloads() {} virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) {} |