summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 15:52:29 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 15:52:29 +0000
commit8537054e6da7e12a50ab27786dd01b253b8a0d12 (patch)
treeec43ed5313377170b8446c71e1c0a5727953af3f
parent0fda727e08d2f785ce127fba39c4ce69955fa934 (diff)
downloadchromium_src-8537054e6da7e12a50ab27786dd01b253b8a0d12.zip
chromium_src-8537054e6da7e12a50ab27786dd01b253b8a0d12.tar.gz
chromium_src-8537054e6da7e12a50ab27786dd01b253b8a0d12.tar.bz2
Revert cl 19359 due to browser_tests timeout.
TBR=nsylvain Review URL: http://codereview.chromium.org/147206 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19363 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_plugin_host.cc2
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc5
-rw-r--r--chrome/browser/dom_ui/dom_ui.h11
-rw-r--r--chrome/browser/dom_ui/downloads_dom_handler.cc42
-rw-r--r--chrome/browser/dom_ui/downloads_dom_handler.h5
-rw-r--r--chrome/browser/dom_ui/downloads_ui.cc4
-rw-r--r--chrome/browser/dom_ui/history_ui.cc23
-rw-r--r--chrome/browser/dom_ui/history_ui.h5
-rw-r--r--chrome/browser/dom_ui/html_dialog_ui.cc11
-rw-r--r--chrome/browser/dom_ui/html_dialog_ui.h9
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc174
-rw-r--r--chrome/browser/dom_ui/shown_sections_handler.cc8
-rw-r--r--chrome/browser/dom_ui/shown_sections_handler.h6
-rw-r--r--chrome/browser/dom_ui/tips_handler.cc13
-rw-r--r--chrome/browser/dom_ui/tips_handler.h10
-rw-r--r--chrome/browser/extensions/extensions_ui.cc17
-rw-r--r--chrome/browser/extensions/extensions_ui.h8
-rw-r--r--chrome/browser/modal_html_dialog_delegate.h2
-rw-r--r--chrome/browser/views/html_dialog_view.cc5
-rw-r--r--chrome/browser/views/html_dialog_view.h2
-rw-r--r--chrome/common/temp_scaffolding_stubs.h2
21 files changed, 157 insertions, 207 deletions
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc
index 4772769..196a24d 100644
--- a/chrome/browser/chrome_plugin_host.cc
+++ b/chrome/browser/chrome_plugin_host.cc
@@ -313,8 +313,6 @@ class ModelessHtmlDialogDelegate : public HtmlDialogUIDelegate {
virtual bool IsDialogModal() const { return false; }
virtual std::wstring GetDialogTitle() const { return L"Gears"; }
virtual GURL GetDialogContentURL() const { return params_.url; }
- virtual void GetDOMMessageHandlers(
- std::vector<DOMMessageHandler*>* handlers) const {}
virtual void GetDialogSize(gfx::Size* size) const {
size->set_width(params_.width);
size->set_height(params_.height);
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index 3a7b221..5e92c57 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -110,10 +110,7 @@ void DOMUI::ExecuteJavascript(const std::wstring& javascript) {
///////////////////////////////////////////////////////////////////////////////
// DOMMessageHandler
-DOMMessageHandler* DOMMessageHandler::Attach(DOMUI* dom_ui) {
- dom_ui_ = dom_ui;
- RegisterMessages();
- return this;
+DOMMessageHandler::DOMMessageHandler(DOMUI *dom_ui) : dom_ui_(dom_ui) {
}
// DOMMessageHandler, protected: ----------------------------------------------
diff --git a/chrome/browser/dom_ui/dom_ui.h b/chrome/browser/dom_ui/dom_ui.h
index 1d81428..553ab28 100644
--- a/chrome/browser/dom_ui/dom_ui.h
+++ b/chrome/browser/dom_ui/dom_ui.h
@@ -129,13 +129,9 @@ class DOMUI {
// host is destroyed.
class DOMMessageHandler {
public:
- DOMMessageHandler() : dom_ui_(NULL) { }
+ explicit DOMMessageHandler(DOMUI* dom_ui);
virtual ~DOMMessageHandler() {};
- // Attaches |this| to |dom_ui| in order to handle messages from it. Declared
- // virtual so that subclasses can do special init work as soon as the dom_ui
- // is provided. Returns |this| for convenience.
- virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
protected:
// Adds "url" and "title" keys on incoming dictionary, setting title
// as the url as a fallback on empty title.
@@ -143,16 +139,13 @@ class DOMMessageHandler {
std::wstring title,
const GURL& gurl);
- // This is where subclasses specify which messages they'd like to handle.
- virtual void RegisterMessages() = 0;
-
// Extract an integer value from a Value.
bool ExtractIntegerValue(const Value* value, int* out_int);
// Extract a string value from a Value.
std::wstring ExtractStringValue(const Value* value);
- DOMUI* dom_ui_;
+ DOMUI* const dom_ui_;
private:
DISALLOW_COPY_AND_ASSIGN(DOMMessageHandler);
diff --git a/chrome/browser/dom_ui/downloads_dom_handler.cc b/chrome/browser/dom_ui/downloads_dom_handler.cc
index 66ee916..b27a520 100644
--- a/chrome/browser/dom_ui/downloads_dom_handler.cc
+++ b/chrome/browser/dom_ui/downloads_dom_handler.cc
@@ -47,28 +47,10 @@ class DownloadItemSorter : public std::binary_function<DownloadItem*,
} // namespace
-DownloadsDOMHandler::DownloadsDOMHandler(DownloadManager* dlm)
- : search_text_(),
+DownloadsDOMHandler::DownloadsDOMHandler(DOMUI* dom_ui, DownloadManager* dlm)
+ : DOMMessageHandler(dom_ui),
+ search_text_(),
download_manager_(dlm) {
- // Create our fileicon data source.
- g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(&chrome_url_data_manager,
- &ChromeURLDataManager::AddDataSource,
- new FileIconSource()));
-}
-
-DownloadsDOMHandler::~DownloadsDOMHandler() {
- ClearDownloadItems();
- download_manager_->RemoveObserver(this);
-}
-
-// DownloadsDOMHandler, public: -----------------------------------------------
-
-void DownloadsDOMHandler::Init() {
- download_manager_->AddObserver(this);
-}
-
-void DownloadsDOMHandler::RegisterMessages() {
dom_ui_->RegisterMessageCallback("getDownloads",
NewCallback(this, &DownloadsDOMHandler::HandleGetDownloads));
dom_ui_->RegisterMessageCallback("openFile",
@@ -91,6 +73,24 @@ void DownloadsDOMHandler::RegisterMessages() {
NewCallback(this, &DownloadsDOMHandler::HandleCancel));
dom_ui_->RegisterMessageCallback("clearAll",
NewCallback(this, &DownloadsDOMHandler::HandleClearAll));
+
+
+ // Create our fileicon data source.
+ g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(&chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource,
+ new FileIconSource()));
+}
+
+DownloadsDOMHandler::~DownloadsDOMHandler() {
+ ClearDownloadItems();
+ download_manager_->RemoveObserver(this);
+}
+
+// DownloadsDOMHandler, public: -----------------------------------------------
+
+void DownloadsDOMHandler::Init() {
+ download_manager_->AddObserver(this);
}
void DownloadsDOMHandler::OnDownloadUpdated(DownloadItem* download) {
diff --git a/chrome/browser/dom_ui/downloads_dom_handler.h b/chrome/browser/dom_ui/downloads_dom_handler.h
index a0158c4..729960c 100644
--- a/chrome/browser/dom_ui/downloads_dom_handler.h
+++ b/chrome/browser/dom_ui/downloads_dom_handler.h
@@ -19,14 +19,11 @@ class DownloadsDOMHandler : public DOMMessageHandler,
public DownloadManager::Observer,
public DownloadItem::Observer {
public:
- explicit DownloadsDOMHandler(DownloadManager* dlm);
+ explicit DownloadsDOMHandler(DOMUI* dom_ui, DownloadManager* dlm);
virtual ~DownloadsDOMHandler();
void Init();
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
// DownloadItem::Observer interface
virtual void OnDownloadUpdated(DownloadItem* download);
virtual void OnDownloadOpened(DownloadItem* download) { }
diff --git a/chrome/browser/dom_ui/downloads_ui.cc b/chrome/browser/dom_ui/downloads_ui.cc
index df1c21c..6840b00 100644
--- a/chrome/browser/dom_ui/downloads_ui.cc
+++ b/chrome/browser/dom_ui/downloads_ui.cc
@@ -121,9 +121,9 @@ DownloadsUI::DownloadsUI(TabContents* contents) : DOMUI(contents) {
DownloadManager* dlm = GetProfile()->GetOriginalProfile()->
GetDownloadManager();
- DownloadsDOMHandler* handler = new DownloadsDOMHandler(dlm);
+ DownloadsDOMHandler* handler = new DownloadsDOMHandler(this, dlm);
AddMessageHandler(handler);
- handler->Attach(this);
+ handler->Init();
DownloadsUIHTMLSource* html_source = new DownloadsUIHTMLSource();
diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc
index a819ab2..b40b6ff 100644
--- a/chrome/browser/dom_ui/history_ui.cc
+++ b/chrome/browser/dom_ui/history_ui.cc
@@ -96,9 +96,17 @@ void HistoryUIHTMLSource::StartDataRequest(const std::string& path,
// HistoryHandler
//
////////////////////////////////////////////////////////////////////////////////
-BrowsingHistoryHandler::BrowsingHistoryHandler()
- : search_text_(),
+BrowsingHistoryHandler::BrowsingHistoryHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ search_text_(),
remover_(NULL) {
+ dom_ui_->RegisterMessageCallback("getHistory",
+ NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory));
+ dom_ui_->RegisterMessageCallback("searchHistory",
+ NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory));
+ dom_ui_->RegisterMessageCallback("deleteDay",
+ NewCallback(this, &BrowsingHistoryHandler::HandleDeleteDay));
+
// Create our favicon data source.
g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(&chrome_url_data_manager,
@@ -116,15 +124,6 @@ BrowsingHistoryHandler::~BrowsingHistoryHandler() {
remover_->RemoveObserver(this);
}
-void BrowsingHistoryHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("getHistory",
- NewCallback(this, &BrowsingHistoryHandler::HandleGetHistory));
- dom_ui_->RegisterMessageCallback("searchHistory",
- NewCallback(this, &BrowsingHistoryHandler::HandleSearchHistory));
- dom_ui_->RegisterMessageCallback("deleteDay",
- NewCallback(this, &BrowsingHistoryHandler::HandleDeleteDay));
-}
-
void BrowsingHistoryHandler::HandleGetHistory(const Value* value) {
// Anything in-flight is invalid.
cancelable_consumer_.CancelAllRequests();
@@ -357,7 +356,7 @@ void BrowsingHistoryHandler::Observe(NotificationType type,
////////////////////////////////////////////////////////////////////////////////
HistoryUI::HistoryUI(TabContents* contents) : DOMUI(contents) {
- AddMessageHandler((new BrowsingHistoryHandler())->Attach(this));
+ AddMessageHandler(new BrowsingHistoryHandler(this));
HistoryUIHTMLSource* html_source = new HistoryUIHTMLSource();
diff --git a/chrome/browser/dom_ui/history_ui.h b/chrome/browser/dom_ui/history_ui.h
index 46aa419..f44e033 100644
--- a/chrome/browser/dom_ui/history_ui.h
+++ b/chrome/browser/dom_ui/history_ui.h
@@ -35,12 +35,9 @@ class BrowsingHistoryHandler : public DOMMessageHandler,
public NotificationObserver,
public BrowsingDataRemover::Observer {
public:
- BrowsingHistoryHandler();
+ explicit BrowsingHistoryHandler(DOMUI* dom_ui_);
virtual ~BrowsingHistoryHandler();
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
// Callback for the "getHistory" message.
void HandleGetHistory(const Value* value);
diff --git a/chrome/browser/dom_ui/html_dialog_ui.cc b/chrome/browser/dom_ui/html_dialog_ui.cc
index 4f7995d..060625d 100644
--- a/chrome/browser/dom_ui/html_dialog_ui.cc
+++ b/chrome/browser/dom_ui/html_dialog_ui.cc
@@ -61,20 +61,11 @@ void HtmlDialogUI::RenderViewCreated(RenderViewHost* render_view_host) {
// Pass the arguments to the renderer supplied by the delegate.
std::string dialog_args;
- std::vector<DOMMessageHandler*> handlers;
HtmlDialogUIDelegate** delegate = GetPropertyAccessor().GetProperty(
tab_contents()->property_bag());
- if (delegate) {
+ if (delegate)
dialog_args = (*delegate)->GetDialogArgs();
- (*delegate)->GetDOMMessageHandlers(&handlers);
- }
-
render_view_host->SetDOMUIProperty("dialogArguments", dialog_args);
- for (std::vector<DOMMessageHandler*>::iterator it = handlers.begin();
- it != handlers.end(); ++it) {
- (*it)->Attach(this);
- AddMessageHandler(*it);
- }
}
void HtmlDialogUI::OnDialogClosed(const Value* content) {
diff --git a/chrome/browser/dom_ui/html_dialog_ui.h b/chrome/browser/dom_ui/html_dialog_ui.h
index fce8f7c..76240cd 100644
--- a/chrome/browser/dom_ui/html_dialog_ui.h
+++ b/chrome/browser/dom_ui/html_dialog_ui.h
@@ -5,8 +5,6 @@
#ifndef CHROME_BROWSER_DOM_UI_HTML_DIALOG_UI_H_
#define CHROME_BROWSER_DOM_UI_HTML_DIALOG_UI_H_
-#include <vector>
-
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/common/property_bag.h"
#include "googleurl/src/gurl.h"
@@ -27,13 +25,6 @@ class HtmlDialogUIDelegate {
// Get the HTML file path for the content to load in the dialog.
virtual GURL GetDialogContentURL() const = 0;
- // Get DOMMessageHandler objects to handle messages from the HTML/JS page.
- // The handlers are used to send and receive messages from the page while it
- // is still open. Ownership of each handler is taken over by the DOMUI
- // hosting the page.
- virtual void GetDOMMessageHandlers(
- std::vector<DOMMessageHandler*>* handlers) const = 0;
-
// Get the size of the dialog.
virtual void GetDialogSize(gfx::Size* size) const = 0;
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 8859efb..2c4de50 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -458,12 +458,8 @@ void IncognitoTabHTMLSource::StartDataRequest(const std::string& path,
class MostVisitedHandler : public DOMMessageHandler,
public NotificationObserver {
public:
- MostVisitedHandler() : url_blacklist_(NULL), pinned_urls_(NULL) { }
- virtual ~MostVisitedHandler() { }
-
- // DOMMessageHandler override and implementation.
- virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
- virtual void RegisterMessages();
+ explicit MostVisitedHandler(DOMUI* dom_ui);
+ virtual ~MostVisitedHandler();
// Callback for the "getMostVisited" message.
void HandleGetMostVisited(const Value* value);
@@ -537,11 +533,33 @@ class MostVisitedHandler : public DOMMessageHandler,
DISALLOW_COPY_AND_ASSIGN(MostVisitedHandler);
};
-DOMMessageHandler* MostVisitedHandler::Attach(DOMUI* dom_ui) {
- url_blacklist_ = dom_ui->GetProfile()->GetPrefs()->
+MostVisitedHandler::MostVisitedHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui) {
+ // Register ourselves as the handler for the "mostvisited" message from
+ // Javascript.
+ dom_ui_->RegisterMessageCallback("getMostVisited",
+ NewCallback(this, &MostVisitedHandler::HandleGetMostVisited));
+
+ // Register ourselves for any most-visited item blacklisting.
+ dom_ui_->RegisterMessageCallback("blacklistURLFromMostVisited",
+ NewCallback(this, &MostVisitedHandler::HandleBlacklistURL));
+ dom_ui_->RegisterMessageCallback("removeURLsFromMostVisitedBlacklist",
+ NewCallback(this, &MostVisitedHandler::HandleRemoveURLsFromBlacklist));
+ dom_ui_->RegisterMessageCallback("clearMostVisitedURLsBlacklist",
+ NewCallback(this, &MostVisitedHandler::HandleClearBlacklist));
+
+ url_blacklist_ = dom_ui_->GetProfile()->GetPrefs()->
GetMutableDictionary(prefs::kNTPMostVisitedURLsBlacklist);
- pinned_urls_ = dom_ui->GetProfile()->GetPrefs()->
- GetMutableDictionary(prefs::kNTPMostVisitedPinnedURLs);
+
+ // Register ourself for pinned URL messages.
+ dom_ui->RegisterMessageCallback("addPinnedURL",
+ NewCallback(this, &MostVisitedHandler::HandleAddPinnedURL));
+ dom_ui->RegisterMessageCallback("removePinnedURL",
+ NewCallback(this, &MostVisitedHandler::HandleRemovePinnedURL));
+
+ pinned_urls_ = dom_ui_->GetProfile()->GetPrefs()->
+ GetMutableDictionary(prefs::kNTPMostVisitedPinnedURLs);
+
// Set up our sources for thumbnail and favicon data. Since we may be in
// testing mode with no I/O thread, only add our handler when an I/O thread
// exists. Ownership is passed to the ChromeURLDataManager.
@@ -558,30 +576,10 @@ DOMMessageHandler* MostVisitedHandler::Attach(DOMUI* dom_ui) {
// Get notifications when history is cleared.
registrar_.Add(this, NotificationType::HISTORY_URLS_DELETED,
- Source<Profile>(dom_ui->GetProfile()));
-
- return DOMMessageHandler::Attach(dom_ui);
+ Source<Profile>(dom_ui_->GetProfile()));
}
-void MostVisitedHandler::RegisterMessages() {
- // Register ourselves as the handler for the "mostvisited" message from
- // Javascript.
- dom_ui_->RegisterMessageCallback("getMostVisited",
- NewCallback(this, &MostVisitedHandler::HandleGetMostVisited));
-
- // Register ourselves for any most-visited item blacklisting.
- dom_ui_->RegisterMessageCallback("blacklistURLFromMostVisited",
- NewCallback(this, &MostVisitedHandler::HandleBlacklistURL));
- dom_ui_->RegisterMessageCallback("removeURLsFromMostVisitedBlacklist",
- NewCallback(this, &MostVisitedHandler::HandleRemoveURLsFromBlacklist));
- dom_ui_->RegisterMessageCallback("clearMostVisitedURLsBlacklist",
- NewCallback(this, &MostVisitedHandler::HandleClearBlacklist));
-
- // Register ourself for pinned URL messages.
- dom_ui_->RegisterMessageCallback("addPinnedURL",
- NewCallback(this, &MostVisitedHandler::HandleAddPinnedURL));
- dom_ui_->RegisterMessageCallback("removePinnedURL",
- NewCallback(this, &MostVisitedHandler::HandleRemovePinnedURL));
+MostVisitedHandler::~MostVisitedHandler() {
}
void MostVisitedHandler::HandleGetMostVisited(const Value* value) {
@@ -830,12 +828,9 @@ void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) {
class TemplateURLHandler : public DOMMessageHandler,
public TemplateURLModelObserver {
public:
- TemplateURLHandler() : DOMMessageHandler(), template_url_model_(NULL) { }
+ explicit TemplateURLHandler(DOMUI* dom_ui);
virtual ~TemplateURLHandler();
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
// Callback for the "getMostSearched" message, sent when the page requests
// the list of available searches.
void HandleGetMostSearched(const Value* content);
@@ -848,23 +843,27 @@ class TemplateURLHandler : public DOMMessageHandler,
virtual void OnTemplateURLModelChanged();
private:
+ DOMUI* dom_ui_;
TemplateURLModel* template_url_model_; // Owned by profile.
DISALLOW_COPY_AND_ASSIGN(TemplateURLHandler);
};
+TemplateURLHandler::TemplateURLHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ dom_ui_(dom_ui),
+ template_url_model_(NULL) {
+ dom_ui->RegisterMessageCallback("getMostSearched",
+ NewCallback(this, &TemplateURLHandler::HandleGetMostSearched));
+ dom_ui->RegisterMessageCallback("doSearch",
+ NewCallback(this, &TemplateURLHandler::HandleDoSearch));
+}
+
TemplateURLHandler::~TemplateURLHandler() {
if (template_url_model_)
template_url_model_->RemoveObserver(this);
}
-void TemplateURLHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("getMostSearched",
- NewCallback(this, &TemplateURLHandler::HandleGetMostSearched));
- dom_ui_->RegisterMessageCallback("doSearch",
- NewCallback(this, &TemplateURLHandler::HandleDoSearch));
-}
-
void TemplateURLHandler::HandleGetMostSearched(const Value* content) {
// The page Javascript has requested the list of keyword searches.
// Start loading them from the template URL backend.
@@ -990,11 +989,8 @@ void TemplateURLHandler::OnTemplateURLModelChanged() {
class RecentlyBookmarkedHandler : public DOMMessageHandler,
public BookmarkModelObserver {
public:
- RecentlyBookmarkedHandler() : model_(NULL) { }
- virtual ~RecentlyBookmarkedHandler();
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
+ explicit RecentlyBookmarkedHandler(DOMUI* dom_ui);
+ ~RecentlyBookmarkedHandler();
// Callback which navigates to the bookmarks page.
void HandleShowBookmarkPage(const Value*);
@@ -1028,23 +1024,27 @@ class RecentlyBookmarkedHandler : public DOMMessageHandler,
virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
BookmarkNode* node) {}
+ DOMUI* dom_ui_;
// The model we're getting bookmarks from. The model is owned by the Profile.
BookmarkModel* model_;
DISALLOW_COPY_AND_ASSIGN(RecentlyBookmarkedHandler);
};
+RecentlyBookmarkedHandler::RecentlyBookmarkedHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ dom_ui_(dom_ui),
+ model_(NULL) {
+ dom_ui->RegisterMessageCallback("getRecentlyBookmarked",
+ NewCallback(this,
+ &RecentlyBookmarkedHandler::HandleGetRecentlyBookmarked));
+}
+
RecentlyBookmarkedHandler::~RecentlyBookmarkedHandler() {
if (model_)
model_->RemoveObserver(this);
}
-void RecentlyBookmarkedHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("getRecentlyBookmarked",
- NewCallback(this,
- &RecentlyBookmarkedHandler::HandleGetRecentlyBookmarked));
-}
-
void RecentlyBookmarkedHandler::HandleGetRecentlyBookmarked(const Value*) {
if (!model_) {
model_ = dom_ui_->GetProfile()->GetBookmarkModel();
@@ -1100,12 +1100,9 @@ void RecentlyBookmarkedHandler::BookmarkNodeChanged(BookmarkModel* model,
class RecentlyClosedTabsHandler : public DOMMessageHandler,
public TabRestoreService::Observer {
public:
- RecentlyClosedTabsHandler() : tab_restore_service_(NULL) { }
+ explicit RecentlyClosedTabsHandler(DOMUI* dom_ui);
virtual ~RecentlyClosedTabsHandler();
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
// Callback for the "reopenTab" message. Rewrites the history of the
// currently displayed tab to be the one in TabRestoreService with a
// history of a session passed in through the content pointer.
@@ -1134,17 +1131,22 @@ class RecentlyClosedTabsHandler : public DOMMessageHandler,
bool WindowToValue(const TabRestoreService::Window& window,
DictionaryValue* dictionary);
+ DOMUI* dom_ui_;
+
// TabRestoreService that we are observing.
TabRestoreService* tab_restore_service_;
DISALLOW_COPY_AND_ASSIGN(RecentlyClosedTabsHandler);
};
-void RecentlyClosedTabsHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("getRecentlyClosedTabs",
+RecentlyClosedTabsHandler::RecentlyClosedTabsHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ dom_ui_(dom_ui),
+ tab_restore_service_(NULL) {
+ dom_ui->RegisterMessageCallback("getRecentlyClosedTabs",
NewCallback(this,
&RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs));
- dom_ui_->RegisterMessageCallback("reopenTab",
+ dom_ui->RegisterMessageCallback("reopenTab",
NewCallback(this, &RecentlyClosedTabsHandler::HandleReopenTab));
}
@@ -1284,22 +1286,21 @@ bool RecentlyClosedTabsHandler::WindowToValue(
class HistoryHandler : public DOMMessageHandler {
public:
- HistoryHandler() { }
- virtual ~HistoryHandler() { }
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
+ explicit HistoryHandler(DOMUI* dom_ui);
// Callback which navigates to the history page and performs a search.
void HandleSearchHistoryPage(const Value* content);
private:
+ DOMUI* dom_ui_;
DISALLOW_COPY_AND_ASSIGN(HistoryHandler);
};
-void HistoryHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("searchHistoryPage",
+HistoryHandler::HistoryHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ dom_ui_(dom_ui) {
+ dom_ui->RegisterMessageCallback("searchHistoryPage",
NewCallback(this, &HistoryHandler::HandleSearchHistoryPage));
}
@@ -1335,22 +1336,21 @@ void HistoryHandler::HandleSearchHistoryPage(const Value* content) {
// information (treat it as RecordComputedMetrics)
class MetricsHandler : public DOMMessageHandler {
public:
- MetricsHandler() { }
- virtual ~MetricsHandler() { }
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
+ explicit MetricsHandler(DOMUI* dom_ui);
+
// Callback which records a user action.
void HandleMetrics(const Value* content);
private:
+ DOMUI* dom_ui_;
DISALLOW_COPY_AND_ASSIGN(MetricsHandler);
};
-void MetricsHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("metrics",
+MetricsHandler::MetricsHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ dom_ui_(dom_ui) {
+ dom_ui->RegisterMessageCallback("metrics",
NewCallback(this, &MetricsHandler::HandleMetrics));
}
@@ -1409,26 +1409,26 @@ NewTabUI::NewTabUI(TabContents* contents)
&ChromeURLDataManager::AddDataSource,
html_source));
} else {
+
if (EnableNewNewTabPage()) {
DownloadManager* dlm = GetProfile()->GetDownloadManager();
DownloadsDOMHandler* downloads_handler =
- new DownloadsDOMHandler(dlm);
- downloads_handler->Attach(this);
+ new DownloadsDOMHandler(this, dlm);
AddMessageHandler(downloads_handler);
downloads_handler->Init();
- AddMessageHandler((new ShownSectionsHandler())->Attach(this));
+ AddMessageHandler(new ShownSectionsHandler(this));
}
- AddMessageHandler((new TemplateURLHandler())->Attach(this));
- AddMessageHandler((new MostVisitedHandler())->Attach(this));
- AddMessageHandler((new RecentlyBookmarkedHandler())->Attach(this));
- AddMessageHandler((new RecentlyClosedTabsHandler())->Attach(this));
- AddMessageHandler((new HistoryHandler())->Attach(this));
- AddMessageHandler((new MetricsHandler())->Attach(this));
if (EnableWebResources())
- AddMessageHandler((new TipsHandler())->Attach(this));
-
+ AddMessageHandler(new TipsHandler(this));
+
+ AddMessageHandler(new TemplateURLHandler(this));
+ AddMessageHandler(new MostVisitedHandler(this));
+ AddMessageHandler(new RecentlyBookmarkedHandler(this));
+ AddMessageHandler(new RecentlyClosedTabsHandler(this));
+ AddMessageHandler(new HistoryHandler(this));
+ AddMessageHandler(new MetricsHandler(this));
#ifdef CHROME_PERSONALIZATION
if (!Personalization::IsP13NDisabled(GetProfile())) {
AddMessageHandler(Personalization::CreateNewTabPageHandler(this));
diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc
index 353dae9..22597cb 100644
--- a/chrome/browser/dom_ui/shown_sections_handler.cc
+++ b/chrome/browser/dom_ui/shown_sections_handler.cc
@@ -9,10 +9,12 @@
#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"
-void ShownSectionsHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("getShownSections",
+ShownSectionsHandler::ShownSectionsHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ dom_ui_(dom_ui) {
+ dom_ui->RegisterMessageCallback("getShownSections",
NewCallback(this, &ShownSectionsHandler::HandleGetShownSections));
- dom_ui_->RegisterMessageCallback("setShownSections",
+ dom_ui->RegisterMessageCallback("setShownSections",
NewCallback(this, &ShownSectionsHandler::HandleSetShownSections));
}
diff --git a/chrome/browser/dom_ui/shown_sections_handler.h b/chrome/browser/dom_ui/shown_sections_handler.h
index d19d484..798a14f 100644
--- a/chrome/browser/dom_ui/shown_sections_handler.h
+++ b/chrome/browser/dom_ui/shown_sections_handler.h
@@ -21,11 +21,7 @@ enum Section {
class ShownSectionsHandler : public DOMMessageHandler {
public:
- ShownSectionsHandler() { }
- virtual ~ShownSectionsHandler() { }
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
+ explicit ShownSectionsHandler(DOMUI* dom_ui);
// Callback for "getShownSections" message.
void HandleGetShownSections(const Value* value);
diff --git a/chrome/browser/dom_ui/tips_handler.cc b/chrome/browser/dom_ui/tips_handler.cc
index f43769b..3df6d4a 100644
--- a/chrome/browser/dom_ui/tips_handler.cc
+++ b/chrome/browser/dom_ui/tips_handler.cc
@@ -21,15 +21,14 @@ namespace {
L"Tips and recommendations to help you discover interesting websites.";
}
-DOMMessageHandler* TipsHandler::Attach(DOMUI* dom_ui) {
+TipsHandler::TipsHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui),
+ dom_ui_(dom_ui) {
+ dom_ui->RegisterMessageCallback("getTips",
+ NewCallback(this, &TipsHandler::HandleGetTips));
+
tips_cache_ = dom_ui_->GetProfile()->GetPrefs()->
GetDictionary(prefs::kNTPTipsCache);
- return DOMMessageHandler::Attach(dom_ui);
-}
-
-void TipsHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("getTips",
- NewCallback(this, &TipsHandler::HandleGetTips));
}
void TipsHandler::HandleGetTips(const Value* content) {
diff --git a/chrome/browser/dom_ui/tips_handler.h b/chrome/browser/dom_ui/tips_handler.h
index a65ebfe..a218e09 100644
--- a/chrome/browser/dom_ui/tips_handler.h
+++ b/chrome/browser/dom_ui/tips_handler.h
@@ -32,12 +32,9 @@ class Value;
class TipsHandler : public DOMMessageHandler {
public:
- TipsHandler() : tips_cache_(NULL) { }
- virtual ~TipsHandler() { }
+ explicit TipsHandler(DOMUI* dom_ui);
- // DOMMessageHandler implementation and overrides.
- virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
- virtual void RegisterMessages();
+ TipsHandler();
// Callback which pulls tips data from the preferences.
void HandleGetTips(const Value* content);
@@ -46,6 +43,9 @@ class TipsHandler : public DOMMessageHandler {
static void RegisterUserPrefs(PrefService* prefs);
private:
+ // So we can push data out to the page that has called this handler.
+ DOMUI* dom_ui_;
+
// Filled with data from cache in preferences.
const DictionaryValue* tips_cache_;
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc
index 7ad40cc..6f08479 100644
--- a/chrome/browser/extensions/extensions_ui.cc
+++ b/chrome/browser/extensions/extensions_ui.cc
@@ -62,12 +62,9 @@ void ExtensionsUIHTMLSource::StartDataRequest(const std::string& path,
//
///////////////////////////////////////////////////////////////////////////////
-ExtensionsDOMHandler::ExtensionsDOMHandler(
- ExtensionsService* extension_service)
- : extensions_service_(extension_service) {
- }
-
-void ExtensionsDOMHandler::RegisterMessages() {
+ExtensionsDOMHandler::ExtensionsDOMHandler(DOMUI* dom_ui,
+ ExtensionsService* extension_service)
+ : DOMMessageHandler(dom_ui), extensions_service_(extension_service) {
dom_ui_->RegisterMessageCallback("requestExtensionsData",
NewCallback(this, &ExtensionsDOMHandler::HandleRequestExtensionsData));
dom_ui_->RegisterMessageCallback("inspect",
@@ -260,13 +257,17 @@ ExtensionsDOMHandler::~ExtensionsDOMHandler() {
// ExtensionsDOMHandler, public: -----------------------------------------------
+void ExtensionsDOMHandler::Init() {
+}
+
ExtensionsUI::ExtensionsUI(TabContents* contents) : DOMUI(contents) {
ExtensionsService *exstension_service =
GetProfile()->GetOriginalProfile()->GetExtensionsService();
- ExtensionsDOMHandler* handler = new ExtensionsDOMHandler(exstension_service);
+ ExtensionsDOMHandler* handler = new ExtensionsDOMHandler(this,
+ exstension_service);
AddMessageHandler(handler);
- handler->Attach(this);
+ handler->Init();
ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource();
diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h
index 39dd2fc..80e0137 100644
--- a/chrome/browser/extensions/extensions_ui.h
+++ b/chrome/browser/extensions/extensions_ui.h
@@ -48,11 +48,11 @@ class ExtensionsUIHTMLSource : public ChromeURLDataManager::DataSource {
// The handler for Javascript messages related to the "extensions" view.
class ExtensionsDOMHandler : public DOMMessageHandler {
public:
- ExtensionsDOMHandler(ExtensionsService* extension_service);
+ ExtensionsDOMHandler(DOMUI* dom_ui,
+ ExtensionsService* extension_service);
+
virtual ~ExtensionsDOMHandler();
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
+ void Init();
// Extension Detail JSON Struct for page. (static for ease of testing).
static DictionaryValue* CreateExtensionDetailValue(
diff --git a/chrome/browser/modal_html_dialog_delegate.h b/chrome/browser/modal_html_dialog_delegate.h
index 17c2d7d..2ab4a9e 100644
--- a/chrome/browser/modal_html_dialog_delegate.h
+++ b/chrome/browser/modal_html_dialog_delegate.h
@@ -33,8 +33,6 @@ class ModalHtmlDialogDelegate
virtual bool IsDialogModal() const;
virtual std::wstring GetDialogTitle() const { return L"Gears"; }
virtual GURL GetDialogContentURL() const;
- virtual void GetDOMMessageHandlers(
- std::vector<DOMMessageHandler*>* handlers) const { }
virtual void GetDialogSize(gfx::Size* size) const;
virtual std::string GetDialogArgs() const;
virtual void OnDialogClosed(const std::string& json_retval);
diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc
index 56c152f..afb23ad 100644
--- a/chrome/browser/views/html_dialog_view.cc
+++ b/chrome/browser/views/html_dialog_view.cc
@@ -93,11 +93,6 @@ GURL HtmlDialogView::GetDialogContentURL() const {
return delegate_->GetDialogContentURL();
}
-void HtmlDialogView::GetDOMMessageHandlers(
- std::vector<DOMMessageHandler*>* handlers) const {
- delegate_->GetDOMMessageHandlers(handlers);
-}
-
void HtmlDialogView::GetDialogSize(gfx::Size* size) const {
delegate_->GetDialogSize(size);
}
diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h
index ff49143..d9edf50 100644
--- a/chrome/browser/views/html_dialog_view.h
+++ b/chrome/browser/views/html_dialog_view.h
@@ -54,8 +54,6 @@ class HtmlDialogView
virtual bool IsDialogModal() const;
virtual std::wstring GetDialogTitle() const;
virtual GURL GetDialogContentURL() const;
- virtual void GetDOMMessageHandlers(
- std::vector<DOMMessageHandler*>* handlers) const;
virtual void GetDialogSize(gfx::Size* size) const;
virtual std::string GetDialogArgs() const;
virtual void OnDialogClosed(const std::string& json_retval);
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 6d67947..3bf3a8e 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -332,8 +332,6 @@ class ModalHtmlDialogDelegate : public HtmlDialogUIDelegate {
virtual bool IsDialogModal() const { return true; }
virtual std::wstring GetDialogTitle() const { return std::wstring(); }
virtual GURL GetDialogContentURL() const { return GURL(); }
- virtual void GetDOMMessageHandlers(
- std::vector<DOMMessageHandler*>* handlers) const {}
virtual void GetDialogSize(gfx::Size* size) const {}
virtual std::string GetDialogArgs() const { return std::string(); }
virtual void OnDialogClosed(const std::string& json_retval) {}