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

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

Issue 11071005: Add native file picker impl using SelectFileDialog. (Closed) Base URL: http://git.chromium.org/chromium/src.git@filePicker
Patch Set: Don't use "DeleteService" as a method name since Windows munges it at compile time. Created 8 years, 2 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 virtual void WebContentsDestroyed(content::WebContents* web_contents) { 129 virtual void WebContentsDestroyed(content::WebContents* web_contents) {
130 if (controller_) 130 if (controller_)
131 controller_->SourceWebContentsDestroyed(web_contents); 131 controller_->SourceWebContentsDestroyed(web_contents);
132 delete this; 132 delete this;
133 } 133 }
134 134
135 private: 135 private:
136 base::WeakPtr<WebIntentPickerController> controller_; 136 base::WeakPtr<WebIntentPickerController> controller_;
137 }; 137 };
138 138
139 // Deletes |service|, presumably called from a dispatcher callback.
140 void DeleteIntentService(
141 web_intents::IntentServiceHost* service,
142 webkit_glue::WebIntentReplyType type) {
143 delete service;
144 }
145
139 } // namespace 146 } // namespace
140 147
141 // UMAReporter handles reporting Web Intents events to UMA. 148 // UMAReporter handles reporting Web Intents events to UMA.
142 class WebIntentPickerController::UMAReporter { 149 class WebIntentPickerController::UMAReporter {
143 public: 150 public:
144 151
145 // Resets the service active duration timer to "now". 152 // Resets the service active duration timer to "now".
146 void ResetServiceActiveTimer(); 153 void ResetServiceActiveTimer();
147 154
148 // Records the duration of time spent using the service. Uses |reply_type| 155 // Records the duration of time spent using the service. Uses |reply_type|
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 363
357 // TODO(smckay): This entire method shold basically be pulled out 364 // TODO(smckay): This entire method shold basically be pulled out
358 // into a separate class dedicated to the execution of intents. 365 // into a separate class dedicated to the execution of intents.
359 // The tricky part is with the "INLINE" disposition where we 366 // The tricky part is with the "INLINE" disposition where we
360 // want to (re)use the picker to handle the intent. A bit of 367 // want to (re)use the picker to handle the intent. A bit of
361 // artful composition + lazy instantiation should make that possible. 368 // artful composition + lazy instantiation should make that possible.
362 switch (disposition) { 369 switch (disposition) {
363 case webkit_glue::WebIntentServiceData::DISPOSITION_NATIVE: { 370 case webkit_glue::WebIntentServiceData::DISPOSITION_NATIVE: {
364 web_intents::IntentServiceHost* service = 371 web_intents::IntentServiceHost* service =
365 native_services_->CreateServiceInstance( 372 native_services_->CreateServiceInstance(
366 url, intents_dispatcher_->GetIntent()); 373 url, intents_dispatcher_->GetIntent(), web_contents_);
367 DCHECK(service); 374 DCHECK(service);
375
376 intents_dispatcher_->RegisterReplyNotification(
377 base::Bind(&DeleteIntentService, base::Unretained(service)));
378
368 service->HandleIntent(intents_dispatcher_); 379 service->HandleIntent(intents_dispatcher_);
369 break; 380 break;
370 } 381 }
371 382
372 case webkit_glue::WebIntentServiceData::DISPOSITION_INLINE: { 383 case webkit_glue::WebIntentServiceData::DISPOSITION_INLINE: {
373 // Set the model to inline disposition. It will notify the picker which 384 // Set the model to inline disposition. It will notify the picker which
374 // will respond (via OnInlineDispositionWebContentsCreated) with the 385 // will respond (via OnInlineDispositionWebContentsCreated) with the
375 // WebContents to dispatch the intent to. 386 // WebContents to dispatch the intent to.
376 picker_model_->SetInlineDisposition(url); 387 picker_model_->SetInlineDisposition(url);
377 break; 388 break;
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 content::DownloadManager* download_manager = 1133 content::DownloadManager* download_manager =
1123 content::BrowserContext::GetDownloadManager(profile); 1134 content::BrowserContext::GetDownloadManager(profile);
1124 if (!download_manager) 1135 if (!download_manager)
1125 return; 1136 return;
1126 content::DownloadItem* item = 1137 content::DownloadItem* item =
1127 download_manager->GetDownload(download_id_.local()); 1138 download_manager->GetDownload(download_id_.local());
1128 if (item) 1139 if (item)
1129 item->Cancel(true); 1140 item->Cancel(true);
1130 download_id_ = content::DownloadId(); 1141 download_id_ = content::DownloadId();
1131 } 1142 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/native_file_picker_service.cc ('k') | chrome/browser/ui/views/web_intents_native_services.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698