summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-23 18:49:52 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-23 18:49:52 +0000
commit6aa376b2bfe85c851edca7fc04a05960bc419051 (patch)
tree3db99be45acc2670857a2d0555eb239a06312c57 /chrome
parent3c0d854087dfc385de5c63875cc1f37ce28fb8de (diff)
downloadchromium_src-6aa376b2bfe85c851edca7fc04a05960bc419051.zip
chromium_src-6aa376b2bfe85c851edca7fc04a05960bc419051.tar.gz
chromium_src-6aa376b2bfe85c851edca7fc04a05960bc419051.tar.bz2
This CL enables the Page info menu when right-clicking on a page/frame.
For the frame case, the SSL info had to be added to the show menu message (as the navigation entry contains the top frame SSL info). BUG=2467 TEST=Open a page over HTTPS with multiple frames. Right-click and select shot page info. Review URL: http://codereview.chromium.org/4034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2504 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/render_view_context_menu_controller.cc36
-rw-r--r--chrome/browser/views/location_bar_view.cc12
-rw-r--r--chrome/browser/views/page_info_window.cc64
-rw-r--r--chrome/browser/views/page_info_window.h33
-rw-r--r--chrome/common/render_messages.h7
-rw-r--r--chrome/renderer/render_view.cc4
-rw-r--r--chrome/renderer/render_view.h3
7 files changed, 118 insertions, 41 deletions
diff --git a/chrome/browser/render_view_context_menu_controller.cc b/chrome/browser/render_view_context_menu_controller.cc
index 39f5b9e..2968c6d 100644
--- a/chrome/browser/render_view_context_menu_controller.cc
+++ b/chrome/browser/render_view_context_menu_controller.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/navigation_entry.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/template_url_model.h"
+#include "chrome/browser/views/page_info_window.h"
#include "chrome/browser/web_contents.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/clipboard_service.h"
@@ -172,7 +173,9 @@ bool RenderViewContextMenuController::IsCommandEnabled(int id) const {
case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY:
return !params_.misspelled_word.empty();
case IDS_CONTENT_CONTEXT_VIEWPAGEINFO:
+ return (source_web_contents_->controller()->GetActiveEntry() != NULL);
case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO:
+ return true;
case IDS_CONTENT_CONTEXT_SAVEFRAMEAS:
case IDS_CONTENT_CONTEXT_PRINTFRAME:
case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented.
@@ -282,10 +285,15 @@ void RenderViewContextMenuController::ExecuteCommand(int id) {
Inspect(params_.x, params_.y);
break;
- case IDS_CONTENT_CONTEXT_VIEWPAGEINFO:
- win_util::MessageBox(NULL, L"Context Menu Action", L"View Page Info",
- MB_OK);
+ case IDS_CONTENT_CONTEXT_VIEWPAGEINFO: {
+ NavigationEntry* nav_entry =
+ source_web_contents_->controller()->GetActiveEntry();
+ PageInfoWindow::CreatePageInfo(source_web_contents_->profile(),
+ nav_entry,
+ source_web_contents_->GetContentHWND(),
+ PageInfoWindow::SECURITY);
break;
+ }
case IDS_CONTENT_CONTEXT_OPENFRAMENEWTAB:
OpenURL(params_.frame_url, NEW_BACKGROUND_TAB, PageTransition::LINK);
@@ -314,10 +322,26 @@ void RenderViewContextMenuController::ExecuteCommand(int id) {
NEW_FOREGROUND_TAB, PageTransition::GENERATED);
break;
- case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO:
- win_util::MessageBox(NULL, L"Context Menu Action", L"View Frame Info",
- MB_OK);
+ case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO: {
+ // Deserialize the SSL info.
+ NavigationEntry::SSLStatus ssl;
+ if (!params_.security_info.empty()) {
+ int cert_id, cert_status, security_bits;
+ SSLManager::DeserializeSecurityInfo(params_.security_info,
+ &cert_id,
+ &cert_status,
+ &security_bits);
+ ssl.set_cert_id(cert_id);
+ ssl.set_cert_status(cert_status);
+ ssl.set_security_bits(security_bits);
+ }
+ PageInfoWindow::CreateFrameInfo(source_web_contents_->profile(),
+ params_.frame_url,
+ ssl,
+ source_web_contents_->GetContentHWND(),
+ PageInfoWindow::SECURITY);
break;
+ }
case IDS_CONTENT_CONTEXT_UNDO:
source_web_contents_->Undo();
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index dcdc5ae..5941d23 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -1004,10 +1004,14 @@ bool LocationBarView::SecurityImageView::OnMousePressed(
NavigationEntry* nav_entry =
BrowserList::GetLastActive()->GetSelectedTabContents()->
controller()->GetActiveEntry();
- PageInfoWindow::Create(profile_,
- nav_entry,
- GetRootView()->GetViewContainer()->GetHWND(),
- PageInfoWindow::SECURITY);
+ if (!nav_entry) {
+ NOTREACHED();
+ return true;
+ }
+ PageInfoWindow::CreatePageInfo(profile_,
+ nav_entry,
+ GetRootView()->GetViewContainer()->GetHWND(),
+ PageInfoWindow::SECURITY);
return true;
}
diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc
index 8116110..adbdd73 100644
--- a/chrome/browser/views/page_info_window.cc
+++ b/chrome/browser/views/page_info_window.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/cert_store.h"
#include "chrome/browser/history/history.h"
-#include "chrome/browser/navigation_entry.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/ssl_manager.h"
#include "chrome/browser/views/standard_layout.h"
@@ -41,7 +40,11 @@ const int kHorizontalPadding = 10;
// SecurityTabView
class SecurityTabView : public ChromeViews::View {
public:
- SecurityTabView(Profile* profile, NavigationEntry* navigation_entry);
+ SecurityTabView(Profile* profile,
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ NavigationEntry::PageType page_type,
+ bool show_history);
virtual ~SecurityTabView();
virtual void Layout();
@@ -223,25 +226,26 @@ void SecurityTabView::Section::Layout() {
}
SecurityTabView::SecurityTabView(Profile* profile,
- NavigationEntry* navigation_entry) {
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ NavigationEntry::PageType page_type,
+ bool show_history) {
bool identity_ok = true;
bool connection_ok = true;
std::wstring identity_title;
std::wstring identity_msg;
std::wstring connection_msg;
scoped_refptr<net::X509Certificate> cert;
- const NavigationEntry::SSLStatus& ssl = navigation_entry->ssl();
// Identity section.
- std::wstring subject_name(UTF8ToWide(navigation_entry->url().host()));
+ std::wstring subject_name(UTF8ToWide(url.host()));
bool empty_subject_name = false;
if (subject_name.empty()) {
subject_name.assign(
l10n_util::GetString(IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY));
empty_subject_name = true;
}
- if (navigation_entry->page_type() == NavigationEntry::NORMAL_PAGE &&
- ssl.cert_id() &&
+ if (page_type == NavigationEntry::NORMAL_PAGE && ssl.cert_id() &&
CertStore::GetSharedInstance()->RetrieveCert(ssl.cert_id(), &cert) &&
!net::IsCertStatusError(ssl.cert_status())) {
// OK HTTPS page.
@@ -250,7 +254,7 @@ SecurityTabView::SecurityTabView(Profile* profile,
identity_title =
l10n_util::GetStringF(IDS_PAGE_INFO_EV_IDENTITY_TITLE,
UTF8ToWide(cert->subject().organization_names[0]),
- UTF8ToWide(navigation_entry->url().host()));
+ UTF8ToWide(url.host()));
// An EV Cert is required to have a city (localityName) and country but
// state is "if any".
DCHECK(!cert->subject().locality_name.empty());
@@ -347,9 +351,9 @@ SecurityTabView::SecurityTabView(Profile* profile,
// Request the number of visits.
HistoryService* history = profile->GetHistoryService(
Profile::EXPLICIT_ACCESS);
- if (history) {
+ if (show_history && history) {
history->GetVisitCountToHost(
- navigation_entry->url(),
+ url,
&request_consumer_,
NewCallback(this, &SecurityTabView::OnGotVisitCountToHost));
}
@@ -470,12 +474,25 @@ class PageInfoContentView : public ChromeViews::View {
int PageInfoWindow::opened_window_count_ = 0;
// static
-void PageInfoWindow::Create(Profile* profile,
- NavigationEntry* nav_entry,
- HWND parent_hwnd,
- PageInfoWindow::TabID tab) {
+void PageInfoWindow::CreatePageInfo(Profile* profile,
+ NavigationEntry* nav_entry,
+ HWND parent_hwnd,
+ PageInfoWindow::TabID tab) {
PageInfoWindow* window = new PageInfoWindow();
- window->Init(profile, nav_entry, parent_hwnd);
+ window->Init(profile, nav_entry->url(), nav_entry->ssl(),
+ nav_entry->page_type(), true, parent_hwnd);
+ window->Show();
+}
+
+// static
+void PageInfoWindow::CreateFrameInfo(Profile* profile,
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ HWND parent_hwnd,
+ TabID tab) {
+ PageInfoWindow* window = new PageInfoWindow();
+ window->Init(profile, url, ssl, NavigationEntry::NORMAL_PAGE,
+ false, parent_hwnd);
window->Show();
}
@@ -493,9 +510,12 @@ PageInfoWindow::~PageInfoWindow() {
}
void PageInfoWindow::Init(Profile* profile,
- NavigationEntry* navigation_entry,
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ NavigationEntry::PageType page_type,
+ bool show_history,
HWND parent) {
- cert_id_ = navigation_entry->ssl().cert_id();
+ cert_id_ = ssl.cert_id();
cert_info_button_ = new ChromeViews::NativeButton(
l10n_util::GetString(IDS_PAGEINFO_CERT_INFO_BUTTON));
@@ -528,7 +548,8 @@ void PageInfoWindow::Init(Profile* profile,
layout->AddPaddingRow(0, kHorizontalPadding);
layout->StartRow(1, 0);
- layout->AddView(CreateSecurityTabView(profile, navigation_entry), 2, 1);
+ layout->AddView(CreateSecurityTabView(profile, url, ssl, page_type,
+ show_history), 2, 1);
layout->AddPaddingRow(0, kHorizontalPadding);
@@ -566,8 +587,11 @@ ChromeViews::View* PageInfoWindow::CreateGeneralTabView() {
ChromeViews::View* PageInfoWindow::CreateSecurityTabView(
Profile* profile,
- NavigationEntry* navigation_entry) {
- return new SecurityTabView(profile, navigation_entry);
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ NavigationEntry::PageType page_type,
+ bool show_history) {
+ return new SecurityTabView(profile, url, ssl, page_type, show_history);
}
void PageInfoWindow::Show() {
diff --git a/chrome/browser/views/page_info_window.h b/chrome/browser/views/page_info_window.h
index f2e998c..3f94fec 100644
--- a/chrome/browser/views/page_info_window.h
+++ b/chrome/browser/views/page_info_window.h
@@ -5,9 +5,11 @@
#ifndef CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H__
#define CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H__
+#include "chrome/browser/navigation_entry.h"
#include "chrome/views/dialog_delegate.h"
#include "chrome/views/native_button.h"
#include "chrome/views/window.h"
+#include "googleurl/src/gurl.h"
// The page info window displays information regarding the current page,
// including security information.
@@ -31,11 +33,19 @@ class PageInfoWindow : public ChromeViews::DialogDelegate,
};
- // Creates and shows a new PageInfoWindow.
- static void Create(Profile* profile,
- NavigationEntry* nav_entry,
- HWND parent_hwnd,
- TabID tab);
+ // Creates and shows a new page info window for the main page.
+ static void CreatePageInfo(Profile* profile,
+ NavigationEntry* nav_entry,
+ HWND parent_hwnd,
+ TabID tab);
+
+ // Creates and shows a new page info window for the frame at |url| with the
+ // specified SSL information.
+ static void CreateFrameInfo(Profile* profile,
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ HWND parent_hwnd,
+ TabID tab);
static void RegisterPrefs(PrefService* prefs);
@@ -43,7 +53,10 @@ class PageInfoWindow : public ChromeViews::DialogDelegate,
virtual ~PageInfoWindow();
virtual void Init(Profile* profile,
- NavigationEntry* navigation_entry,
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ NavigationEntry::PageType page_type,
+ bool show_history,
HWND parent);
// ChromeViews::Window overridden method.
@@ -65,8 +78,12 @@ class PageInfoWindow : public ChromeViews::DialogDelegate,
private:
ChromeViews::View* CreateGeneralTabView();
- ChromeViews::View* CreateSecurityTabView(Profile* profile,
- NavigationEntry* navigation_entry);
+ ChromeViews::View* CreateSecurityTabView(
+ Profile* profile,
+ const GURL& url,
+ const NavigationEntry::SSLStatus& ssl,
+ NavigationEntry::PageType page_type,
+ bool show_history);
// Offsets the specified rectangle so it is showing on the screen and shifted
// from its original location.
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 6f82feb..f1c9bcda 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -150,6 +150,9 @@ struct ViewHostMsg_ContextMenu_Params {
// These flags indicate to the browser whether the renderer believes it is
// able to perform the corresponding action.
int edit_flags;
+
+ // The security info for the resource we are showing the menu on.
+ std::string security_info;
};
// Values that may be OR'd together to form the 'flags' parameter of a
@@ -766,6 +769,7 @@ struct ParamTraits<ViewHostMsg_ContextMenu_Params> {
WriteParam(m, p.misspelled_word);
WriteParam(m, p.dictionary_suggestions);
WriteParam(m, p.edit_flags);
+ WriteParam(m, p.security_info);
}
static bool Read(const Message* m, void** iter, param_type* p) {
return
@@ -779,7 +783,8 @@ struct ParamTraits<ViewHostMsg_ContextMenu_Params> {
ReadParam(m, iter, &p->selection_text) &&
ReadParam(m, iter, &p->misspelled_word) &&
ReadParam(m, iter, &p->dictionary_suggestions) &&
- ReadParam(m, iter, &p->edit_flags);
+ ReadParam(m, iter, &p->edit_flags) &&
+ ReadParam(m, iter, &p->security_info);
}
static void Log(const param_type& p, std::wstring* l) {
l->append(L"<ViewHostMsg_ContextMenu_Params>");
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index f978178..032584b 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1790,7 +1790,8 @@ void RenderView::ShowContextMenu(WebView* webview,
const GURL& frame_url,
const std::wstring& selection_text,
const std::wstring& misspelled_word,
- int edit_flags) {
+ int edit_flags,
+ const std::string& security_info) {
ViewHostMsg_ContextMenu_Params params;
params.type = type;
params.x = x;
@@ -1802,6 +1803,7 @@ void RenderView::ShowContextMenu(WebView* webview,
params.selection_text = selection_text;
params.misspelled_word = misspelled_word;
params.edit_flags = edit_flags;
+ params.security_info = security_info;
Send(new ViewHostMsg_ContextMenu(routing_id_, params));
}
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 85c74fc..6f6b9c3 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -205,7 +205,8 @@ class RenderView : public RenderWidget, public WebViewDelegate,
const GURL& frame_url,
const std::wstring& selection_text,
const std::wstring& misspelled_word,
- int edit_flags);
+ int edit_flags,
+ const std::string& security_info);
virtual void StartDragging(WebView* webview,
const WebDropData& drag_data);