page_info_helper.cc revision 7dbb3d5cf0c15f500944d211057644d6a2f37371
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
3// found in the LICENSE file.
4
5#include "chrome/browser/ui/views/location_bar/page_info_helper.h"
6
7#include "chrome/browser/ui/omnibox/omnibox_view.h"
8#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
9#include "content/public/browser/navigation_controller.h"
10#include "content/public/browser/navigation_entry.h"
11#include "content/public/browser/web_contents.h"
12#include "ui/views/view.h"
13
14using content::NavigationController;
15using content::NavigationEntry;
16using content::WebContents;
17
18PageInfoHelper::PageInfoHelper(const views::View* owner,
19                               LocationBarView* location_bar)
20    : owner_(owner),
21      location_bar_(location_bar) {
22}
23
24void PageInfoHelper::ProcessEvent(const ui::LocatedEvent& event) {
25  if (!owner_->HitTestPoint(event.location()))
26    return;
27
28  // Do not show page info if the user has been editing the location
29  // bar, or the location bar is at the NTP.
30  if (location_bar_->GetLocationEntry()->IsEditingOrEmpty())
31    return;
32
33  WebContents* tab = location_bar_->GetWebContents();
34  if (!tab)
35    return;
36  const NavigationController& controller = tab->GetController();
37  NavigationEntry* nav_entry = controller.GetActiveEntry();
38  if (!nav_entry) {
39    NOTREACHED();
40    return;
41  }
42
43  location_bar_->delegate()->ShowWebsiteSettings(
44      tab, nav_entry->GetURL(), nav_entry->GetSSL());
45}
46