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/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 462 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
463 } | 463 } |
464 | 464 |
465 bool AutomationProvider::Send(IPC::Message* msg) { | 465 bool AutomationProvider::Send(IPC::Message* msg) { |
466 DCHECK(channel_.get()); | 466 DCHECK(channel_.get()); |
467 return channel_->Send(msg); | 467 return channel_->Send(msg); |
468 } | 468 } |
469 | 469 |
470 Browser* AutomationProvider::FindAndActivateTab( | 470 Browser* AutomationProvider::FindAndActivateTab( |
471 NavigationController* controller) { | 471 NavigationController* controller) { |
472 content::WebContentsDelegate* d = controller->GetWebContents()->GetDelegate(); | 472 int tab_index; |
473 if (d) | 473 Browser* browser = browser::FindBrowserForController(controller, &tab_index); |
474 d->ActivateContents(controller->GetWebContents()); | 474 if (browser) |
475 return browser::FindBrowserWithWebContents(controller->GetWebContents()); | 475 chrome::ActivateTabAt(browser, tab_index, true); |
| 476 return browser; |
476 } | 477 } |
477 | 478 |
478 void AutomationProvider::HandleFindRequest( | 479 void AutomationProvider::HandleFindRequest( |
479 int handle, | 480 int handle, |
480 const AutomationMsg_Find_Params& params, | 481 const AutomationMsg_Find_Params& params, |
481 IPC::Message* reply_message) { | 482 IPC::Message* reply_message) { |
482 if (!tab_tracker_->ContainsHandle(handle)) { | 483 if (!tab_tracker_->ContainsHandle(handle)) { |
483 AutomationMsg_Find::WriteReplyParams(reply_message, -1, -1); | 484 AutomationMsg_Find::WriteReplyParams(reply_message, -1, -1); |
484 Send(reply_message); | 485 Send(reply_message); |
485 return; | 486 return; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 751 |
751 return NULL; | 752 return NULL; |
752 } | 753 } |
753 | 754 |
754 void AutomationProvider::SaveAsAsync(int tab_handle) { | 755 void AutomationProvider::SaveAsAsync(int tab_handle) { |
755 NavigationController* tab = NULL; | 756 NavigationController* tab = NULL; |
756 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); | 757 WebContents* web_contents = GetWebContentsForHandle(tab_handle, &tab); |
757 if (web_contents) | 758 if (web_contents) |
758 web_contents->OnSavePage(); | 759 web_contents->OnSavePage(); |
759 } | 760 } |
OLD | NEW |