blob: 736f449bfaee03de9e31f1a9a53ac4d73d7e57f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// Copyright (c) 2011 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.
#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_MENU_UI_H_
#define CHROME_BROWSER_CHROMEOS_WEBUI_MENU_UI_H_
#pragma once
#include <string>
#include "chrome/browser/webui/chrome_url_data_manager.h"
#include "content/browser/webui/web_ui.h"
class DictionaryValue;
namespace ui{
class MenuModel;
} // namespace ui
namespace chromeos {
class WebUIMenuControl;
// MenuSourceDelegate class allows subclass to injects specific values
// to menu javascript code.
class MenuSourceDelegate {
public:
virtual ~MenuSourceDelegate() {}
// Subclass can add extra parameters or replaces default configuration.
virtual void AddCustomConfigValues(DictionaryValue* config) const {}
// Subclass can add their values to |localized_strings| and those values
// are used by JS template builder and could be accessed via JS class
// LocalStrings.
virtual void AddLocalizedStrings(DictionaryValue* localized_strings) const {}
};
class MenuUI : public WebUI {
public:
explicit MenuUI(TabContents* contents);
// A callback method that is invoked when a menu model associated
// with the WebUI Menu gets updated.
virtual void ModelUpdated(const ui::MenuModel* new_model);
// Creates a menu item for the menu item at index in the model.
virtual DictionaryValue* CreateMenuItem(const ui::MenuModel* model,
int index,
const char* type,
int* max_icon_width,
bool* has_accel) const;
// A utility function which creates a concrete html file from
// template file |menu_resource_id| and |menu_css_id| for given |menu_class|.
// The resource_name is the host part of WebUI's url.
static ChromeURLDataManager::DataSource* CreateMenuUIHTMLSource(
const MenuSourceDelegate* delegate,
const std::string& source_name,
const std::string& menu_class,
int menu_source_res_id,
int menu_css_res_id);
// Returns true if DMOUI menu is enabled.
static bool IsEnabled();
protected:
// A constructor for subclass to initialize the MenuUI with
// different data source.
MenuUI(TabContents* contents, ChromeURLDataManager::DataSource* source);
private:
// Create HTML Data source for the menu.
ChromeURLDataManager::DataSource* CreateDataSource();
DISALLOW_COPY_AND_ASSIGN(MenuUI);
};
// Base class for MenuUI's WebUIMessageHandler.
class MenuHandlerBase : public WebUIMessageHandler {
public:
MenuHandlerBase() : WebUIMessageHandler() {}
// Returns the menu control that is associated with the
// MenuUI. This may return null when menu is being deleted.
WebUIMenuControl* GetMenuControl();
// Returns the menu model for this menu ui.
// This may return null when menu is being deleted.
ui::MenuModel* GetMenuModel();
private:
DISALLOW_COPY_AND_ASSIGN(MenuHandlerBase);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_WEBUI_MENU_UI_H_
|