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

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

Issue 10892014: 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 HWND parent, 157 HWND parent,
158 const gfx::Rect& bounds, 158 const gfx::Rect& bounds,
159 DWORD style, 159 DWORD style,
160 bool load_requests_via_automation, 160 bool load_requests_via_automation,
161 bool handle_top_level_requests, 161 bool handle_top_level_requests,
162 TabContents* existing_contents, 162 TabContents* existing_contents,
163 const GURL& initial_url, 163 const GURL& initial_url,
164 const GURL& referrer, 164 const GURL& referrer,
165 bool infobars_enabled, 165 bool infobars_enabled,
166 bool route_all_top_level_navigations) { 166 bool route_all_top_level_navigations) {
167 if (IsWindow()) { 167 if (IsWindow(GetNativeView())) {
168 NOTREACHED(); 168 NOTREACHED();
169 return false; 169 return false;
170 } 170 }
171 171
172 load_requests_via_automation_ = load_requests_via_automation; 172 load_requests_via_automation_ = load_requests_via_automation;
173 handle_top_level_requests_ = handle_top_level_requests; 173 handle_top_level_requests_ = handle_top_level_requests;
174 route_all_top_level_navigations_ = route_all_top_level_navigations; 174 route_all_top_level_navigations_ = route_all_top_level_navigations;
175 175
176 set_window_style(WS_POPUP | WS_CLIPCHILDREN); 176 set_window_style(WS_POPUP | WS_CLIPCHILDREN);
177 177
178 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 178 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
179 params.bounds = bounds; 179 params.bounds = bounds;
180 params.native_widget = this; 180 params.native_widget = this;
181 GetWidget()->Init(params); 181 GetWidget()->Init(params);
182 if (!IsWindow()) { 182 if (!IsWindow(GetNativeView())) {
183 NOTREACHED(); 183 NOTREACHED();
184 return false; 184 return false;
185 } 185 }
186 186
187 // TODO(jcampan): limit focus traversal to contents. 187 // TODO(jcampan): limit focus traversal to contents.
188 188
189 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this)); 189 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this));
190 190
191 if (existing_contents) { 191 if (existing_contents) {
192 tab_contents_.reset(existing_contents); 192 tab_contents_.reset(existing_contents);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 weak_factory_.GetWeakPtr(), 236 weak_factory_.GetWeakPtr(),
237 initial_url, referrer)); 237 initial_url, referrer));
238 } 238 }
239 239
240 // We need WS_POPUP to be on the window during initialization, but 240 // 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 241 // once initialized we apply the requested style which may or may not
242 // include the popup bit. 242 // include the popup bit.
243 // Note that it's important to do this before we call SetParent since 243 // 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 244 // during the SetParent call we will otherwise get a WA_ACTIVATE call
245 // that causes us to steal the current focus. 245 // that causes us to steal the current focus.
246 SetWindowLong(GWL_STYLE, (GetWindowLong(GWL_STYLE) & ~WS_POPUP) | style); 246 SetWindowLong(
247 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 679 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 bool ExternalTabContainerWin::PreHandleMSG(UINT message,
947 LRESULT result = views::NativeWidgetWin::OnCreate(create_struct); 949 WPARAM w_param,
948 if (result == 0) { 950 LPARAM l_param,
949 // Grab a reference here which will be released in OnFinalMessage 951 LRESULT* result) {
950 AddRef(); 952 if (message == WM_DESTROY) {
953 prop_.reset();
954 Uninitialize();
951 } 955 }
952 return result; 956 return false;
953 } 957 }
954 958
955 void ExternalTabContainerWin::OnDestroy() { 959 void ExternalTabContainerWin::PostHandleMSG(UINT message,
956 prop_.reset(); 960 WPARAM w_param,
957 Uninitialize(); 961 LPARAM l_param) {
958 NativeWidgetWin::OnDestroy(); 962 // Grab a reference here which will be released in OnFinalMessage
963 if (message == WM_CREATE)
964 AddRef();
959 } 965 }
960 966
961 void ExternalTabContainerWin::OnFinalMessage(HWND window) { 967 void ExternalTabContainerWin::OnFinalMessage(HWND window) {
962 GetWidget()->OnNativeWidgetDestroyed(); 968 GetWidget()->OnNativeWidgetDestroyed();
963 // Release the reference which we grabbed in WM_CREATE. 969 // Release the reference which we grabbed in WM_CREATE.
964 Release(); 970 Release();
965 } 971 }
966 972
967 //////////////////////////////////////////////////////////////////////////////// 973 ////////////////////////////////////////////////////////////////////////////////
968 // ExternalTabContainer, private: 974 // ExternalTabContainer, private:
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 if (params.disposition == CURRENT_TAB) { 1261 if (params.disposition == CURRENT_TAB) {
1256 DCHECK(route_all_top_level_navigations_); 1262 DCHECK(route_all_top_level_navigations_);
1257 forward_params.disposition = NEW_FOREGROUND_TAB; 1263 forward_params.disposition = NEW_FOREGROUND_TAB;
1258 } 1264 }
1259 WebContents* new_contents = 1265 WebContents* new_contents =
1260 ExternalTabContainerWin::OpenURLFromTab(source, forward_params); 1266 ExternalTabContainerWin::OpenURLFromTab(source, forward_params);
1261 // support only one navigation for a dummy tab before it is killed. 1267 // support only one navigation for a dummy tab before it is killed.
1262 ::DestroyWindow(GetNativeView()); 1268 ::DestroyWindow(GetNativeView());
1263 return new_contents; 1269 return new_contents;
1264 } 1270 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/external_tab_container_win.h ('k') | chrome/browser/ui/views/frame/browser_frame_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698