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/click_handler.h" | 5 #include "chrome/browser/ui/views/location_bar/click_handler.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 9 #include "chrome/browser/ui/views/window.h" | |
|
sky
2012/02/28 18:24:24
sort
altimofeev
2012/02/29 18:57:29
Done.
| |
| 10 #include "chrome/browser/ui/views/page_info_bubble_view.h" | |
| 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 12 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | |
| 10 #include "content/public/browser/navigation_controller.h" | 13 #include "content/public/browser/navigation_controller.h" |
| 11 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
| 12 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 13 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 14 | 17 |
| 18 #if defined(USE_AURA) | |
| 19 #include "ash/shell.h" | |
| 20 #include "ash/shell_window_ids.h" | |
| 21 #endif | |
| 22 | |
| 15 using content::NavigationController; | 23 using content::NavigationController; |
| 16 using content::NavigationEntry; | 24 using content::NavigationEntry; |
| 17 using content::WebContents; | 25 using content::WebContents; |
| 18 | 26 |
| 19 ClickHandler::ClickHandler(const views::View* owner, | 27 ClickHandler::ClickHandler(const views::View* owner, |
| 20 LocationBarView* location_bar) | 28 LocationBarView* location_bar) |
| 21 : owner_(owner), | 29 : owner_(owner), |
| 22 location_bar_(location_bar) { | 30 location_bar_(location_bar) { |
| 23 } | 31 } |
| 24 | 32 |
| 25 void ClickHandler::OnMouseReleased(const views::MouseEvent& event) { | 33 void ClickHandler::OnMouseReleased(const views::MouseEvent& event) { |
| 26 if (!owner_->HitTest(event.location())) | 34 if (!owner_->HitTest(event.location())) |
| 27 return; | 35 return; |
| 28 | 36 |
| 29 // Do not show page info if the user has been editing the location | 37 // Do not show page info if the user has been editing the location |
| 30 // bar, or the location bar is at the NTP. | 38 // bar, or the location bar is at the NTP. |
| 31 if (location_bar_->location_entry()->IsEditingOrEmpty()) | 39 if (location_bar_->location_entry()->IsEditingOrEmpty()) |
| 32 return; | 40 return; |
| 33 | 41 |
| 34 WebContents* tab = location_bar_->GetTabContentsWrapper()->web_contents(); | 42 WebContents* tab = location_bar_->GetTabContentsWrapper()->web_contents(); |
| 35 const NavigationController& controller = tab->GetController(); | 43 const NavigationController& controller = tab->GetController(); |
| 36 NavigationEntry* nav_entry = controller.GetActiveEntry(); | 44 NavigationEntry* nav_entry = controller.GetActiveEntry(); |
| 37 if (!nav_entry) { | 45 if (!nav_entry) { |
| 38 NOTREACHED(); | 46 NOTREACHED(); |
| 39 return; | 47 return; |
| 40 } | 48 } |
| 41 | 49 |
| 42 Browser* browser = Browser::GetBrowserForController(&controller, NULL); | 50 Browser* browser = location_bar_->FindBrowser(); |
| 43 browser->ShowPageInfo(tab, nav_entry->GetURL(), nav_entry->GetSSL(), true); | 51 if (browser) { |
| 52 browser->ShowPageInfo(tab, nav_entry->GetURL(), nav_entry->GetSSL(), true); | |
| 53 } else { | |
| 54 #if defined(USE_AURA) | |
| 55 PageInfoBubbleView* page_info_bubble = | |
| 56 new PageInfoBubbleView( | |
| 57 location_bar_->location_icon_view(), location_bar_->profile(), | |
| 58 nav_entry->GetURL(), nav_entry->GetSSL(), true); | |
| 59 page_info_bubble->set_parent_window( | |
| 60 ash::Shell::GetInstance()->GetContainer( | |
| 61 ash::internal::kShellWindowId_LockSystemModalContainer)); | |
| 62 browser::CreateViewsBubble(page_info_bubble); | |
| 63 page_info_bubble->Show(); | |
| 64 #else | |
| 65 NOTIMPLEMENTED(); | |
| 66 #endif | |
| 67 } | |
| 44 } | 68 } |
| OLD | NEW |