Index: chrome/browser/automation/automation_provider.cc |
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc |
index 418738a6c136d9851100ad97f795f288033fc257..b79181b15271e82c42601028e122e872c28393a0 100644 |
--- a/chrome/browser/automation/automation_provider.cc |
+++ b/chrome/browser/automation/automation_provider.cc |
@@ -82,6 +82,7 @@ |
#include "chrome/browser/ssl/ssl_manager.h" |
#include "chrome/browser/ssl/ssl_blocking_page.h" |
#include "chrome/browser/tab_contents/infobar_delegate.h" |
+#include "chrome/browser/tab_contents/navigation_entry.h" |
#include "chrome/browser/tab_contents/tab_contents.h" |
#include "chrome/browser/tab_contents/tab_contents_view.h" |
#include "chrome/browser/translate/translate_infobar_delegate.h" |
@@ -733,6 +734,56 @@ void AutomationProvider::GetBrowserInfo(Browser* browser, |
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
} |
+// Sample json input: { "command": "GetNavigationInfo" } |
+// Refer to GetNavigationInfo() in chrome/test/pyautolib/pyauto.py for |
+// sample json output. |
+void AutomationProvider::GetNavigationInfo(Browser* browser, |
+ DictionaryValue* args, |
+ IPC::Message* reply_message) { |
+ AutomationJSONReply reply(this, reply_message); |
+ int tab_index; |
+ TabContents* tab_contents = NULL; |
+ if (!args->GetInteger("tab_index", &tab_index) || |
+ !(tab_contents = browser->GetTabContentsAt(tab_index))) { |
+ reply.SendError("tab_index missing or invalid."); |
+ return; |
+ } |
+ scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
+ const NavigationController& controller = tab_contents->controller(); |
+ NavigationEntry* nav_entry = controller.GetActiveEntry(); |
+ DCHECK(nav_entry); |
+ |
+ // Security info. |
+ DictionaryValue* ssl = new DictionaryValue; |
+ std::map<SecurityStyle, std::string> style_to_string; |
+ style_to_string[SECURITY_STYLE_UNKNOWN] = "SECURITY_STYLE_UNKNOWN"; |
+ style_to_string[SECURITY_STYLE_UNAUTHENTICATED] = |
+ "SECURITY_STYLE_UNAUTHENTICATED"; |
+ style_to_string[SECURITY_STYLE_AUTHENTICATION_BROKEN] = |
+ "SECURITY_STYLE_AUTHENTICATION_BROKEN"; |
+ style_to_string[SECURITY_STYLE_AUTHENTICATED] = |
+ "SECURITY_STYLE_AUTHENTICATED"; |
+ |
+ NavigationEntry::SSLStatus ssl_status = nav_entry->ssl(); |
+ ssl->SetString("security_style", |
+ style_to_string[ssl_status.security_style()]); |
+ ssl->SetBoolean("ran_insecure_content", ssl_status.ran_insecure_content()); |
+ ssl->SetBoolean("displayed_insecure_content", |
+ ssl_status.displayed_insecure_content()); |
+ return_value->Set("ssl", ssl); |
+ |
+ // Page type. |
+ std::map<NavigationEntry::PageType, std::string> pagetype_to_string; |
+ pagetype_to_string[NavigationEntry::NORMAL_PAGE] = "NORMAL_PAGE"; |
+ pagetype_to_string[NavigationEntry::ERROR_PAGE] = "ERROR_PAGE"; |
+ pagetype_to_string[NavigationEntry::INTERSTITIAL_PAGE] = "INTERSTITIAL_PAGE"; |
+ return_value->SetString("page_type", |
+ pagetype_to_string[nav_entry->page_type()]); |
+ |
+ return_value->SetString("favicon_url", nav_entry->favicon().url().spec()); |
+ reply.SendSuccess(return_value.get()); |
+} |
+ |
// Sample json input: { "command": "GetHistoryInfo", |
// "search_text": "some text" } |
// Refer chrome/test/pyautolib/history_info.py for sample json output. |
@@ -2085,6 +2136,8 @@ void AutomationProvider::SendJSONRequest(int handle, |
handler_map["GetBrowserInfo"] = &AutomationProvider::GetBrowserInfo; |
+ handler_map["GetNavigationInfo"] = &AutomationProvider::GetNavigationInfo; |
+ |
handler_map["PerformActionOnInfobar"] = |
&AutomationProvider::PerformActionOnInfobar; |