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

Side by Side Diff: chrome/browser/ui/intents/web_intents_model.h

Issue 11410040: Delete WebUI for web intents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Return value from flag for profile disablement Created 8 years, 1 month 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
(Empty)
1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENTS_MODEL_H_
6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENTS_MODEL_H_
7
8 #include "base/basictypes.h"
9 #include "base/values.h"
10 #include "ui/base/models/tree_node_model.h"
11 #include "webkit/glue/web_intent_service_data.h"
12
13 class WebIntentsRegistry;
14
15 // The tree structure is a TYPE_ROOT node with title="",
16 // children are TYPE_ORIGIN nodes with title=origin, whose
17 // children are TYPE_SERVICE nodes with title=origin, and
18 // will be of type ServiceTreeNode with data on individual
19 // services.
20 class WebIntentsTreeNode : public ui::TreeNode<WebIntentsTreeNode> {
21 public:
22 enum NodeType {
23 TYPE_ROOT,
24 TYPE_ORIGIN,
25 TYPE_SERVICE,
26 };
27
28 WebIntentsTreeNode();
29 explicit WebIntentsTreeNode(const string16& title);
30 virtual ~WebIntentsTreeNode();
31
32 NodeType Type() const { return type_; }
33
34 protected:
35 WebIntentsTreeNode(const string16& title, NodeType type)
36 : ui::TreeNode<WebIntentsTreeNode>(title),
37 type_(type) {}
38
39 private:
40 NodeType type_;
41
42 DISALLOW_COPY_AND_ASSIGN(WebIntentsTreeNode);
43 };
44
45 // Tree node representing particular services presented by an origin.
46 class ServiceTreeNode : public WebIntentsTreeNode {
47 public:
48 explicit ServiceTreeNode(const string16& title);
49 virtual ~ServiceTreeNode();
50
51 const string16& ServiceName() const { return service_name_; }
52 const string16& ServiceUrl() const { return service_url_; }
53 const string16& IconUrl() const { return icon_url_; }
54 const string16& Action() const { return action_; }
55 const base::ListValue& Types() const { return types_; }
56 bool IsBlocked() const { return blocked_; }
57 bool IsDisabled() const { return disabled_; }
58
59 void SetServiceName(const string16& name) { service_name_ = name; }
60 void SetServiceUrl(const string16& url) { service_url_ = url; }
61 void SetIconUrl(const string16& url) { icon_url_ = url; }
62 void SetAction(const string16& action) { action_ = action; }
63 void AddType(const string16& type) {
64 types_.Append(base::Value::CreateStringValue(type));
65 }
66 void SetBlocked(bool blocked) { blocked_ = blocked; }
67 void SetDisabled(bool disabled) { disabled_ = disabled; }
68
69 private:
70 string16 service_name_;
71 string16 icon_url_;
72 string16 service_url_;
73 string16 action_;
74 base::ListValue types_;
75
76 // TODO(gbillock): these are kind of a placeholder for exceptions data.
77 bool blocked_;
78 bool disabled_;
79
80 DISALLOW_COPY_AND_ASSIGN(ServiceTreeNode);
81 };
82
83 // UI-backing tree model of the data in the WebIntentsRegistry.
84 class WebIntentsModel : public ui::TreeNodeModel<WebIntentsTreeNode> {
85 public:
86 // Because nodes are fetched in a background thread, they are not
87 // present at the time the Model is created. The Model then notifies its
88 // observers for every item added.
89 class Observer : public ui::TreeModelObserver {
90 public:
91 virtual void TreeModelBeginBatch(WebIntentsModel* model) {}
92 virtual void TreeModelEndBatch(WebIntentsModel* model) {}
93 };
94
95 explicit WebIntentsModel(WebIntentsRegistry* intents_registry);
96 virtual ~WebIntentsModel();
97
98 void AddWebIntentsTreeObserver(Observer* observer);
99 void RemoveWebIntentsTreeObserver(Observer* observer);
100
101 string16 GetTreeNodeId(WebIntentsTreeNode* node);
102 WebIntentsTreeNode* GetTreeNode(const std::string& path_id);
103 void GetChildNodeList(WebIntentsTreeNode* parent,
104 int start,
105 int count,
106 base::ListValue* nodes);
107 void GetWebIntentsTreeNodeDictionary(const WebIntentsTreeNode& node,
108 base::DictionaryValue* dict);
109
110 void OnIntentsQueryDone(
111 const std::vector<webkit_glue::WebIntentServiceData>& services);
112
113 private:
114 // Loads the data model from the WebIntentsRegistry.
115 // TODO(gbillock): need an observer on that to absorb async updates?
116 void LoadModel();
117
118 // Get the model node for a particular host.
119 WebIntentsTreeNode* GetNodeForHost(const std::string& host);
120
121 // Do batch-specific notifies for updates coming from the LoadModel.
122 void NotifyObserverBeginBatch();
123 void NotifyObserverEndBatch();
124
125 // The backing registry. Weak pointer.
126 WebIntentsRegistry* intents_registry_;
127
128 // Separate list of observers that'll get batch updates.
129 ObserverList<Observer> intents_observer_list_;
130
131 // Batch update nesting level. Incremented to indicate that we're in
132 // the middle of a batch update.
133 int batch_update_;
134
135 DISALLOW_COPY_AND_ASSIGN(WebIntentsModel);
136 };
137
138 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENTS_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/content_settings.js ('k') | chrome/browser/ui/intents/web_intents_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698