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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 switch (disposition) { | 299 switch (disposition) { |
300 case WebIntentPickerModel::DISPOSITION_INLINE: | 300 case WebIntentPickerModel::DISPOSITION_INLINE: |
301 // Set the model to inline disposition. It will notify the picker which | 301 // Set the model to inline disposition. It will notify the picker which |
302 // will respond (via OnInlineDispositionWebContentsCreated) with the | 302 // will respond (via OnInlineDispositionWebContentsCreated) with the |
303 // WebContents to dispatch the intent to. | 303 // WebContents to dispatch the intent to. |
304 picker_model_->SetInlineDisposition(url); | 304 picker_model_->SetInlineDisposition(url); |
305 break; | 305 break; |
306 | 306 |
307 case WebIntentPickerModel::DISPOSITION_WINDOW: { | 307 case WebIntentPickerModel::DISPOSITION_WINDOW: { |
308 Browser* browser = browser::FindBrowserWithWebContents( | 308 int index = TabStripModel::kNoTab; |
309 tab_contents_->web_contents()); | 309 Browser* browser = browser::FindBrowserForController( |
| 310 &tab_contents_->web_contents()->GetController(), &index); |
310 TabContents* contents = chrome::TabContentsFactory( | 311 TabContents* contents = chrome::TabContentsFactory( |
311 tab_contents_->profile(), | 312 tab_contents_->profile(), |
312 tab_util::GetSiteInstanceForNewTab( | 313 tab_util::GetSiteInstanceForNewTab( |
313 tab_contents_->profile(), url), | 314 tab_contents_->profile(), url), |
314 MSG_ROUTING_NONE, NULL, NULL); | 315 MSG_ROUTING_NONE, NULL, NULL); |
315 | 316 |
316 // Let the controller for the target TabContents know that it is hosting a | 317 // Let the controller for the target TabContents know that it is hosting a |
317 // web intents service. | 318 // web intents service. |
318 contents->web_intent_picker_controller()->SetWindowDispositionSource( | 319 contents->web_intent_picker_controller()->SetWindowDispositionSource( |
319 tab_contents_->web_contents(), intents_dispatcher_); | 320 tab_contents_->web_contents(), intents_dispatcher_); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 picker_->OnExtensionInstallFailure(id); | 461 picker_->OnExtensionInstallFailure(id); |
461 AsyncOperationFinished(); | 462 AsyncOperationFinished(); |
462 } | 463 } |
463 | 464 |
464 void WebIntentPickerController::OnSendReturnMessage( | 465 void WebIntentPickerController::OnSendReturnMessage( |
465 webkit_glue::WebIntentReplyType reply_type) { | 466 webkit_glue::WebIntentReplyType reply_type) { |
466 ClosePicker(); | 467 ClosePicker(); |
467 | 468 |
468 if (service_tab_ && | 469 if (service_tab_ && |
469 reply_type != webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED) { | 470 reply_type != webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED) { |
470 Browser* browser = browser::FindBrowserWithWebContents(service_tab_); | 471 int index = TabStripModel::kNoTab; |
| 472 Browser* browser = browser::FindBrowserForController( |
| 473 &service_tab_->GetController(), &index); |
471 if (browser) { | 474 if (browser) { |
472 int index = browser->tab_strip_model()->GetIndexOfWebContents( | |
473 service_tab_); | |
474 browser->tab_strip_model()->CloseTabContentsAt( | 475 browser->tab_strip_model()->CloseTabContentsAt( |
475 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | 476 index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); |
476 | 477 |
477 // Activate source tab. | 478 // Activate source tab. |
478 Browser* source_browser = | 479 Browser* source_browser = |
479 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); | 480 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); |
480 if (source_browser) { | 481 if (source_browser) { |
481 int source_index = source_browser->tab_strip_model()-> | 482 int source_index = source_browser->tab_strip_model()-> |
482 GetIndexOfTabContents(tab_contents_); | 483 GetIndexOfTabContents(tab_contents_); |
483 chrome::ActivateTabAt(source_browser, source_index, false); | 484 chrome::ActivateTabAt(source_browser, source_index, false); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 // If picker is non-NULL, it was set by a test. | 767 // If picker is non-NULL, it was set by a test. |
767 if (picker_ == NULL) | 768 if (picker_ == NULL) |
768 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get()); | 769 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get()); |
769 picker_shown_ = true; | 770 picker_shown_ = true; |
770 } | 771 } |
771 | 772 |
772 void WebIntentPickerController::ClosePicker() { | 773 void WebIntentPickerController::ClosePicker() { |
773 if (picker_) | 774 if (picker_) |
774 picker_->Close(); | 775 picker_->Close(); |
775 } | 776 } |
OLD | NEW |