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

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

Issue 7930002: Rename WebIntentData for backend storage to WebIntentServiceData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 #include "chrome/browser/ui/intents/intents_model.h" 5 #include "chrome/browser/ui/intents/intents_model.h"
6 #include "base/string_split.h" 6 #include "base/string_split.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/intents/web_intents_registry.h" 10 #include "chrome/browser/intents/web_intents_registry.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 } 114 }
115 115
116 void IntentsModel::LoadModel() { 116 void IntentsModel::LoadModel() {
117 NotifyObserverBeginBatch(); 117 NotifyObserverBeginBatch();
118 intents_registry_->GetAllIntentProviders(this); 118 intents_registry_->GetAllIntentProviders(this);
119 } 119 }
120 120
121 void IntentsModel::OnIntentsQueryDone( 121 void IntentsModel::OnIntentsQueryDone(
122 WebIntentsRegistry::QueryID query_id, 122 WebIntentsRegistry::QueryID query_id,
123 const std::vector<WebIntentData>& intents) { 123 const std::vector<WebIntentServiceData>& services) {
124 for (size_t i = 0; i < intents.size(); ++i) { 124 for (size_t i = 0; i < services.size(); ++i) {
125 // Eventually do some awesome sorting, grouping, clustering stuff here. 125 // Eventually do some awesome sorting, grouping, clustering stuff here.
126 // For now, just stick it in the model flat. 126 // For now, just stick it in the model flat.
127 IntentsTreeNode* n = new IntentsTreeNode(ASCIIToUTF16( 127 IntentsTreeNode* n = new IntentsTreeNode(ASCIIToUTF16(
128 intents[i].service_url.host())); 128 services[i].service_url.host()));
129 ServiceTreeNode* ns = new ServiceTreeNode(ASCIIToUTF16( 129 ServiceTreeNode* ns = new ServiceTreeNode(ASCIIToUTF16(
130 intents[i].service_url.host())); 130 services[i].service_url.host()));
131 ns->SetServiceName(intents[i].title); 131 ns->SetServiceName(services[i].title);
132 ns->SetServiceUrl(ASCIIToUTF16(intents[i].service_url.spec())); 132 ns->SetServiceUrl(ASCIIToUTF16(services[i].service_url.spec()));
133 GURL icon_url = intents[i].service_url.GetOrigin().Resolve("/favicon.ico"); 133 GURL icon_url = services[i].service_url.GetOrigin().Resolve("/favicon.ico");
134 ns->SetIconUrl(ASCIIToUTF16(icon_url.spec())); 134 ns->SetIconUrl(ASCIIToUTF16(icon_url.spec()));
135 ns->SetAction(intents[i].action); 135 ns->SetAction(services[i].action);
136 ns->AddType(intents[i].type); 136 ns->AddType(services[i].type);
137 // Won't generate a notification. OK for now as the next line will. 137 // Won't generate a notification. OK for now as the next line will.
138 n->Add(ns, 0); 138 n->Add(ns, 0);
139 Add(GetRoot(), n, GetRoot()->child_count()); 139 Add(GetRoot(), n, GetRoot()->child_count());
140 } 140 }
141 141
142 NotifyObserverEndBatch(); 142 NotifyObserverEndBatch();
143 } 143 }
144 144
145 void IntentsModel::NotifyObserverBeginBatch() { 145 void IntentsModel::NotifyObserverBeginBatch() {
146 // Only notify the model once if we're batching in a nested manner. 146 // Only notify the model once if we're batching in a nested manner.
147 if (batch_update_++ == 0) { 147 if (batch_update_++ == 0) {
148 FOR_EACH_OBSERVER(Observer, 148 FOR_EACH_OBSERVER(Observer,
149 intents_observer_list_, 149 intents_observer_list_,
150 TreeModelBeginBatch(this)); 150 TreeModelBeginBatch(this));
151 } 151 }
152 } 152 }
153 153
154 void IntentsModel::NotifyObserverEndBatch() { 154 void IntentsModel::NotifyObserverEndBatch() {
155 // Only notify the observers if this is the outermost call to EndBatch() if 155 // Only notify the observers if this is the outermost call to EndBatch() if
156 // called in a nested manner. 156 // called in a nested manner.
157 if (--batch_update_ == 0) { 157 if (--batch_update_ == 0) {
158 FOR_EACH_OBSERVER(Observer, 158 FOR_EACH_OBSERVER(Observer,
159 intents_observer_list_, 159 intents_observer_list_,
160 TreeModelEndBatch(this)); 160 TreeModelEndBatch(this));
161 } 161 }
162 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698