summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authornirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 17:39:42 +0000
committernirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 17:39:42 +0000
commit8982ab1c48ce6495d98332fa02037c5f8e159efb (patch)
tree246abdef8757510b3206f740427922dd0172f495 /chrome/browser
parentb0deb15a7c1769f0a9814e7ec64975b68c016638 (diff)
downloadchromium_src-8982ab1c48ce6495d98332fa02037c5f8e159efb.zip
chromium_src-8982ab1c48ce6495d98332fa02037c5f8e159efb.tar.gz
chromium_src-8982ab1c48ce6495d98332fa02037c5f8e159efb.tar.bz2
Fetch info about the state of navigation in a tab
This includes info about: - ssl status: allows for automation of ssl tests - page type - favicon TEST=ssl.py Review URL: http://codereview.chromium.org/3266012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_provider.cc53
-rw-r--r--chrome/browser/automation/automation_provider.h7
2 files changed, 60 insertions, 0 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 87578db..e2f5d12 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"
@@ -748,6 +749,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.
@@ -2100,6 +2151,8 @@ void AutomationProvider::SendJSONRequest(int handle,
handler_map["GetBrowserInfo"] = &AutomationProvider::GetBrowserInfo;
+ handler_map["GetNavigationInfo"] = &AutomationProvider::GetNavigationInfo;
+
handler_map["PerformActionOnInfobar"] =
&AutomationProvider::PerformActionOnInfobar;
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index ff859591..00cc478 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -246,6 +246,13 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
DictionaryValue* args,
IPC::Message* reply_message);
+ // Get info about the state of navigation in a given tab.
+ // This includes ssl info.
+ // Uses the JSON interface for input/output.
+ void GetNavigationInfo(Browser* browser,
+ DictionaryValue* args,
+ IPC::Message* reply_message);
+
// Get info about downloads. This includes only ones that have been
// registered by the history system.
// Uses the JSON interface for input/output.