Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/location_bar/page_info_helper.h" | 5 #include "chrome/browser/ui/views/location_bar/page_info_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/search/search.h" | 7 #include "chrome/browser/search/search.h" |
| 8 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 8 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
| 11 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 14 | 14 |
| 15 using content::NavigationController; | 15 using content::NavigationController; |
| 16 using content::NavigationEntry; | 16 using content::NavigationEntry; |
| 17 using content::WebContents; | 17 using content::WebContents; |
| 18 | 18 |
| 19 PageInfoHelper::PageInfoHelper(const views::View* owner, | 19 PageInfoHelper::PageInfoHelper(const views::View* owner, |
| 20 LocationBarView* location_bar) | 20 LocationBarView* location_bar) |
| 21 : owner_(owner), | 21 : owner_(owner), |
| 22 location_bar_(location_bar) { | 22 location_bar_(location_bar) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 void PageInfoHelper::ProcessEvent(const ui::LocatedEvent& event) { | 25 void PageInfoHelper::ProcessEvent(const ui::LocatedEvent& event) { |
| 26 if (!owner_->HitTestPoint(event.location())) | 26 if (!owner_->HitTestPoint(event.location())) |
| 27 return; | 27 return; |
| 28 | 28 |
| 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 !chrome::ShouldDisplayOriginChipV2()) | |
| 34 return; | |
| 35 | |
| 36 WebContents* tab = location_bar_->GetWebContents(); | 29 WebContents* tab = location_bar_->GetWebContents(); |
| 37 if (!tab) | 30 if (!tab) |
| 38 return; | 31 return; |
| 39 const NavigationController& controller = tab->GetController(); | 32 const NavigationController& controller = tab->GetController(); |
| 40 // Important to use GetVisibleEntry to match what's showing in the omnibox. | 33 // Important to use GetVisibleEntry to match what's showing in the omnibox. |
| 41 NavigationEntry* nav_entry = controller.GetVisibleEntry(); | 34 NavigationEntry* nav_entry = controller.GetVisibleEntry(); |
| 42 if (!nav_entry) { | 35 if (!nav_entry) { |
| 43 NOTREACHED(); | 36 NOTREACHED(); |
|
Peter Kasting
2014/03/12 21:11:27
Nit: While here: Please fix this style violation b
Justin Donnelly
2014/03/14 15:27:51
Done.
| |
| 44 return; | 37 return; |
| 45 } | 38 } |
| 46 | 39 |
| 47 location_bar_->delegate()->ShowWebsiteSettings( | 40 location_bar_->delegate()->ShowWebsiteSettings( |
| 48 tab, nav_entry->GetURL(), nav_entry->GetSSL()); | 41 tab, nav_entry->GetURL(), nav_entry->GetSSL()); |
| 49 } | 42 } |
| OLD | NEW |