Chromium Code Reviews| Index: chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc |
| diff --git a/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc b/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..461a0806045d1228d1c9c038ff2ce080ec15d747 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc |
| @@ -0,0 +1,37 @@ |
| +// Copyright 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/values.h" |
| +#include "content/public/browser/notification_details.h" |
| +#include "content/public/browser/notification_service.h" |
| +#include "content/public/browser/notification_source.h" |
| +#include "content/public/browser/notification_types.h" |
| +#include "content/public/browser/web_ui.h" |
| + |
| +UserActionsUIHandler::UserActionsUIHandler() : NotificationObserver() { |
| + registrar_.Add(this, |
| + content::NOTIFICATION_USER_ACTION, |
| + content::NotificationService::AllSources()); |
| +} |
| + |
| +UserActionsUIHandler::~UserActionsUIHandler() { |
| + // No need to explicitly unregister ourselves--it's done automatically |
|
Evan Stade
2012/11/20 23:09:57
this comment is unecessary imo
Mark P
2012/11/20 23:45:41
I found the behavior confusing/surprising; I'd rat
Evan Stade
2012/11/20 23:59:16
this behavior is 99% of the reason registrar_ exis
Mark P
2012/11/21 00:18:14
Okay. Good argument. I haven't look widely throu
|
| + // when registrar_ is deleted. |
| +} |
| + |
| +void UserActionsUIHandler::Observe( |
| + int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + DCHECK_EQ(type, content::NOTIFICATION_USER_ACTION); |
| + base::StringValue user_action_name( |
| + *content::Details<const char*>(details).ptr()); |
| + web_ui()->CallJavascriptFunction("userActions.observeUserAction", |
| + user_action_name); |
| +} |
| + |
| +void UserActionsUIHandler::RegisterMessages() {} |