OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/external_tab_container_win.h" | 5 #include "chrome/browser/external_tab_container_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return new_model; | 89 return new_model; |
90 } | 90 } |
91 | 91 |
92 } // namespace | 92 } // namespace |
93 | 93 |
94 // This class overrides the LinkClicked function in the PageInfoBubbleView | 94 // This class overrides the LinkClicked function in the PageInfoBubbleView |
95 // class and routes the help center link navigation to the host browser. | 95 // class and routes the help center link navigation to the host browser. |
96 class ExternalTabPageInfoBubbleView : public PageInfoBubbleView { | 96 class ExternalTabPageInfoBubbleView : public PageInfoBubbleView { |
97 public: | 97 public: |
98 ExternalTabPageInfoBubbleView(ExternalTabContainer* container, | 98 ExternalTabPageInfoBubbleView(ExternalTabContainer* container, |
99 gfx::NativeWindow parent_window, | 99 const views::View* anchor_view, |
100 Profile* profile, | 100 Profile* profile, |
101 const GURL& url, | 101 const GURL& url, |
102 const NavigationEntry::SSLStatus& ssl, | 102 const NavigationEntry::SSLStatus& ssl, |
103 bool show_history) | 103 bool show_history) |
104 : PageInfoBubbleView(parent_window, profile, url, ssl, show_history), | 104 : PageInfoBubbleView(anchor_view, profile, url, ssl, show_history), |
105 container_(container) { | 105 container_(container) { |
106 DVLOG(1) << __FUNCTION__; | 106 DVLOG(1) << __FUNCTION__; |
107 } | 107 } |
| 108 |
108 virtual ~ExternalTabPageInfoBubbleView() { | 109 virtual ~ExternalTabPageInfoBubbleView() { |
109 DVLOG(1) << __FUNCTION__; | 110 DVLOG(1) << __FUNCTION__; |
110 } | 111 } |
111 // LinkListener methods: | 112 |
| 113 // views::LinkListener methods: |
112 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE { | 114 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE { |
113 GURL url = google_util::AppendGoogleLocaleParam( | 115 GURL url = google_util::AppendGoogleLocaleParam( |
114 GURL(chrome::kPageInfoHelpCenterURL)); | 116 GURL(chrome::kPageInfoHelpCenterURL)); |
115 container_->OpenURLFromTab(container_->tab_contents(), url, GURL(), | 117 container_->OpenURLFromTab(container_->tab_contents(), url, GURL(), |
116 NEW_FOREGROUND_TAB, | 118 NEW_FOREGROUND_TAB, |
117 content::PAGE_TRANSITION_LINK); | 119 content::PAGE_TRANSITION_LINK); |
118 } | 120 } |
| 121 |
| 122 // PageInfoBubbleView methods: |
| 123 virtual gfx::Point GetAnchorPoint() OVERRIDE { |
| 124 POINT cursor_pos = {0}; |
| 125 GetCursorPos(&cursor_pos); |
| 126 return gfx::Point(cursor_pos); |
| 127 } |
| 128 |
119 private: | 129 private: |
120 scoped_refptr<ExternalTabContainer> container_; | 130 scoped_refptr<ExternalTabContainer> container_; |
121 }; | 131 }; |
122 | 132 |
123 base::LazyInstance<ExternalTabContainer::PendingTabs> | 133 base::LazyInstance<ExternalTabContainer::PendingTabs> |
124 ExternalTabContainer::pending_tabs_(base::LINKER_INITIALIZED); | 134 ExternalTabContainer::pending_tabs_(base::LINKER_INITIALIZED); |
125 | 135 |
126 ExternalTabContainer::ExternalTabContainer( | 136 ExternalTabContainer::ExternalTabContainer( |
127 AutomationProvider* automation, AutomationResourceMessageFilter* filter) | 137 AutomationProvider* automation, AutomationResourceMessageFilter* filter) |
128 : views::NativeWidgetWin(new views::Widget), | 138 : views::NativeWidgetWin(new views::Widget), |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 594 } |
585 | 595 |
586 // Never allow downloads. | 596 // Never allow downloads. |
587 return false; | 597 return false; |
588 } | 598 } |
589 | 599 |
590 void ExternalTabContainer::ShowPageInfo(Profile* profile, | 600 void ExternalTabContainer::ShowPageInfo(Profile* profile, |
591 const GURL& url, | 601 const GURL& url, |
592 const NavigationEntry::SSLStatus& ssl, | 602 const NavigationEntry::SSLStatus& ssl, |
593 bool show_history) { | 603 bool show_history) { |
594 POINT cursor_pos = {0}; | |
595 GetCursorPos(&cursor_pos); | |
596 | |
597 gfx::Rect bounds; | |
598 bounds.set_origin(gfx::Point(cursor_pos)); | |
599 | |
600 PageInfoBubbleView* page_info_bubble = | 604 PageInfoBubbleView* page_info_bubble = |
601 new ExternalTabPageInfoBubbleView(this, NULL, profile, url, | 605 new ExternalTabPageInfoBubbleView(this, NULL, profile, url, |
602 ssl, show_history); | 606 ssl, show_history); |
603 Bubble* bubble = Bubble::Show(GetWidget(), bounds, | 607 views::BubbleDelegateView::CreateBubble(page_info_bubble); |
604 views::BubbleBorder::TOP_LEFT, | 608 page_info_bubble->Show(); |
605 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
606 page_info_bubble, page_info_bubble); | |
607 page_info_bubble->set_bubble(bubble); | |
608 } | 609 } |
609 | 610 |
610 void ExternalTabContainer::RegisterRenderViewHostForAutomation( | 611 void ExternalTabContainer::RegisterRenderViewHostForAutomation( |
611 RenderViewHost* render_view_host, bool pending_view) { | 612 RenderViewHost* render_view_host, bool pending_view) { |
612 if (render_view_host) { | 613 if (render_view_host) { |
613 AutomationResourceMessageFilter::RegisterRenderView( | 614 AutomationResourceMessageFilter::RegisterRenderView( |
614 render_view_host->process()->id(), | 615 render_view_host->process()->id(), |
615 render_view_host->routing_id(), | 616 render_view_host->routing_id(), |
616 tab_handle(), | 617 tab_handle(), |
617 automation_resource_message_filter_, | 618 automation_resource_message_filter_, |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 if (params.disposition == CURRENT_TAB) { | 1227 if (params.disposition == CURRENT_TAB) { |
1227 DCHECK(route_all_top_level_navigations_); | 1228 DCHECK(route_all_top_level_navigations_); |
1228 forward_params.disposition = NEW_FOREGROUND_TAB; | 1229 forward_params.disposition = NEW_FOREGROUND_TAB; |
1229 } | 1230 } |
1230 TabContents* new_contents = | 1231 TabContents* new_contents = |
1231 ExternalTabContainer::OpenURLFromTab(source, forward_params); | 1232 ExternalTabContainer::OpenURLFromTab(source, forward_params); |
1232 // support only one navigation for a dummy tab before it is killed. | 1233 // support only one navigation for a dummy tab before it is killed. |
1233 ::DestroyWindow(GetNativeView()); | 1234 ::DestroyWindow(GetNativeView()); |
1234 return new_contents; | 1235 return new_contents; |
1235 } | 1236 } |
OLD | NEW |