| OLD | NEW |
| 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 #include "chrome/browser/ui/webui/options/intents_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/intents_settings_handler.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/browsing_data_appcache_helper.h" | 9 #include "chrome/browser/browsing_data_appcache_helper.h" |
| 10 #include "chrome/browser/browsing_data_database_helper.h" | 10 #include "chrome/browser/browsing_data_database_helper.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (node->Type() == IntentsTreeNode::TYPE_ORIGIN) { | 96 if (node->Type() == IntentsTreeNode::TYPE_ORIGIN) { |
| 97 RemoveOrigin(node); | 97 RemoveOrigin(node); |
| 98 } else if (node->Type() == IntentsTreeNode::TYPE_SERVICE) { | 98 } else if (node->Type() == IntentsTreeNode::TYPE_SERVICE) { |
| 99 ServiceTreeNode* snode = static_cast<ServiceTreeNode*>(node); | 99 ServiceTreeNode* snode = static_cast<ServiceTreeNode*>(node); |
| 100 RemoveService(snode); | 100 RemoveService(snode); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 void IntentsSettingsHandler::RemoveOrigin(IntentsTreeNode* node) { | 104 void IntentsSettingsHandler::RemoveOrigin(IntentsTreeNode* node) { |
| 105 // TODO(gbillock): This is a known batch update. Worth optimizing? | 105 // TODO(gbillock): This is a known batch update. Worth optimizing? |
| 106 while (node->child_count() > 0) { | 106 while (!node->empty()) { |
| 107 IntentsTreeNode* cnode = node->GetChild(0); | 107 IntentsTreeNode* cnode = node->GetChild(0); |
| 108 CHECK(cnode->Type() == IntentsTreeNode::TYPE_SERVICE); | 108 CHECK(cnode->Type() == IntentsTreeNode::TYPE_SERVICE); |
| 109 ServiceTreeNode* snode = static_cast<ServiceTreeNode*>(cnode); | 109 ServiceTreeNode* snode = static_cast<ServiceTreeNode*>(cnode); |
| 110 RemoveService(snode); | 110 RemoveService(snode); |
| 111 } | 111 } |
| 112 delete intents_tree_model_->Remove(node->parent(), node); | 112 delete intents_tree_model_->Remove(node->parent(), node); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void IntentsSettingsHandler::RemoveService(ServiceTreeNode* snode) { | 115 void IntentsSettingsHandler::RemoveService(ServiceTreeNode* snode) { |
| 116 WebIntentData provider; | 116 WebIntentData provider; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 children); | 150 children); |
| 151 | 151 |
| 152 ListValue args; | 152 ListValue args; |
| 153 args.Append(parent == intents_tree_model_->GetRoot() ? | 153 args.Append(parent == intents_tree_model_->GetRoot() ? |
| 154 Value::CreateNullValue() : | 154 Value::CreateNullValue() : |
| 155 Value::CreateStringValue(intents_tree_model_->GetTreeNodeId(parent))); | 155 Value::CreateStringValue(intents_tree_model_->GetTreeNodeId(parent))); |
| 156 args.Append(children); | 156 args.Append(children); |
| 157 | 157 |
| 158 web_ui_->CallJavascriptFunction("IntentsView.loadChildren", args); | 158 web_ui_->CallJavascriptFunction("IntentsView.loadChildren", args); |
| 159 } | 159 } |
| OLD | NEW |