| Index: chrome/browser/ui/intents/web_intents_model.cc
|
| diff --git a/chrome/browser/ui/intents/intents_model.cc b/chrome/browser/ui/intents/web_intents_model.cc
|
| similarity index 65%
|
| rename from chrome/browser/ui/intents/intents_model.cc
|
| rename to chrome/browser/ui/intents/web_intents_model.cc
|
| index 4aa09112f47be05450f76aa9a024f3a0370523c3..da74bf31a309145e1339f760590ff1bee375afdb 100644
|
| --- a/chrome/browser/ui/intents/intents_model.cc
|
| +++ b/chrome/browser/ui/intents/web_intents_model.cc
|
| @@ -2,53 +2,53 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/ui/intents/intents_model.h"
|
| +#include "chrome/browser/ui/intents/web_intents_model.h"
|
| #include "base/string_split.h"
|
| #include "base/string_util.h"
|
| #include "base/stringprintf.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/intents/web_intents_registry.h"
|
|
|
| -IntentsTreeNode::IntentsTreeNode()
|
| - : ui::TreeNode<IntentsTreeNode>(string16()),
|
| +WebIntentsTreeNode::WebIntentsTreeNode()
|
| + : ui::TreeNode<WebIntentsTreeNode>(string16()),
|
| type_(TYPE_ROOT) {}
|
|
|
| -IntentsTreeNode::IntentsTreeNode(const string16& title)
|
| - : ui::TreeNode<IntentsTreeNode>(title),
|
| +WebIntentsTreeNode::WebIntentsTreeNode(const string16& title)
|
| + : ui::TreeNode<WebIntentsTreeNode>(title),
|
| type_(TYPE_ORIGIN) {}
|
|
|
| -IntentsTreeNode::~IntentsTreeNode() {}
|
| +WebIntentsTreeNode::~WebIntentsTreeNode() {}
|
|
|
| ServiceTreeNode::ServiceTreeNode(const string16& title)
|
| - : IntentsTreeNode(title, IntentsTreeNode::TYPE_SERVICE),
|
| + : WebIntentsTreeNode(title, WebIntentsTreeNode::TYPE_SERVICE),
|
| blocked_(false),
|
| disabled_(false) {}
|
|
|
| ServiceTreeNode::~ServiceTreeNode() {}
|
|
|
| -IntentsModel::IntentsModel(WebIntentsRegistry* intents_registry)
|
| - : ui::TreeNodeModel<IntentsTreeNode>(new IntentsTreeNode()),
|
| +WebIntentsModel::WebIntentsModel(WebIntentsRegistry* intents_registry)
|
| + : ui::TreeNodeModel<WebIntentsTreeNode>(new WebIntentsTreeNode()),
|
| intents_registry_(intents_registry),
|
| batch_update_(0) {
|
| LoadModel();
|
| }
|
|
|
| -IntentsModel::~IntentsModel() {}
|
| +WebIntentsModel::~WebIntentsModel() {}
|
|
|
| -void IntentsModel::AddIntentsTreeObserver(Observer* observer) {
|
| +void WebIntentsModel::AddWebIntentsTreeObserver(Observer* observer) {
|
| intents_observer_list_.AddObserver(observer);
|
| // Call super so that TreeNodeModel can notify, too.
|
| - ui::TreeNodeModel<IntentsTreeNode>::AddObserver(observer);
|
| + ui::TreeNodeModel<WebIntentsTreeNode>::AddObserver(observer);
|
| }
|
|
|
| -void IntentsModel::RemoveIntentsTreeObserver(Observer* observer) {
|
| +void WebIntentsModel::RemoveWebIntentsTreeObserver(Observer* observer) {
|
| intents_observer_list_.RemoveObserver(observer);
|
| // Call super so that TreeNodeModel doesn't have dead pointers.
|
| - ui::TreeNodeModel<IntentsTreeNode>::RemoveObserver(observer);
|
| + ui::TreeNodeModel<WebIntentsTreeNode>::RemoveObserver(observer);
|
| }
|
|
|
| -string16 IntentsModel::GetTreeNodeId(IntentsTreeNode* node) {
|
| - if (node->Type() == IntentsTreeNode::TYPE_ORIGIN)
|
| +string16 WebIntentsModel::GetTreeNodeId(WebIntentsTreeNode* node) {
|
| + if (node->Type() == WebIntentsTreeNode::TYPE_ORIGIN)
|
| return node->GetTitle();
|
|
|
| // TODO(gbillock): handle TYPE_SERVICE when/if we ever want to do
|
| @@ -57,7 +57,7 @@ string16 IntentsModel::GetTreeNodeId(IntentsTreeNode* node) {
|
| return string16();
|
| }
|
|
|
| -IntentsTreeNode* IntentsModel::GetTreeNode(std::string path_id) {
|
| +WebIntentsTreeNode* WebIntentsModel::GetTreeNode(std::string path_id) {
|
| if (path_id.empty())
|
| return GetRoot();
|
|
|
| @@ -65,7 +65,7 @@ IntentsTreeNode* IntentsModel::GetTreeNode(std::string path_id) {
|
| base::SplitString(path_id, ',', &node_ids);
|
|
|
| for (int i = 0; i < GetRoot()->child_count(); ++i) {
|
| - IntentsTreeNode* node = GetRoot()->GetChild(i);
|
| + WebIntentsTreeNode* node = GetRoot()->GetChild(i);
|
| if (UTF16ToUTF8(node->GetTitle()) == node_ids[0]) {
|
| if (node_ids.size() == 1)
|
| return node;
|
| @@ -76,30 +76,31 @@ IntentsTreeNode* IntentsModel::GetTreeNode(std::string path_id) {
|
| return NULL;
|
| }
|
|
|
| -void IntentsModel::GetChildNodeList(IntentsTreeNode* parent,
|
| - int start, int count,
|
| - base::ListValue* nodes) {
|
| +void WebIntentsModel::GetChildNodeList(WebIntentsTreeNode* parent,
|
| + int start, int count,
|
| + base::ListValue* nodes) {
|
| for (int i = 0; i < count; ++i) {
|
| base::DictionaryValue* dict = new base::DictionaryValue;
|
| - IntentsTreeNode* child = parent->GetChild(start + i);
|
| - GetIntentsTreeNodeDictionary(*child, dict);
|
| + WebIntentsTreeNode* child = parent->GetChild(start + i);
|
| + GetWebIntentsTreeNodeDictionary(*child, dict);
|
| nodes->Append(dict);
|
| }
|
| }
|
|
|
| -void IntentsModel::GetIntentsTreeNodeDictionary(const IntentsTreeNode& node,
|
| - base::DictionaryValue* dict) {
|
| - if (node.Type() == IntentsTreeNode::TYPE_ROOT) {
|
| +void WebIntentsModel::GetWebIntentsTreeNodeDictionary(
|
| + const WebIntentsTreeNode& node,
|
| + base::DictionaryValue* dict) {
|
| + if (node.Type() == WebIntentsTreeNode::TYPE_ROOT) {
|
| return;
|
| }
|
|
|
| - if (node.Type() == IntentsTreeNode::TYPE_ORIGIN) {
|
| + if (node.Type() == WebIntentsTreeNode::TYPE_ORIGIN) {
|
| dict->SetString("site", node.GetTitle());
|
| dict->SetBoolean("hasChildren", !node.empty());
|
| return;
|
| }
|
|
|
| - if (node.Type() == IntentsTreeNode::TYPE_SERVICE) {
|
| + if (node.Type() == WebIntentsTreeNode::TYPE_SERVICE) {
|
| const ServiceTreeNode* snode = static_cast<const ServiceTreeNode*>(&node);
|
| dict->SetString("site", snode->GetTitle());
|
| dict->SetString("name", snode->ServiceName());
|
| @@ -113,18 +114,18 @@ void IntentsModel::GetIntentsTreeNodeDictionary(const IntentsTreeNode& node,
|
| }
|
| }
|
|
|
| -void IntentsModel::LoadModel() {
|
| +void WebIntentsModel::LoadModel() {
|
| NotifyObserverBeginBatch();
|
| intents_registry_->GetAllIntentProviders(this);
|
| }
|
|
|
| -void IntentsModel::OnIntentsQueryDone(
|
| +void WebIntentsModel::OnIntentsQueryDone(
|
| WebIntentsRegistry::QueryID query_id,
|
| const std::vector<WebIntentData>& intents) {
|
| for (size_t i = 0; i < intents.size(); ++i) {
|
| // Eventually do some awesome sorting, grouping, clustering stuff here.
|
| // For now, just stick it in the model flat.
|
| - IntentsTreeNode* n = new IntentsTreeNode(ASCIIToUTF16(
|
| + WebIntentsTreeNode* n = new WebIntentsTreeNode(ASCIIToUTF16(
|
| intents[i].service_url.host()));
|
| ServiceTreeNode* ns = new ServiceTreeNode(ASCIIToUTF16(
|
| intents[i].service_url.host()));
|
| @@ -142,7 +143,7 @@ void IntentsModel::OnIntentsQueryDone(
|
| NotifyObserverEndBatch();
|
| }
|
|
|
| -void IntentsModel::NotifyObserverBeginBatch() {
|
| +void WebIntentsModel::NotifyObserverBeginBatch() {
|
| // Only notify the model once if we're batching in a nested manner.
|
| if (batch_update_++ == 0) {
|
| FOR_EACH_OBSERVER(Observer,
|
| @@ -151,7 +152,7 @@ void IntentsModel::NotifyObserverBeginBatch() {
|
| }
|
| }
|
|
|
| -void IntentsModel::NotifyObserverEndBatch() {
|
| +void WebIntentsModel::NotifyObserverEndBatch() {
|
| // Only notify the observers if this is the outermost call to EndBatch() if
|
| // called in a nested manner.
|
| if (--batch_update_ == 0) {
|
|
|