summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorcsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 17:07:47 +0000
committercsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 17:07:47 +0000
commit2d300e710abab2137223ad48be681387efd9550d (patch)
treeeee5de75e1a83adb245ec6d4f2d8b69f85e87f99 /content
parentc4170c98f76cc7d6bf4eddd13291884b3523010b (diff)
downloadchromium_src-2d300e710abab2137223ad48be681387efd9550d.zip
chromium_src-2d300e710abab2137223ad48be681387efd9550d.tar.gz
chromium_src-2d300e710abab2137223ad48be681387efd9550d.tar.bz2
[web-ui] Remove support for legacy-style callbacks.
BUG=98478 Review URL: http://codereview.chromium.org/8199011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105105 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/webui/web_ui.cc38
-rw-r--r--content/browser/webui/web_ui.h21
2 files changed, 10 insertions, 49 deletions
diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc
index 206d221..92e55c9 100644
--- a/content/browser/webui/web_ui.cc
+++ b/content/browser/webui/web_ui.cc
@@ -52,9 +52,6 @@ WebUI::WebUI(TabContents* contents)
}
WebUI::~WebUI() {
- // TODO(csilv): Remove legacy callback support.
- STLDeleteContainerPairSecondPointers(message_callbacks_.begin(),
- message_callbacks_.end());
STLDeleteContainerPointers(handlers_.begin(), handlers_.end());
}
@@ -81,21 +78,11 @@ void WebUI::OnWebUISend(const GURL& source_url,
}
// Look up the callback for this message.
- NewMessageCallbackMap::const_iterator new_callback =
- new_message_callbacks_.find(message);
- if (new_callback != new_message_callbacks_.end()) {
- // Forward this message and content on.
- new_callback->second.Run(&args);
- return;
- }
-
- // TODO(csilv): Remove legacy callback support.
- // Look up the callback for this message.
MessageCallbackMap::const_iterator callback =
message_callbacks_.find(message);
if (callback != message_callbacks_.end()) {
// Forward this message and content on.
- callback->second->Run(&args);
+ callback->second.Run(&args);
}
}
@@ -170,30 +157,13 @@ void WebUI::CallJavascriptFunction(
}
void WebUI::RegisterMessageCallback(const std::string &message,
- const NewMessageCallback& callback) {
- std::pair<NewMessageCallbackMap::iterator, bool> result =
- new_message_callbacks_.insert(std::make_pair(message, callback));
-
- // Overwrite preexisting message callback mappings.
- if (!result.second && register_callback_overwrites())
- result.first->second = callback;
-}
-
-// TODO(csilv): Remove legacy callback support.
-void WebUI::RegisterMessageCallback(const std::string& message,
- MessageCallback* callback) {
+ const MessageCallback& callback) {
std::pair<MessageCallbackMap::iterator, bool> result =
message_callbacks_.insert(std::make_pair(message, callback));
// Overwrite preexisting message callback mappings.
- if (!result.second) {
- if (register_callback_overwrites()) {
- delete result.first->second;
- result.first->second = callback;
- } else {
- delete callback;
- }
- }
+ if (!result.second && register_callback_overwrites())
+ result.first->second = callback;
}
bool WebUI::IsLoading() const {
diff --git a/content/browser/webui/web_ui.h b/content/browser/webui/web_ui.h
index 6d0e16c..7c5b270 100644
--- a/content/browser/webui/web_ui.h
+++ b/content/browser/webui/web_ui.h
@@ -66,17 +66,12 @@ class CONTENT_EXPORT WebUI : public IPC::Channel::Listener {
// won't be run in that case.
virtual void DidBecomeActiveForReusedRenderView() {}
- // Used by WebUIMessageHandlers. RegisterMessageCallback takes ownership of
- // the passed callback. If the given message is already registered, the call
- // has no effect unless |register_callback_overwrites_| is set to true.
- typedef base::Callback<void(const base::ListValue*)> NewMessageCallback;
+ // Used by WebUIMessageHandlers. If the given message is already registered,
+ // the call has no effect unless |register_callback_overwrites_| is set to
+ // true.
+ typedef base::Callback<void(const base::ListValue*)> MessageCallback;
void RegisterMessageCallback(const std::string& message,
- const NewMessageCallback& callback);
-
- // TODO(csilv): Remove legacy callback support
- typedef Callback1<const base::ListValue*>::Type MessageCallback;
- void RegisterMessageCallback(const std::string& message,
- MessageCallback* callback);
+ const MessageCallback& callback);
// Returns true if the favicon should be hidden for the current tab.
bool hide_favicon() const {
@@ -196,11 +191,7 @@ class CONTENT_EXPORT WebUI : public IPC::Channel::Listener {
private:
// A map of message name -> message handling callback.
- typedef std::map<std::string, NewMessageCallback> NewMessageCallbackMap;
- NewMessageCallbackMap new_message_callbacks_;
-
- // TODO(csilv): Remove legacy callback support.
- typedef std::map<std::string, MessageCallback*> MessageCallbackMap;
+ typedef std::map<std::string, MessageCallback> MessageCallbackMap;
MessageCallbackMap message_callbacks_;
DISALLOW_COPY_AND_ASSIGN(WebUI);