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

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

Issue 10867096: Make HWNDMessageHandler subclass WindowImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "grit/locale_settings.h" 59 #include "grit/locale_settings.h"
60 #include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h " 60 #include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h "
61 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 61 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
62 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 62 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
64 #include "ui/base/l10n/l10n_util.h" 64 #include "ui/base/l10n/l10n_util.h"
65 #include "ui/base/models/menu_model.h" 65 #include "ui/base/models/menu_model.h"
66 #include "ui/base/view_prop.h" 66 #include "ui/base/view_prop.h"
67 #include "ui/views/controls/webview/webview.h" 67 #include "ui/views/controls/webview/webview.h"
68 #include "ui/views/layout/grid_layout.h" 68 #include "ui/views/layout/grid_layout.h"
69 #include "ui/views/win/hwnd_message_handler.h"
69 70
70 using content::BrowserThread; 71 using content::BrowserThread;
71 using content::LoadNotificationDetails; 72 using content::LoadNotificationDetails;
72 using content::NativeWebKeyboardEvent; 73 using content::NativeWebKeyboardEvent;
73 using content::NavigationController; 74 using content::NavigationController;
74 using content::NavigationEntry; 75 using content::NavigationEntry;
75 using content::OpenURLParams; 76 using content::OpenURLParams;
76 using content::RenderViewHost; 77 using content::RenderViewHost;
77 using content::SSLStatus; 78 using content::SSLStatus;
78 using content::WebContents; 79 using content::WebContents;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 HWND parent, 158 HWND parent,
158 const gfx::Rect& bounds, 159 const gfx::Rect& bounds,
159 DWORD style, 160 DWORD style,
160 bool load_requests_via_automation, 161 bool load_requests_via_automation,
161 bool handle_top_level_requests, 162 bool handle_top_level_requests,
162 TabContents* existing_contents, 163 TabContents* existing_contents,
163 const GURL& initial_url, 164 const GURL& initial_url,
164 const GURL& referrer, 165 const GURL& referrer,
165 bool infobars_enabled, 166 bool infobars_enabled,
166 bool route_all_top_level_navigations) { 167 bool route_all_top_level_navigations) {
167 if (IsWindow()) { 168 if (IsWindow(GetNativeView())) {
168 NOTREACHED(); 169 NOTREACHED();
169 return false; 170 return false;
170 } 171 }
171 172
172 load_requests_via_automation_ = load_requests_via_automation; 173 load_requests_via_automation_ = load_requests_via_automation;
173 handle_top_level_requests_ = handle_top_level_requests; 174 handle_top_level_requests_ = handle_top_level_requests;
174 route_all_top_level_navigations_ = route_all_top_level_navigations; 175 route_all_top_level_navigations_ = route_all_top_level_navigations;
175 176
176 set_window_style(WS_POPUP | WS_CLIPCHILDREN); 177 GetMessageHandler()->set_window_style(WS_POPUP | WS_CLIPCHILDREN);
177 178
178 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 179 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
179 params.bounds = bounds; 180 params.bounds = bounds;
180 params.native_widget = this; 181 params.native_widget = this;
181 GetWidget()->Init(params); 182 GetWidget()->Init(params);
182 if (!IsWindow()) { 183 if (!IsWindow(GetNativeView())) {
183 NOTREACHED(); 184 NOTREACHED();
184 return false; 185 return false;
185 } 186 }
186 187
187 // TODO(jcampan): limit focus traversal to contents. 188 // TODO(jcampan): limit focus traversal to contents.
188 189
189 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this)); 190 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this));
190 191
191 if (existing_contents) { 192 if (existing_contents) {
192 tab_contents_.reset(existing_contents); 193 tab_contents_.reset(existing_contents);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 weak_factory_.GetWeakPtr(), 237 weak_factory_.GetWeakPtr(),
237 initial_url, referrer)); 238 initial_url, referrer));
238 } 239 }
239 240
240 // We need WS_POPUP to be on the window during initialization, but 241 // We need WS_POPUP to be on the window during initialization, but
241 // once initialized we apply the requested style which may or may not 242 // once initialized we apply the requested style which may or may not
242 // include the popup bit. 243 // include the popup bit.
243 // Note that it's important to do this before we call SetParent since 244 // Note that it's important to do this before we call SetParent since
244 // during the SetParent call we will otherwise get a WA_ACTIVATE call 245 // during the SetParent call we will otherwise get a WA_ACTIVATE call
245 // that causes us to steal the current focus. 246 // that causes us to steal the current focus.
246 SetWindowLong(GWL_STYLE, (GetWindowLong(GWL_STYLE) & ~WS_POPUP) | style); 247 SetWindowLong(GetNativeView(), GWL_STYLE,
248 (GetWindowLong(GetNativeView(), GWL_STYLE) & ~WS_POPUP) | style);
247 249
248 // Now apply the parenting and style 250 // Now apply the parenting and style
249 if (parent) 251 if (parent)
250 SetParent(GetNativeView(), parent); 252 SetParent(GetNativeView(), parent);
251 253
252 ::ShowWindow(tab_contents_->web_contents()->GetNativeView(), SW_SHOWNA); 254 ::ShowWindow(tab_contents_->web_contents()->GetNativeView(), SW_SHOWNA);
253 255
254 LoadAccelerators(); 256 LoadAccelerators();
255 SetupExternalTabView(); 257 SetupExternalTabView();
256 tab_contents_->blocked_content_tab_helper()->set_delegate(this); 258 tab_contents_->blocked_content_tab_helper()->set_delegate(this);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 string16 url_string = CA2W(url.spec().c_str()); 586 string16 url_string = CA2W(url.spec().c_str());
585 automation_->Send( 587 automation_->Send(
586 new AutomationMsg_UpdateTargetUrl(tab_handle_, url_string)); 588 new AutomationMsg_UpdateTargetUrl(tab_handle_, url_string));
587 } 589 }
588 } 590 }
589 591
590 void ExternalTabContainerWin::ContentsZoomChange(bool zoom_in) { 592 void ExternalTabContainerWin::ContentsZoomChange(bool zoom_in) {
591 } 593 }
592 594
593 gfx::NativeWindow ExternalTabContainerWin::GetFrameNativeWindow() { 595 gfx::NativeWindow ExternalTabContainerWin::GetFrameNativeWindow() {
594 return hwnd(); 596 return GetNativeView();
595 } 597 }
596 598
597 bool ExternalTabContainerWin::TakeFocus(content::WebContents* source, 599 bool ExternalTabContainerWin::TakeFocus(content::WebContents* source,
598 bool reverse) { 600 bool reverse) {
599 if (automation_) { 601 if (automation_) {
600 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, 602 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_,
601 base::win::IsShiftPressed())); 603 base::win::IsShiftPressed()));
602 } 604 }
603 605
604 return true; 606 return true;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 break; 938 break;
937 } 939 }
938 default: 940 default:
939 NOTREACHED(); 941 NOTREACHED();
940 } 942 }
941 } 943 }
942 944
943 //////////////////////////////////////////////////////////////////////////////// 945 ////////////////////////////////////////////////////////////////////////////////
944 // ExternalTabContainer, views::NativeWidgetWin overrides: 946 // ExternalTabContainer, views::NativeWidgetWin overrides:
945 947
946 LRESULT ExternalTabContainerWin::OnCreate(LPCREATESTRUCT create_struct) { 948 void ExternalTabContainerWin::HandleCreate() {
947 LRESULT result = views::NativeWidgetWin::OnCreate(create_struct); 949 views::NativeWidgetWin::HandleCreate();
948 if (result == 0) { 950 // Grab a reference here which will be released in OnFinalMessage
949 // Grab a reference here which will be released in OnFinalMessage 951 AddRef();
950 AddRef();
951 }
952 return result;
953 } 952 }
954 953
955 void ExternalTabContainerWin::OnDestroy() { 954 void ExternalTabContainerWin::HandleDestroying() {
956 prop_.reset(); 955 prop_.reset();
957 Uninitialize(); 956 Uninitialize();
958 NativeWidgetWin::OnDestroy(); 957 NativeWidgetWin::HandleDestroying();
959 } 958 }
960 959
961 void ExternalTabContainerWin::OnFinalMessage(HWND window) { 960 void ExternalTabContainerWin::OnFinalMessage(HWND window) {
962 GetWidget()->OnNativeWidgetDestroyed(); 961 GetWidget()->OnNativeWidgetDestroyed();
963 // Release the reference which we grabbed in WM_CREATE. 962 // Release the reference which we grabbed in WM_CREATE.
964 Release(); 963 Release();
965 } 964 }
966 965
967 //////////////////////////////////////////////////////////////////////////////// 966 ////////////////////////////////////////////////////////////////////////////////
968 // ExternalTabContainer, private: 967 // ExternalTabContainer, private:
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 if (params.disposition == CURRENT_TAB) { 1254 if (params.disposition == CURRENT_TAB) {
1256 DCHECK(route_all_top_level_navigations_); 1255 DCHECK(route_all_top_level_navigations_);
1257 forward_params.disposition = NEW_FOREGROUND_TAB; 1256 forward_params.disposition = NEW_FOREGROUND_TAB;
1258 } 1257 }
1259 WebContents* new_contents = 1258 WebContents* new_contents =
1260 ExternalTabContainerWin::OpenURLFromTab(source, forward_params); 1259 ExternalTabContainerWin::OpenURLFromTab(source, forward_params);
1261 // support only one navigation for a dummy tab before it is killed. 1260 // support only one navigation for a dummy tab before it is killed.
1262 ::DestroyWindow(GetNativeView()); 1261 ::DestroyWindow(GetNativeView());
1263 return new_contents; 1262 return new_contents;
1264 } 1263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698