OLD | NEW |
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 if (tab_contents_->profile()->IsOffTheRecord()) { | 212 if (tab_contents_->profile()->IsOffTheRecord()) { |
213 if (intents_dispatcher_) { | 213 if (intents_dispatcher_) { |
214 intents_dispatcher_->SendReplyMessage( | 214 intents_dispatcher_->SendReplyMessage( |
215 webkit_glue::WEB_INTENT_REPLY_FAILURE, string16()); | 215 webkit_glue::WEB_INTENT_REPLY_FAILURE, string16()); |
216 } | 216 } |
217 return; | 217 return; |
218 } | 218 } |
219 | 219 |
220 picker_model_->Clear(); | 220 picker_model_->Clear(); |
221 picker_model_->set_action(action); | 221 picker_model_->set_action(action); |
222 picker_model_->set_mimetype(type); | 222 picker_model_->set_type(type); |
223 | 223 |
224 // If the intent is explicit, skip showing the picker. | 224 // If the intent is explicit, skip showing the picker. |
225 if (intents_dispatcher_) { | 225 if (intents_dispatcher_) { |
226 const GURL& service = intents_dispatcher_->GetIntent().service; | 226 const GURL& service = intents_dispatcher_->GetIntent().service; |
227 if (service.is_valid()) { | 227 if (service.is_valid()) { |
228 // TODO(gbillock): When we can parse pages for the intent tag, | 228 // TODO(gbillock): When we can parse pages for the intent tag, |
229 // take out this requirement that explicit intents dispatch to | 229 // take out this requirement that explicit intents dispatch to |
230 // extension urls. | 230 // extension urls. |
231 if (!service.SchemeIs(chrome::kExtensionScheme)) { | 231 if (!service.SchemeIs(chrome::kExtensionScheme)) { |
232 intents_dispatcher_->SendReplyMessage( | 232 intents_dispatcher_->SendReplyMessage( |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 params.disposition = NEW_FOREGROUND_TAB; | 375 params.disposition = NEW_FOREGROUND_TAB; |
376 chrome::Navigate(¶ms); | 376 chrome::Navigate(¶ms); |
377 } | 377 } |
378 | 378 |
379 void WebIntentPickerController::OnSuggestionsLinkClicked() { | 379 void WebIntentPickerController::OnSuggestionsLinkClicked() { |
380 // Navigate from source tab. | 380 // Navigate from source tab. |
381 Browser* browser = | 381 Browser* browser = |
382 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); | 382 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); |
383 GURL query_url = extension_urls::GetWebstoreIntentQueryURL( | 383 GURL query_url = extension_urls::GetWebstoreIntentQueryURL( |
384 UTF16ToUTF8(picker_model_->action()), | 384 UTF16ToUTF8(picker_model_->action()), |
385 UTF16ToUTF8(picker_model_->mimetype())); | 385 UTF16ToUTF8(picker_model_->type())); |
386 chrome::NavigateParams params(browser, query_url, | 386 chrome::NavigateParams params(browser, query_url, |
387 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 387 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
388 params.disposition = NEW_FOREGROUND_TAB; | 388 params.disposition = NEW_FOREGROUND_TAB; |
389 chrome::Navigate(¶ms); | 389 chrome::Navigate(¶ms); |
390 } | 390 } |
391 | 391 |
392 void WebIntentPickerController::OnPickerClosed() { | 392 void WebIntentPickerController::OnPickerClosed() { |
393 if (!intents_dispatcher_) | 393 if (!intents_dispatcher_) |
394 return; | 394 return; |
395 | 395 |
(...skipping 19 matching lines...) Expand all Loading... |
415 picker_shown_ = false; | 415 picker_shown_ = false; |
416 picker_ = NULL; | 416 picker_ = NULL; |
417 } | 417 } |
418 | 418 |
419 void WebIntentPickerController::OnExtensionInstallSuccess( | 419 void WebIntentPickerController::OnExtensionInstallSuccess( |
420 const std::string& id) { | 420 const std::string& id) { |
421 picker_->OnExtensionInstallSuccess(id); | 421 picker_->OnExtensionInstallSuccess(id); |
422 pending_async_count_++; | 422 pending_async_count_++; |
423 GetWebIntentsRegistry(tab_contents_)->GetIntentServicesForExtensionFilter( | 423 GetWebIntentsRegistry(tab_contents_)->GetIntentServicesForExtensionFilter( |
424 picker_model_->action(), | 424 picker_model_->action(), |
425 picker_model_->mimetype(), | 425 picker_model_->type(), |
426 id, | 426 id, |
427 base::Bind( | 427 base::Bind( |
428 &WebIntentPickerController::OnExtensionInstallServiceAvailable, | 428 &WebIntentPickerController::OnExtensionInstallServiceAvailable, |
429 weak_ptr_factory_.GetWeakPtr())); | 429 weak_ptr_factory_.GetWeakPtr())); |
430 AsyncOperationFinished(); | 430 AsyncOperationFinished(); |
431 } | 431 } |
432 | 432 |
433 void WebIntentPickerController::OnExtensionInstallFailure( | 433 void WebIntentPickerController::OnExtensionInstallFailure( |
434 const std::string& id, | 434 const std::string& id, |
435 const std::string& error) { | 435 const std::string& error) { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 // If picker is non-NULL, it was set by a test. | 768 // If picker is non-NULL, it was set by a test. |
769 if (picker_ == NULL) | 769 if (picker_ == NULL) |
770 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get()); | 770 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get()); |
771 picker_shown_ = true; | 771 picker_shown_ = true; |
772 } | 772 } |
773 | 773 |
774 void WebIntentPickerController::ClosePicker() { | 774 void WebIntentPickerController::ClosePicker() { |
775 if (picker_) | 775 if (picker_) |
776 picker_->Close(); | 776 picker_->Close(); |
777 } | 777 } |
OLD | NEW |