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

Side by Side Diff: chrome/browser/ui/intents/web_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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_INTENTS_INTENTS_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENTS_MODEL_H_
6 #define CHROME_BROWSER_UI_INTENTS_INTENTS_MODEL_H_ 6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENTS_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/intents/web_intents_registry.h" 10 #include "chrome/browser/intents/web_intents_registry.h"
11 #include "ui/base/models/tree_node_model.h" 11 #include "ui/base/models/tree_node_model.h"
12 12
13 class WebIntentsRegistry; 13 class WebIntentsRegistry;
14 14
15 // The tree structure is a TYPE_ROOT node with title="", 15 // The tree structure is a TYPE_ROOT node with title="",
16 // children are TYPE_ORIGIN nodes with title=origin, whose 16 // children are TYPE_ORIGIN nodes with title=origin, whose
17 // children are TYPE_SERVICE nodes with title=origin, and 17 // children are TYPE_SERVICE nodes with title=origin, and
18 // will be of type ServiceTreeNode with data on individual 18 // will be of type ServiceTreeNode with data on individual
19 // services. 19 // services.
20 class IntentsTreeNode : public ui::TreeNode<IntentsTreeNode> { 20 class WebIntentsTreeNode : public ui::TreeNode<WebIntentsTreeNode> {
21 public: 21 public:
22 IntentsTreeNode(); 22 WebIntentsTreeNode();
23 explicit IntentsTreeNode(const string16& title); 23 explicit WebIntentsTreeNode(const string16& title);
24 24
25 virtual ~IntentsTreeNode(); 25 virtual ~WebIntentsTreeNode();
26 26
27 enum NodeType { 27 enum NodeType {
28 TYPE_ROOT, 28 TYPE_ROOT,
29 TYPE_ORIGIN, 29 TYPE_ORIGIN,
30 TYPE_SERVICE, 30 TYPE_SERVICE,
31 }; 31 };
32 32
33 NodeType Type() const { return type_; } 33 NodeType Type() const { return type_; }
34 34
35 protected: 35 protected:
36 IntentsTreeNode(const string16& title, NodeType type) 36 WebIntentsTreeNode(const string16& title, NodeType type)
37 : ui::TreeNode<IntentsTreeNode>(title), 37 : ui::TreeNode<WebIntentsTreeNode>(title),
38 type_(type) {} 38 type_(type) {}
39 39
40 private: 40 private:
41 NodeType type_; 41 NodeType type_;
42 }; 42 };
43 43
44 // Tree node representing particular services presented by an origin. 44 // Tree node representing particular services presented by an origin.
45 class ServiceTreeNode : public IntentsTreeNode { 45 class ServiceTreeNode : public WebIntentsTreeNode {
46 public: 46 public:
47 explicit ServiceTreeNode(const string16& title); 47 explicit ServiceTreeNode(const string16& title);
48 virtual ~ServiceTreeNode(); 48 virtual ~ServiceTreeNode();
49 49
50 const string16& ServiceName() const { return service_name_; } 50 const string16& ServiceName() const { return service_name_; }
51 const string16& ServiceUrl() const { return service_url_; } 51 const string16& ServiceUrl() const { return service_url_; }
52 const string16& IconUrl() const { return icon_url_; } 52 const string16& IconUrl() const { return icon_url_; }
53 const string16& Action() const { return action_; } 53 const string16& Action() const { return action_; }
54 const base::ListValue& Types() const { return types_; } 54 const base::ListValue& Types() const { return types_; }
55 bool IsBlocked() const { return blocked_; } 55 bool IsBlocked() const { return blocked_; }
(...skipping 13 matching lines...) Expand all
69 string16 service_url_; 69 string16 service_url_;
70 string16 action_; 70 string16 action_;
71 base::ListValue types_; 71 base::ListValue types_;
72 72
73 // TODO(gbillock): these are kind of a placeholder for exceptions data. 73 // TODO(gbillock): these are kind of a placeholder for exceptions data.
74 bool blocked_; 74 bool blocked_;
75 bool disabled_; 75 bool disabled_;
76 }; 76 };
77 77
78 // UI-backing tree model of the data in the WebIntentsRegistry. 78 // UI-backing tree model of the data in the WebIntentsRegistry.
79 class IntentsModel : public ui::TreeNodeModel<IntentsTreeNode>, 79 class WebIntentsModel : public ui::TreeNodeModel<WebIntentsTreeNode>,
80 public WebIntentsRegistry::Consumer { 80 public WebIntentsRegistry::Consumer {
81 public: 81 public:
82 // Because nodes are fetched in a background thread, they are not 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 83 // present at the time the Model is created. The Model then notifies its
84 // observers for every item added. 84 // observers for every item added.
85 class Observer : public ui::TreeModelObserver { 85 class Observer : public ui::TreeModelObserver {
86 public: 86 public:
87 virtual void TreeModelBeginBatch(IntentsModel* model) {} 87 virtual void TreeModelBeginBatch(WebIntentsModel* model) {}
88 virtual void TreeModelEndBatch(IntentsModel* model) {} 88 virtual void TreeModelEndBatch(WebIntentsModel* model) {}
89 }; 89 };
90 90
91 explicit IntentsModel(WebIntentsRegistry* intents_registry); 91 explicit WebIntentsModel(WebIntentsRegistry* intents_registry);
92 virtual ~IntentsModel(); 92 virtual ~WebIntentsModel();
93 93
94 void AddIntentsTreeObserver(Observer* observer); 94 void AddWebIntentsTreeObserver(Observer* observer);
95 void RemoveIntentsTreeObserver(Observer* observer); 95 void RemoveWebIntentsTreeObserver(Observer* observer);
96 96
97 string16 GetTreeNodeId(IntentsTreeNode* node); 97 string16 GetTreeNodeId(WebIntentsTreeNode* node);
98 IntentsTreeNode* GetTreeNode(std::string path_id); 98 WebIntentsTreeNode* GetTreeNode(std::string path_id);
99 void GetChildNodeList(IntentsTreeNode* parent, int start, int count, 99 void GetChildNodeList(WebIntentsTreeNode* parent, int start, int count,
100 base::ListValue* nodes); 100 base::ListValue* nodes);
101 void GetIntentsTreeNodeDictionary(const IntentsTreeNode& node, 101 void GetWebIntentsTreeNodeDictionary(const WebIntentsTreeNode& node,
102 base::DictionaryValue* dict); 102 base::DictionaryValue* dict);
103 103
104 virtual void OnIntentsQueryDone( 104 virtual void OnIntentsQueryDone(
105 WebIntentsRegistry::QueryID query_id, 105 WebIntentsRegistry::QueryID query_id,
106 const std::vector<WebIntentData>& intents) OVERRIDE; 106 const std::vector<WebIntentData>& intents) OVERRIDE;
107 107
108 private: 108 private:
109 // Loads the data model from the WebIntentsRegistry. 109 // Loads the data model from the WebIntentsRegistry.
110 // TODO(gbillock): need an observer on that to absorb async updates? 110 // TODO(gbillock): need an observer on that to absorb async updates?
111 void LoadModel(); 111 void LoadModel();
112 112
113 // Do batch-specific notifies for updates coming from the LoadModel. 113 // Do batch-specific notifies for updates coming from the LoadModel.
114 void NotifyObserverBeginBatch(); 114 void NotifyObserverBeginBatch();
115 void NotifyObserverEndBatch(); 115 void NotifyObserverEndBatch();
116 116
117 // The backing registry. Weak pointer. 117 // The backing registry. Weak pointer.
118 WebIntentsRegistry* intents_registry_; 118 WebIntentsRegistry* intents_registry_;
119 119
120 // Separate list of observers that'll get batch updates. 120 // Separate list of observers that'll get batch updates.
121 ObserverList<Observer> intents_observer_list_; 121 ObserverList<Observer> intents_observer_list_;
122 122
123 // Batch update nesting level. Incremented to indicate that we're in 123 // Batch update nesting level. Incremented to indicate that we're in
124 // the middle of a batch update. 124 // the middle of a batch update.
125 int batch_update_; 125 int batch_update_;
126 }; 126 };
127 127
128 #endif // CHROME_BROWSER_UI_INTENTS_INTENTS_MODEL_H_ 128 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENTS_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/intents_model_unittest.cc ('k') | chrome/browser/ui/intents/web_intents_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698