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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_controller.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_intent_picker_controller.h" 5 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/browser/favicon/favicon_service.h" 9 #include "chrome/browser/favicon/favicon_service.h"
10 #include "chrome/browser/intents/web_intent_data.h" 10 #include "chrome/browser/intents/web_intent_service_data.h"
11 #include "chrome/browser/intents/web_intents_registry.h" 11 #include "chrome/browser/intents/web_intents_registry.h"
12 #include "chrome/browser/intents/web_intents_registry_factory.h" 12 #include "chrome/browser/intents/web_intents_registry_factory.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/intents/web_intent_picker.h" 14 #include "chrome/browser/ui/intents/web_intent_picker.h"
15 #include "chrome/browser/ui/intents/web_intent_picker_factory.h" 15 #include "chrome/browser/ui/intents/web_intent_picker_factory.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
17 #include "chrome/browser/webdata/web_data_service.h" 17 #include "chrome/browser/webdata/web_data_service.h"
18 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
19 #include "content/common/notification_source.h" 19 #include "content/common/notification_source.h"
20 #include "ui/gfx/codec/png_codec.h" 20 #include "ui/gfx/codec/png_codec.h"
(...skipping 14 matching lines...) Expand all
35 35
36 // A class that asynchronously fetches web intent data from the web intents 36 // A class that asynchronously fetches web intent data from the web intents
37 // registry. 37 // registry.
38 class WebIntentPickerController::WebIntentDataFetcher 38 class WebIntentPickerController::WebIntentDataFetcher
39 : public WebIntentsRegistry::Consumer { 39 : public WebIntentsRegistry::Consumer {
40 public: 40 public:
41 WebIntentDataFetcher(WebIntentPickerController* controller, 41 WebIntentDataFetcher(WebIntentPickerController* controller,
42 WebIntentsRegistry* web_intents_registry); 42 WebIntentsRegistry* web_intents_registry);
43 ~WebIntentDataFetcher(); 43 ~WebIntentDataFetcher();
44 44
45 // Asynchronously fetches WebIntentData for the given |action| |type| pair. 45 // Asynchronously fetches WebIntentServiceData for the given
46 // |action|, |type| pair.
46 void Fetch(const string16& action, const string16& type); 47 void Fetch(const string16& action, const string16& type);
47 48
48 // Cancels the WebDataService request. 49 // Cancels the WebDataService request.
49 void Cancel(); 50 void Cancel();
50 51
51 private: 52 private:
52 // WebIntentsRegistry::Consumer implementation. 53 // WebIntentsRegistry::Consumer implementation.
53 virtual void OnIntentsQueryDone( 54 virtual void OnIntentsQueryDone(
54 WebIntentsRegistry::QueryID, 55 WebIntentsRegistry::QueryID,
55 const std::vector<WebIntentData>& intents) OVERRIDE; 56 const std::vector<WebIntentServiceData>& intents) OVERRIDE;
56 57
57 // A weak pointer to the picker controller. 58 // A weak pointer to the picker controller.
58 WebIntentPickerController* controller_; 59 WebIntentPickerController* controller_;
59 60
60 // A weak pointer to the web intents registry. 61 // A weak pointer to the web intents registry.
61 WebIntentsRegistry* web_intents_registry_; 62 WebIntentsRegistry* web_intents_registry_;
62 63
63 // The ID of the current web intents request. The value will be -1 if 64 // The ID of the current web intents request. The value will be -1 if
64 // there is no request in flight. 65 // there is no request in flight.
65 WebIntentsRegistry::QueryID query_id_; 66 WebIntentsRegistry::QueryID query_id_;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 LOG(INFO) << "Chose index: " << index << " url: " << urls_[index]; 149 LOG(INFO) << "Chose index: " << index << " url: " << urls_[index];
149 ClosePicker(); 150 ClosePicker();
150 } 151 }
151 152
152 void WebIntentPickerController::OnCancelled() { 153 void WebIntentPickerController::OnCancelled() {
153 // TODO(binji) Tell the renderer that the intent was cancelled. 154 // TODO(binji) Tell the renderer that the intent was cancelled.
154 ClosePicker(); 155 ClosePicker();
155 } 156 }
156 157
157 void WebIntentPickerController::OnWebIntentDataAvailable( 158 void WebIntentPickerController::OnWebIntentDataAvailable(
158 const std::vector<WebIntentData>& intent_data) { 159 const std::vector<WebIntentServiceData>& intent_data) {
159 urls_.clear(); 160 urls_.clear();
160 for (size_t i = 0; i < intent_data.size(); ++i) { 161 for (size_t i = 0; i < intent_data.size(); ++i) {
161 urls_.push_back(intent_data[i].service_url); 162 urls_.push_back(intent_data[i].service_url);
162 } 163 }
163 164
164 // Tell the picker to initialize N urls to the default favicon 165 // Tell the picker to initialize N urls to the default favicon
165 picker_->SetServiceURLs(urls_); 166 picker_->SetServiceURLs(urls_);
166 favicon_fetcher_->Fetch(urls_); 167 favicon_fetcher_->Fetch(urls_);
167 pending_async_count_--; 168 pending_async_count_--;
168 } 169 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void WebIntentPickerController::WebIntentDataFetcher::Fetch( 201 void WebIntentPickerController::WebIntentDataFetcher::Fetch(
201 const string16& action, 202 const string16& action,
202 const string16& type) { 203 const string16& type) {
203 DCHECK(query_id_ == -1) << "Fetch already in process."; 204 DCHECK(query_id_ == -1) << "Fetch already in process.";
204 controller_->pending_async_count_++; 205 controller_->pending_async_count_++;
205 query_id_ = web_intents_registry_->GetIntentProviders(action, this); 206 query_id_ = web_intents_registry_->GetIntentProviders(action, this);
206 } 207 }
207 208
208 void WebIntentPickerController::WebIntentDataFetcher::OnIntentsQueryDone( 209 void WebIntentPickerController::WebIntentDataFetcher::OnIntentsQueryDone(
209 WebIntentsRegistry::QueryID, 210 WebIntentsRegistry::QueryID,
210 const std::vector<WebIntentData>& intents) { 211 const std::vector<WebIntentServiceData>& intents) {
211 controller_->OnWebIntentDataAvailable(intents); 212 controller_->OnWebIntentDataAvailable(intents);
212 query_id_ = -1; 213 query_id_ = -1;
213 } 214 }
214 215
215 WebIntentPickerController::FaviconFetcher::FaviconFetcher( 216 WebIntentPickerController::FaviconFetcher::FaviconFetcher(
216 WebIntentPickerController* controller, 217 WebIntentPickerController* controller,
217 FaviconService* favicon_service) 218 FaviconService* favicon_service)
218 : controller_(controller), 219 : controller_(controller),
219 favicon_service_(favicon_service) { 220 favicon_service_(favicon_service) {
220 } 221 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(), 254 if (gfx::PNGCodec::Decode(favicon_data.image_data->front(),
254 favicon_data.image_data->size(), 255 favicon_data.image_data->size(),
255 &icon_bitmap)) { 256 &icon_bitmap)) {
256 controller_->OnFaviconDataAvailable(index, icon_bitmap); 257 controller_->OnFaviconDataAvailable(index, icon_bitmap);
257 return; 258 return;
258 } 259 }
259 } 260 }
260 261
261 controller_->OnFaviconDataUnavailable(index); 262 controller_->OnFaviconDataUnavailable(index);
262 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698