Chromium Code Reviews| Index: chrome/browser/ui/webui/aura/app_list_ui.cc |
| diff --git a/chrome/browser/ui/webui/aura/app_list_ui.cc b/chrome/browser/ui/webui/aura/app_list_ui.cc |
| index 574a0aac36b4fb8950001f65c58dc797f01766e2..974b874ffdaee344bf1d7e1017d41fff0b0cef4c 100644 |
| --- a/chrome/browser/ui/webui/aura/app_list_ui.cc |
| +++ b/chrome/browser/ui/webui/aura/app_list_ui.cc |
| @@ -76,10 +76,47 @@ ChromeWebUIDataSource* CreateAppListUIHTMLSource(PrefService* prefs) { |
| return source; |
| } |
| +class AppListHandler : public WebUIMessageHandler { |
| + public: |
| + AppListHandler() {} |
| + virtual ~AppListHandler() {} |
| + |
| + // WebUIMessageHandler |
| + virtual void RegisterMessages() OVERRIDE; |
| + |
| + private: |
| + AppListUI* app_list_ui() const { |
| + return static_cast<AppListUI*>(web_ui_); |
| + } |
| + |
| + void HandleClose(const base::ListValue* args); |
| + void HandleAppsLoaded(const base::ListValue* args); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppListHandler); |
| +}; |
| + |
| +void AppListHandler::RegisterMessages() { |
| + web_ui_->RegisterMessageCallback("close", |
| + base::Bind(&AppListHandler::HandleClose, base::Unretained(this))); |
| + web_ui_->RegisterMessageCallback("onAppsLoaded", |
| + base::Bind(&AppListHandler::HandleAppsLoaded, base::Unretained(this))); |
| +} |
| + |
| +void AppListHandler::HandleClose(const base::ListValue* args) { |
| + app_list_ui()->delegate()->Close(); |
|
sky
2011/11/30 21:50:21
Might the delegate be NULL here and on 110?
xiyuan
2011/11/30 22:26:34
It should never be NULL. Added a DCHECK to catch t
|
| +} |
| + |
| +void AppListHandler::HandleAppsLoaded(const base::ListValue* args) { |
| + app_list_ui()->delegate()->OnAppsLoaded(); |
| +} |
| + |
| } // namespace |
| AppListUI::AppListUI(TabContents* contents) |
| - : ChromeWebUI(contents) { |
| + : ChromeWebUI(contents), |
| + delegate_(NULL) { |
| + AddMessageHandler((new AppListHandler)->Attach(this)); |
| + |
| ExtensionService* service = GetProfile()->GetExtensionService(); |
| if (service) |
| AddMessageHandler((new AppLauncherHandler(service))->Attach(this)); |