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

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

Issue 7796020: Rename intents_settings_handler files to web_intents_settings_handler. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Merge to head Created 9 years, 3 months 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) 2011 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_INTENTS_MODEL_H_
6 #define CHROME_BROWSER_UI_INTENTS_INTENTS_MODEL_H_
7 #pragma once
8
9 #include "base/values.h"
10 #include "chrome/browser/intents/web_intents_registry.h"
11 #include "ui/base/models/tree_node_model.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 IntentsTreeNode : public ui::TreeNode<IntentsTreeNode> {
21 public:
22 IntentsTreeNode();
23 explicit IntentsTreeNode(const string16& title);
24
25 virtual ~IntentsTreeNode();
26
27 enum NodeType {
28 TYPE_ROOT,
29 TYPE_ORIGIN,
30 TYPE_SERVICE,
31 };
32
33 NodeType Type() const { return type_; }
34
35 protected:
36 IntentsTreeNode(const string16& title, NodeType type)
37 : ui::TreeNode<IntentsTreeNode>(title),
38 type_(type) {}
39
40 private:
41 NodeType type_;
42 };
43
44 // Tree node representing particular services presented by an origin.
45 class ServiceTreeNode : public IntentsTreeNode {
46 public:
47 explicit ServiceTreeNode(const string16& title);
48 virtual ~ServiceTreeNode();
49
50 const string16& ServiceName() const { return service_name_; }
51 const string16& ServiceUrl() const { return service_url_; }
52 const string16& IconUrl() const { return icon_url_; }
53 const string16& Action() const { return action_; }
54 const base::ListValue& Types() const { return types_; }
55 bool IsBlocked() const { return blocked_; }
56 bool IsDisabled() const { return disabled_; }
57
58 void SetServiceName(string16 name) { service_name_ = name; }
59 void SetServiceUrl(string16 url) { service_url_ = url; }
60 void SetIconUrl(string16 url) { icon_url_ = url; }
61 void SetAction(string16 action) { action_ = action; }
62 void AddType(string16 type) { types_.Append(Value::CreateStringValue(type)); }
63 void SetBlocked(bool blocked) { blocked_ = blocked; }
64 void SetDisabled(bool disabled) { disabled_ = disabled; }
65
66 private:
67 string16 service_name_;
68 string16 icon_url_;
69 string16 service_url_;
70 string16 action_;
71 base::ListValue types_;
72
73 // TODO(gbillock): these are kind of a placeholder for exceptions data.
74 bool blocked_;
75 bool disabled_;
76 };
77
78 // UI-backing tree model of the data in the WebIntentsRegistry.
79 class IntentsModel : public ui::TreeNodeModel<IntentsTreeNode>,
80 public WebIntentsRegistry::Consumer {
81 public:
82 // Because nodes are fetched in a background thread, they are not
83 // present at the time the Model is created. The Model then notifies its
84 // observers for every item added.
85 class Observer : public ui::TreeModelObserver {
86 public:
87 virtual void TreeModelBeginBatch(IntentsModel* model) {}
88 virtual void TreeModelEndBatch(IntentsModel* model) {}
89 };
90
91 explicit IntentsModel(WebIntentsRegistry* intents_registry);
92 virtual ~IntentsModel();
93
94 void AddIntentsTreeObserver(Observer* observer);
95 void RemoveIntentsTreeObserver(Observer* observer);
96
97 string16 GetTreeNodeId(IntentsTreeNode* node);
98 IntentsTreeNode* GetTreeNode(std::string path_id);
99 void GetChildNodeList(IntentsTreeNode* parent, int start, int count,
100 base::ListValue* nodes);
101 void GetIntentsTreeNodeDictionary(const IntentsTreeNode& node,
102 base::DictionaryValue* dict);
103
104 virtual void OnIntentsQueryDone(
105 WebIntentsRegistry::QueryID query_id,
106 const std::vector<WebIntentData>& intents) OVERRIDE;
107
108 private:
109 // Loads the data model from the WebIntentsRegistry.
110 // TODO(gbillock): need an observer on that to absorb async updates?
111 void LoadModel();
112
113 // Do batch-specific notifies for updates coming from the LoadModel.
114 void NotifyObserverBeginBatch();
115 void NotifyObserverEndBatch();
116
117 // The backing registry. Weak pointer.
118 WebIntentsRegistry* intents_registry_;
119
120 // Separate list of observers that'll get batch updates.
121 ObserverList<Observer> intents_observer_list_;
122
123 // Batch update nesting level. Incremented to indicate that we're in
124 // the middle of a batch update.
125 int batch_update_;
126 };
127
128 #endif // CHROME_BROWSER_UI_INTENTS_INTENTS_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/intents/web_intents_registry.h ('k') | chrome/browser/ui/intents/intents_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698