Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / page_info_helper.cc
blob2c99ad16c3a8a6de2f0b1a810d4c946d64fd9290
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.
5 #include "chrome/browser/ui/views/location_bar/page_info_helper.h"
7 #include "chrome/browser/search/search.h"
8 #include "chrome/browser/ui/omnibox/omnibox_view.h"
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
10 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/browser/web_contents.h"
13 #include "ui/views/view.h"
15 using content::NavigationController;
16 using content::NavigationEntry;
17 using content::WebContents;
19 PageInfoHelper::PageInfoHelper(const views::View* owner,
20 LocationBarView* location_bar)
21 : owner_(owner),
22 location_bar_(location_bar) {
25 void PageInfoHelper::ProcessEvent(const ui::LocatedEvent& event) {
26 if (!owner_->HitTestPoint(event.location()))
27 return;
29 // Do not show page info if the user has been editing the location
30 // bar, or the location bar is at the NTP.
31 if (location_bar_->GetOmniboxView()->IsEditingOrEmpty() &&
32 !chrome::ShouldDisplayOriginChip())
33 return;
35 WebContents* tab = location_bar_->GetWebContents();
36 if (!tab)
37 return;
38 const NavigationController& controller = tab->GetController();
39 // Important to use GetVisibleEntry to match what's showing in the omnibox.
40 NavigationEntry* nav_entry = controller.GetVisibleEntry();
41 if (!nav_entry) {
42 NOTREACHED();
43 return;
46 location_bar_->delegate()->ShowWebsiteSettings(
47 tab, nav_entry->GetURL(), nav_entry->GetSSL());