| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 tab_util::GetSiteInstanceForNewTab( | 288 tab_util::GetSiteInstanceForNewTab( |
| 289 tab_contents_->profile(), url), | 289 tab_contents_->profile(), url), |
| 290 MSG_ROUTING_NONE, NULL, NULL); | 290 MSG_ROUTING_NONE, NULL, NULL); |
| 291 | 291 |
| 292 intents_dispatcher_->DispatchIntent(contents->web_contents()); | 292 intents_dispatcher_->DispatchIntent(contents->web_contents()); |
| 293 service_tab_ = contents->web_contents(); | 293 service_tab_ = contents->web_contents(); |
| 294 | 294 |
| 295 // This call performs all the tab strip manipulation, notifications, etc. | 295 // This call performs all the tab strip manipulation, notifications, etc. |
| 296 // Since we're passing in a target_contents, it assumes that we will | 296 // Since we're passing in a target_contents, it assumes that we will |
| 297 // navigate the page ourselves, though. | 297 // navigate the page ourselves, though. |
| 298 browser::NavigateParams params(browser, | 298 chrome::NavigateParams params(browser, url, |
| 299 url, | 299 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 300 content::PAGE_TRANSITION_AUTO_BOOKMARK); | |
| 301 params.target_contents = contents; | 300 params.target_contents = contents; |
| 302 params.disposition = NEW_FOREGROUND_TAB; | 301 params.disposition = NEW_FOREGROUND_TAB; |
| 303 params.profile = tab_contents_->profile(); | 302 params.profile = tab_contents_->profile(); |
| 304 browser::Navigate(¶ms); | 303 chrome::Navigate(¶ms); |
| 305 | 304 |
| 306 service_tab_->GetController().LoadURL( | 305 service_tab_->GetController().LoadURL( |
| 307 url, content::Referrer(), | 306 url, content::Referrer(), |
| 308 content::PAGE_TRANSITION_AUTO_BOOKMARK, std::string()); | 307 content::PAGE_TRANSITION_AUTO_BOOKMARK, std::string()); |
| 309 | 308 |
| 310 ClosePicker(); | 309 ClosePicker(); |
| 311 break; | 310 break; |
| 312 } | 311 } |
| 313 | 312 |
| 314 default: | 313 default: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 336 | 335 |
| 337 pending_async_count_++; | 336 pending_async_count_++; |
| 338 installer->Start(); | 337 installer->Start(); |
| 339 } | 338 } |
| 340 | 339 |
| 341 void WebIntentPickerController::OnExtensionLinkClicked(const std::string& id) { | 340 void WebIntentPickerController::OnExtensionLinkClicked(const std::string& id) { |
| 342 // Navigate from source tab. | 341 // Navigate from source tab. |
| 343 Browser* browser = | 342 Browser* browser = |
| 344 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); | 343 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); |
| 345 GURL extension_url(extension_urls::GetWebstoreItemDetailURLPrefix() + id); | 344 GURL extension_url(extension_urls::GetWebstoreItemDetailURLPrefix() + id); |
| 346 browser::NavigateParams params(browser, extension_url, | 345 chrome::NavigateParams params(browser, extension_url, |
| 347 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 346 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 348 params.disposition = NEW_FOREGROUND_TAB; | 347 params.disposition = NEW_FOREGROUND_TAB; |
| 349 browser::Navigate(¶ms); | 348 chrome::Navigate(¶ms); |
| 350 } | 349 } |
| 351 | 350 |
| 352 void WebIntentPickerController::OnSuggestionsLinkClicked() { | 351 void WebIntentPickerController::OnSuggestionsLinkClicked() { |
| 353 // Navigate from source tab. | 352 // Navigate from source tab. |
| 354 Browser* browser = | 353 Browser* browser = |
| 355 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); | 354 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); |
| 356 GURL query_url = extension_urls::GetWebstoreIntentQueryURL( | 355 GURL query_url = extension_urls::GetWebstoreIntentQueryURL( |
| 357 UTF16ToUTF8(picker_model_->action()), | 356 UTF16ToUTF8(picker_model_->action()), |
| 358 UTF16ToUTF8(picker_model_->mimetype())); | 357 UTF16ToUTF8(picker_model_->mimetype())); |
| 359 browser::NavigateParams params(browser, query_url, | 358 chrome::NavigateParams params(browser, query_url, |
| 360 content::PAGE_TRANSITION_AUTO_BOOKMARK); | 359 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 361 params.disposition = NEW_FOREGROUND_TAB; | 360 params.disposition = NEW_FOREGROUND_TAB; |
| 362 browser::Navigate(¶ms); | 361 chrome::Navigate(¶ms); |
| 363 } | 362 } |
| 364 | 363 |
| 365 void WebIntentPickerController::OnPickerClosed() { | 364 void WebIntentPickerController::OnPickerClosed() { |
| 366 if (!intents_dispatcher_) | 365 if (!intents_dispatcher_) |
| 367 return; | 366 return; |
| 368 | 367 |
| 369 if (service_tab_) { | 368 if (service_tab_) { |
| 370 intents_dispatcher_->SendReplyMessage( | 369 intents_dispatcher_->SendReplyMessage( |
| 371 webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED, string16()); | 370 webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED, string16()); |
| 372 } else { | 371 } else { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 // If picker is non-NULL, it was set by a test. | 708 // If picker is non-NULL, it was set by a test. |
| 710 if (picker_ == NULL) | 709 if (picker_ == NULL) |
| 711 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get()); | 710 picker_ = WebIntentPicker::Create(tab_contents_, this, picker_model_.get()); |
| 712 picker_shown_ = true; | 711 picker_shown_ = true; |
| 713 } | 712 } |
| 714 | 713 |
| 715 void WebIntentPickerController::ClosePicker() { | 714 void WebIntentPickerController::ClosePicker() { |
| 716 if (picker_) | 715 if (picker_) |
| 717 picker_->Close(); | 716 picker_->Close(); |
| 718 } | 717 } |
| OLD | NEW |