Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: chrome/browser/ui/views/external_tab_container_win.cc

Issue 15944007: Fix cross-window focus in Chrome Frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only open popups once Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/external_tab_container_win.h" 5 #include "chrome/browser/ui/views/external_tab_container_win.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlapp.h> 8 #include <atlapp.h>
9 #include <atlconv.h> 9 #include <atlconv.h>
10 #include <atlcrack.h> 10 #include <atlcrack.h>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "ui/base/models/menu_model.h" 74 #include "ui/base/models/menu_model.h"
75 #include "ui/base/view_prop.h" 75 #include "ui/base/view_prop.h"
76 #include "ui/views/controls/webview/webview.h" 76 #include "ui/views/controls/webview/webview.h"
77 #include "ui/views/layout/grid_layout.h" 77 #include "ui/views/layout/grid_layout.h"
78 #include "ui/views/widget/widget.h" 78 #include "ui/views/widget/widget.h"
79 #include "ui/views/win/hwnd_util.h" 79 #include "ui/views/win/hwnd_util.h"
80 80
81 #if defined(USE_AURA) 81 #if defined(USE_AURA)
82 #include "ui/aura/root_window.h" 82 #include "ui/aura/root_window.h"
83 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 83 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
84 #include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h"
84 #endif 85 #endif
85 86
86 using content::BrowserThread; 87 using content::BrowserThread;
87 using content::LoadNotificationDetails; 88 using content::LoadNotificationDetails;
88 using content::NativeWebKeyboardEvent; 89 using content::NativeWebKeyboardEvent;
89 using content::NavigationController; 90 using content::NavigationController;
90 using content::NavigationEntry; 91 using content::NavigationEntry;
91 using content::OpenURLParams; 92 using content::OpenURLParams;
92 using content::RenderViewHost; 93 using content::RenderViewHost;
93 using content::SSLStatus; 94 using content::SSLStatus;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 224
224 void OnSize(UINT type, const CSize& size) { 225 void OnSize(UINT type, const CSize& size) {
225 ::SetWindowPos(child_, NULL, 0, 0, size.cx, size.cy, 226 ::SetWindowPos(child_, NULL, 0, 0, size.cx, size.cy,
226 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); 227 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
227 } 228 }
228 229
229 HWND child_; 230 HWND child_;
230 231
231 DISALLOW_COPY_AND_ASSIGN(ContainerWindow); 232 DISALLOW_COPY_AND_ASSIGN(ContainerWindow);
232 }; 233 };
234
235 // A specialization of DesktopRootWindowHost for an external tab container that
236 // saves and restores focus as the ETC is blurred and focused. DRWHW ordinarily
237 // does this during window activation and deactivation. Since the ETC is a child
238 // window, it does not receive activation messages.
239 class ExternalTabRootWindowHost : public views::DesktopRootWindowHostWin {
240 public:
241 ExternalTabRootWindowHost(
242 views::internal::NativeWidgetDelegate* native_widget_delegate,
243 views::DesktopNativeWidgetAura* desktop_native_widget_aura,
244 const gfx::Rect& initial_bounds)
245 : views::DesktopRootWindowHostWin(native_widget_delegate,
246 desktop_native_widget_aura,
247 initial_bounds) {}
248
249 protected:
250 // HWNDMessageHandlerDelegate methods:
251 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE {
252 views::DesktopRootWindowHostWin::HandleNativeFocus(last_focused_window);
253 RestoreFocusOnActivate();
254 }
255
256 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE {
257 SaveFocusOnDeactivate();
258 views::DesktopRootWindowHostWin::HandleNativeBlur(focused_window);
259 }
260
261 private:
262 DISALLOW_COPY_AND_ASSIGN(ExternalTabRootWindowHost);
263 };
233 #endif 264 #endif
234 265
235 base::LazyInstance<ExternalTabContainerWin::PendingTabs> 266 base::LazyInstance<ExternalTabContainerWin::PendingTabs>
236 ExternalTabContainerWin::pending_tabs_ = LAZY_INSTANCE_INITIALIZER; 267 ExternalTabContainerWin::pending_tabs_ = LAZY_INSTANCE_INITIALIZER;
237 268
238 ExternalTabContainerWin::ExternalTabContainerWin( 269 ExternalTabContainerWin::ExternalTabContainerWin(
239 AutomationProvider* automation, 270 AutomationProvider* automation,
240 AutomationResourceMessageFilter* filter) 271 AutomationResourceMessageFilter* filter)
241 : widget_(NULL), 272 : widget_(NULL),
242 automation_(automation), 273 automation_(automation),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 route_all_top_level_navigations_ = route_all_top_level_navigations; 328 route_all_top_level_navigations_ = route_all_top_level_navigations;
298 329
299 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 330 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
300 params.bounds = bounds; 331 params.bounds = bounds;
301 #if defined(USE_AURA) 332 #if defined(USE_AURA)
302 // Create the window that sits between the parent (most likely a 333 // Create the window that sits between the parent (most likely a
303 // ChromeFrameAutomationClient) and the DesktopRootWindowHostWin. 334 // ChromeFrameAutomationClient) and the DesktopRootWindowHostWin.
304 tab_container_window_ = 335 tab_container_window_ =
305 (new ContainerWindow(HWND_DESKTOP, params.bounds))->AsWeakPtr(); 336 (new ContainerWindow(HWND_DESKTOP, params.bounds))->AsWeakPtr();
306 337
307 params.native_widget = new views::DesktopNativeWidgetAura(widget_); 338 views::DesktopNativeWidgetAura* native_widget =
339 new views::DesktopNativeWidgetAura(widget_);
340 params.native_widget = native_widget;
341 params.desktop_root_window_host =
342 new ExternalTabRootWindowHost(widget_, native_widget, params.bounds);
308 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; 343 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
309 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; 344 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
310 #endif 345 #endif
311 widget_->Init(params); 346 widget_->Init(params);
312 347
313 #if defined(USE_AURA) 348 #if defined(USE_AURA)
314 tab_container_window_->SetChild(views::HWNDForWidget(widget_)); 349 tab_container_window_->SetChild(views::HWNDForWidget(widget_));
315 #endif 350 #endif
316 351
317 // TODO(jcampan): limit focus traversal to contents. 352 // TODO(jcampan): limit focus traversal to contents.
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 bool ExternalTabContainerWin::TakeFocus(content::WebContents* source, 788 bool ExternalTabContainerWin::TakeFocus(content::WebContents* source,
754 bool reverse) { 789 bool reverse) {
755 if (automation_) { 790 if (automation_) {
756 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, 791 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_,
757 base::win::IsShiftPressed())); 792 base::win::IsShiftPressed()));
758 } 793 }
759 794
760 return true; 795 return true;
761 } 796 }
762 797
798 void ExternalTabContainerWin::WebContentsFocused(
799 content::WebContents* contents) {
800 DCHECK_EQ(tab_contents_container_->GetWebContents(), contents);
801 tab_contents_container_->OnWebContentsFocused(contents);
802 }
803
763 void ExternalTabContainerWin::CanDownload( 804 void ExternalTabContainerWin::CanDownload(
764 RenderViewHost* render_view_host, 805 RenderViewHost* render_view_host,
765 int request_id, 806 int request_id,
766 const std::string& request_method, 807 const std::string& request_method,
767 const base::Callback<void(bool)>& callback) { 808 const base::Callback<void(bool)>& callback) {
768 if (load_requests_via_automation_) { 809 if (load_requests_via_automation_) {
769 if (automation_) { 810 if (automation_) {
770 // In case the host needs to show UI that needs to take the focus. 811 // In case the host needs to show UI that needs to take the focus.
771 ::AllowSetForegroundWindow(ASFW_ANY); 812 ::AllowSetForegroundWindow(ASFW_ANY);
772 813
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 if (params.disposition == CURRENT_TAB) { 1439 if (params.disposition == CURRENT_TAB) {
1399 DCHECK(route_all_top_level_navigations_); 1440 DCHECK(route_all_top_level_navigations_);
1400 forward_params.disposition = NEW_FOREGROUND_TAB; 1441 forward_params.disposition = NEW_FOREGROUND_TAB;
1401 } 1442 }
1402 WebContents* new_contents = 1443 WebContents* new_contents =
1403 ExternalTabContainerWin::OpenURLFromTab(source, forward_params); 1444 ExternalTabContainerWin::OpenURLFromTab(source, forward_params);
1404 // support only one navigation for a dummy tab before it is killed. 1445 // support only one navigation for a dummy tab before it is killed.
1405 widget_->CloseNow(); 1446 widget_->CloseNow();
1406 return new_contents; 1447 return new_contents;
1407 } 1448 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/external_tab_container_win.h ('k') | chrome_frame/test/data/window_open.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698