blob: c18e9fbd71df27f4b691c8a385c4b953b9282fb0 [file] [log] [blame]
[email protected]f17be762014-01-30 21:05:381// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/ui/webui/invalidations_ui.h"
6
7#include "chrome/browser/profiles/profile.h"
[email protected]b7600272014-02-11 18:55:558#include "chrome/browser/ui/webui/invalidations_message_handler.h"
[email protected]f17be762014-01-30 21:05:389#include "chrome/common/url_constants.h"
10#include "content/public/browser/web_ui.h"
11#include "content/public/browser/web_ui_data_source.h"
[email protected]b7600272014-02-11 18:55:5512#include "content/public/browser/web_ui_message_handler.h"
[email protected]f17be762014-01-30 21:05:3813#include "grit/invalidations_resources.h"
14
15content::WebUIDataSource* CreateInvalidationsHTMLSource() {
16 // This is done once per opening of the page
17 // This method does not fire when refreshing the page
18 content::WebUIDataSource* source =
19 content::WebUIDataSource::Create(chrome::kChromeUIInvalidationsHost);
20 source->AddResourcePath("about_invalidations.js", IDR_ABOUT_INVALIDATIONS_JS);
21 source->SetDefaultResource(IDR_ABOUT_INVALIDATIONS_HTML);
22 return source;
23}
24
25InvalidationsUI::InvalidationsUI(content::WebUI* web_ui)
26 : WebUIController(web_ui) {
27 Profile* profile = Profile::FromWebUI(web_ui);
28 if (profile) {
29 content::WebUIDataSource::Add(profile, CreateInvalidationsHTMLSource());
[email protected]b7600272014-02-11 18:55:5530 InvalidationsMessageHandler* message_handler =
31 new InvalidationsMessageHandler();
32 // The MessageHandler of web_ui takes ownership of the object
33 web_ui->AddMessageHandler(message_handler);
[email protected]f17be762014-01-30 21:05:3834 }
35}
36
37InvalidationsUI::~InvalidationsUI() { }
[email protected]b7600272014-02-11 18:55:5538