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

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

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

Powered by Google App Engine
This is Rietveld 408576698