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

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

Issue 10969016: web intents. Fix callbacks to restore tab management on service exit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve comments Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 uma_reporter_(new UMAReporter()), 192 uma_reporter_(new UMAReporter()),
193 pending_async_count_(0), 193 pending_async_count_(0),
194 pending_registry_calls_count_(0), 194 pending_registry_calls_count_(0),
195 pending_cws_request_(false), 195 pending_cws_request_(false),
196 picker_shown_(false), 196 picker_shown_(false),
197 window_disposition_source_(NULL), 197 window_disposition_source_(NULL),
198 source_intents_dispatcher_(NULL), 198 source_intents_dispatcher_(NULL),
199 intents_dispatcher_(NULL), 199 intents_dispatcher_(NULL),
200 service_tab_(NULL), 200 service_tab_(NULL),
201 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 201 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
202 ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)) { 202 ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)),
203 ALLOW_THIS_IN_INITIALIZER_LIST(dispatcher_factory_(this)) {
203 content::NavigationController* controller = 204 content::NavigationController* controller =
204 &tab_contents->web_contents()->GetController(); 205 &tab_contents->web_contents()->GetController();
205 registrar_.Add(this, content::NOTIFICATION_LOAD_START, 206 registrar_.Add(this, content::NOTIFICATION_LOAD_START,
206 content::Source<content::NavigationController>(controller)); 207 content::Source<content::NavigationController>(controller));
207 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING, 208 registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING,
208 content::Source<content::NavigationController>(controller)); 209 content::Source<content::NavigationController>(controller));
209 #if defined(TOOLKIT_VIEWS) 210 #if defined(TOOLKIT_VIEWS)
210 cancelled_ = true; 211 cancelled_ = true;
211 #endif 212 #endif
212 } 213 }
213 214
214 WebIntentPickerController::~WebIntentPickerController() { 215 WebIntentPickerController::~WebIntentPickerController() {
215 } 216 }
216 217
217 // TODO(gbillock): combine this with ShowDialog. 218 // TODO(gbillock): combine this with ShowDialog.
218 void WebIntentPickerController::SetIntentsDispatcher( 219 void WebIntentPickerController::SetIntentsDispatcher(
219 content::WebIntentsDispatcher* intents_dispatcher) { 220 content::WebIntentsDispatcher* intents_dispatcher) {
220 intents_dispatcher_ = intents_dispatcher; 221 intents_dispatcher_ = intents_dispatcher;
222 // TODO(gbillock): This is to account for multiple dispatches in the same tab.
223 // That is currently not a well-handled case, and this is a band-aid.
224 dispatcher_factory_.InvalidateWeakPtrs();
groby-ooo-7-16 2012/09/21 02:25:21 Don't you want to invalidate _before_ you change m
Greg Billock 2012/09/21 05:10:09 Good point. I'll do it. On 2012/09/21 02:25:21, g
221 intents_dispatcher_->RegisterReplyNotification( 225 intents_dispatcher_->RegisterReplyNotification(
222 base::Bind(&WebIntentPickerController::OnSendReturnMessage, 226 base::Bind(&WebIntentPickerController::OnSendReturnMessage,
223 weak_ptr_factory_.GetWeakPtr())); 227 dispatcher_factory_.GetWeakPtr()));
224 228
225 // Initialize the reporting bucket. 229 // Initialize the reporting bucket.
226 const webkit_glue::WebIntentData& intent = intents_dispatcher_->GetIntent(); 230 const webkit_glue::WebIntentData& intent = intents_dispatcher_->GetIntent();
227 uma_bucket_ = web_intents::ToUMABucket(intent.action, intent.type); 231 uma_bucket_ = web_intents::ToUMABucket(intent.action, intent.type);
228 } 232 }
229 233
230 // TODO(smckay): rename this "StartActivity". 234 // TODO(smckay): rename this "StartActivity".
231 void WebIntentPickerController::ShowDialog(const string16& action, 235 void WebIntentPickerController::ShowDialog(const string16& action,
232 const string16& type) { 236 const string16& type) {
233 ShowDialog(false); 237 ShowDialog(false);
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 web_intents::RecordPickerShow( 1052 web_intents::RecordPickerShow(
1049 uma_bucket_, picker_model_->GetInstalledServiceCount()); 1053 uma_bucket_, picker_model_->GetInstalledServiceCount());
1050 picker_shown_ = true; 1054 picker_shown_ = true;
1051 } 1055 }
1052 1056
1053 void WebIntentPickerController::ClosePicker() { 1057 void WebIntentPickerController::ClosePicker() {
1054 SetDialogState(kPickerHidden); 1058 SetDialogState(kPickerHidden);
1055 if (picker_) 1059 if (picker_)
1056 picker_->Close(); 1060 picker_->Close();
1057 } 1061 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698