Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc

Issue 12039079: content: convert user action notification to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h" 5 #include "chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_service.h"
11 #include "content/public/browser/notification_source.h"
12 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/web_ui.h" 9 #include "content/public/browser/web_ui.h"
14 10
15 UserActionsUIHandler::UserActionsUIHandler() : NotificationObserver() { 11 UserActionsUIHandler::UserActionsUIHandler()
16 registrar_.Add(this, 12 : action_callback_(base::Bind(&UserActionsUIHandler::OnUserAction,
17 content::NOTIFICATION_USER_ACTION, 13 base::Unretained(this))) {
18 content::NotificationService::AllSources()); 14 content::AddActionCallback(action_callback_);
19 } 15 }
20 16
21 UserActionsUIHandler::~UserActionsUIHandler() { 17 UserActionsUIHandler::~UserActionsUIHandler() {
18 content::RemoveActionCallback(action_callback_);
22 } 19 }
23 20
24 void UserActionsUIHandler::Observe( 21 void UserActionsUIHandler::RegisterMessages() {}
25 int type, 22
26 const content::NotificationSource& source, 23 void UserActionsUIHandler::OnUserAction(const std::string& action) {
27 const content::NotificationDetails& details) { 24 base::StringValue user_action_name(action);
28 DCHECK_EQ(type, content::NOTIFICATION_USER_ACTION);
29 base::StringValue user_action_name(
30 *content::Details<const char*>(details).ptr());
31 web_ui()->CallJavascriptFunction("userActions.observeUserAction", 25 web_ui()->CallJavascriptFunction("userActions.observeUserAction",
32 user_action_name); 26 user_action_name);
33 } 27 }
34 28
35 void UserActionsUIHandler::RegisterMessages() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698