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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 6650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6661 | 6661 |
6662 void TestingAutomationProvider::GetTabInfo( | 6662 void TestingAutomationProvider::GetTabInfo( |
6663 DictionaryValue* args, | 6663 DictionaryValue* args, |
6664 IPC::Message* reply_message) { | 6664 IPC::Message* reply_message) { |
6665 AutomationJSONReply reply(this, reply_message); | 6665 AutomationJSONReply reply(this, reply_message); |
6666 Browser* browser; | 6666 Browser* browser; |
6667 WebContents* tab; | 6667 WebContents* tab; |
6668 std::string error; | 6668 std::string error; |
6669 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { | 6669 if (GetBrowserAndTabFromJSONArgs(args, &browser, &tab, &error)) { |
6670 NavigationEntry* entry = tab->GetController().GetActiveEntry(); | 6670 NavigationEntry* entry = tab->GetController().GetActiveEntry(); |
| 6671 if (!entry) { |
| 6672 reply.SendError("Unable to get active navigation entry"); |
| 6673 return; |
| 6674 } |
6671 DictionaryValue dict; | 6675 DictionaryValue dict; |
6672 dict.SetString("title", entry->GetTitleForDisplay("")); | 6676 dict.SetString("title", entry->GetTitleForDisplay("")); |
6673 dict.SetString("url", entry->GetVirtualURL().spec()); | 6677 dict.SetString("url", entry->GetVirtualURL().spec()); |
6674 reply.SendSuccess(&dict); | 6678 reply.SendSuccess(&dict); |
6675 } else { | 6679 } else { |
6676 reply.SendError(error); | 6680 reply.SendError(error); |
6677 } | 6681 } |
6678 } | 6682 } |
6679 | 6683 |
6680 void TestingAutomationProvider::GetTabCountJSON( | 6684 void TestingAutomationProvider::GetTabCountJSON( |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7243 void TestingAutomationProvider::OnRemoveProvider() { | 7247 void TestingAutomationProvider::OnRemoveProvider() { |
7244 if (g_browser_process) | 7248 if (g_browser_process) |
7245 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 7249 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
7246 } | 7250 } |
7247 | 7251 |
7248 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, | 7252 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, |
7249 WebContents* tab) { | 7253 WebContents* tab) { |
7250 if (chrome::GetActiveWebContents(browser) != tab) | 7254 if (chrome::GetActiveWebContents(browser) != tab) |
7251 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); | 7255 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); |
7252 } | 7256 } |
OLD | NEW |