click_handler.cc revision 201ade2fbba22bfb27ae029f4d23fca6ded109a0
1// Copyright (c) 2010 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/views/location_bar/click_handler.h"
6
7#include "chrome/browser/tab_contents/navigation_controller.h"
8#include "chrome/browser/tab_contents/tab_contents.h"
9#include "chrome/browser/tab_contents_wrapper.h"
10#include "chrome/browser/views/location_bar/location_bar_view.h"
11#include "views/view.h"
12
13ClickHandler::ClickHandler(const views::View* owner,
14                           const LocationBarView* location_bar)
15    : owner_(owner),
16      location_bar_(location_bar) {
17}
18
19void ClickHandler::OnMouseReleased(const views::MouseEvent& event,
20                                   bool canceled) {
21  if (canceled || !owner_->HitTest(event.location()))
22    return;
23
24  // Do not show page info if the user has been editing the location
25  // bar, or the location bar is at the NTP.
26  if (location_bar_->location_entry()->IsEditingOrEmpty())
27    return;
28
29  TabContents* tab = location_bar_->GetTabContentsWrapper()->tab_contents();
30  NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
31  if (!nav_entry) {
32    NOTREACHED();
33    return;
34  }
35  tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
36}
37
38