OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/view_prop.h" | 10 #include "app/win/scoped_prop.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/win_util.h" | 14 #include "base/win_util.h" |
15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
16 #include "chrome/app/chrome_dll_resource.h" | 16 #include "chrome/app/chrome_dll_resource.h" |
17 #include "chrome/browser/automation/automation_provider.h" | 17 #include "chrome/browser/automation/automation_provider.h" |
18 #include "chrome/browser/automation/automation_extension_function.h" | 18 #include "chrome/browser/automation/automation_extension_function.h" |
19 #include "chrome/browser/browser_window.h" | 19 #include "chrome/browser/browser_window.h" |
20 #include "chrome/browser/debugger/devtools_manager.h" | 20 #include "chrome/browser/debugger/devtools_manager.h" |
(...skipping 19 matching lines...) Expand all Loading... |
40 #include "chrome/common/native_web_keyboard_event.h" | 40 #include "chrome/common/native_web_keyboard_event.h" |
41 #include "chrome/common/notification_service.h" | 41 #include "chrome/common/notification_service.h" |
42 #include "chrome/common/page_transition_types.h" | 42 #include "chrome/common/page_transition_types.h" |
43 #include "chrome/common/url_constants.h" | 43 #include "chrome/common/url_constants.h" |
44 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
45 #include "grit/locale_settings.h" | 45 #include "grit/locale_settings.h" |
46 #include "views/grid_layout.h" | 46 #include "views/grid_layout.h" |
47 #include "views/widget/root_view.h" | 47 #include "views/widget/root_view.h" |
48 #include "views/window/window.h" | 48 #include "views/window/window.h" |
49 | 49 |
50 using app::ViewProp; | 50 static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject"; |
51 | |
52 static const char kWindowObjectKey[] = "ChromeWindowObject"; | |
53 | 51 |
54 // This class overrides the LinkActivated function in the PageInfoBubbleView | 52 // This class overrides the LinkActivated function in the PageInfoBubbleView |
55 // class and routes the help center link navigation to the host browser. | 53 // class and routes the help center link navigation to the host browser. |
56 class ExternalTabPageInfoBubbleView : public PageInfoBubbleView { | 54 class ExternalTabPageInfoBubbleView : public PageInfoBubbleView { |
57 public: | 55 public: |
58 ExternalTabPageInfoBubbleView(ExternalTabContainer* container, | 56 ExternalTabPageInfoBubbleView(ExternalTabContainer* container, |
59 gfx::NativeWindow parent_window, | 57 gfx::NativeWindow parent_window, |
60 Profile* profile, | 58 Profile* profile, |
61 const GURL& url, | 59 const GURL& url, |
62 const NavigationEntry::SSLStatus& ssl, | 60 const NavigationEntry::SSLStatus& ssl, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 127 |
130 set_window_style(WS_POPUP | WS_CLIPCHILDREN); | 128 set_window_style(WS_POPUP | WS_CLIPCHILDREN); |
131 views::WidgetWin::Init(NULL, bounds); | 129 views::WidgetWin::Init(NULL, bounds); |
132 if (!IsWindow()) { | 130 if (!IsWindow()) { |
133 NOTREACHED(); | 131 NOTREACHED(); |
134 return false; | 132 return false; |
135 } | 133 } |
136 | 134 |
137 // TODO(jcampan): limit focus traversal to contents. | 135 // TODO(jcampan): limit focus traversal to contents. |
138 | 136 |
139 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this)); | 137 prop_.reset( |
| 138 new app::win::ScopedProp(GetNativeView(), kWindowObjectKey, this)); |
140 | 139 |
141 if (existing_contents) { | 140 if (existing_contents) { |
142 tab_contents_ = existing_contents; | 141 tab_contents_ = existing_contents; |
143 tab_contents_->controller().set_profile(profile); | 142 tab_contents_->controller().set_profile(profile); |
144 } else { | 143 } else { |
145 tab_contents_ = new TabContents(profile, NULL, MSG_ROUTING_NONE, | 144 tab_contents_ = new TabContents(profile, NULL, MSG_ROUTING_NONE, |
146 NULL, NULL); | 145 NULL, NULL); |
147 } | 146 } |
148 | 147 |
149 tab_contents_->set_delegate(this); | 148 tab_contents_->set_delegate(this); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // The tab_contents_ member can get destroyed in the context of the call to | 277 // The tab_contents_ member can get destroyed in the context of the call to |
279 // TabContentsViewWin::Focus() above. This method eventually calls SetFocus | 278 // TabContentsViewWin::Focus() above. This method eventually calls SetFocus |
280 // on the native window, which could end up dispatching messages like | 279 // on the native window, which could end up dispatching messages like |
281 // WM_DESTROY for the external tab. | 280 // WM_DESTROY for the external tab. |
282 if (tab_contents_ && restore_focus_to_view) | 281 if (tab_contents_ && restore_focus_to_view) |
283 tab_contents_->FocusThroughTabTraversal(reverse); | 282 tab_contents_->FocusThroughTabTraversal(reverse); |
284 } | 283 } |
285 | 284 |
286 // static | 285 // static |
287 bool ExternalTabContainer::IsExternalTabContainer(HWND window) { | 286 bool ExternalTabContainer::IsExternalTabContainer(HWND window) { |
288 return ViewProp::GetValue(window, kWindowObjectKey) != NULL; | 287 if (::GetProp(window, kWindowObjectKey) != NULL) |
| 288 return true; |
| 289 |
| 290 return false; |
289 } | 291 } |
290 | 292 |
291 // static | 293 // static |
292 ExternalTabContainer* ExternalTabContainer::GetContainerForTab( | 294 ExternalTabContainer* ExternalTabContainer::GetContainerForTab( |
293 HWND tab_window) { | 295 HWND tab_window) { |
294 HWND parent_window = ::GetParent(tab_window); | 296 HWND parent_window = ::GetParent(tab_window); |
295 if (!::IsWindow(parent_window)) { | 297 if (!::IsWindow(parent_window)) { |
296 return NULL; | 298 return NULL; |
297 } | 299 } |
298 if (!IsExternalTabContainer(parent_window)) { | 300 if (!IsExternalTabContainer(parent_window)) { |
299 return NULL; | 301 return NULL; |
300 } | 302 } |
301 ExternalTabContainer* container = reinterpret_cast<ExternalTabContainer*>( | 303 ExternalTabContainer* container = reinterpret_cast<ExternalTabContainer*>( |
302 ViewProp::GetValue(parent_window, kWindowObjectKey)); | 304 GetProp(parent_window, kWindowObjectKey)); |
303 return container; | 305 return container; |
304 } | 306 } |
305 | 307 |
306 // static | 308 // static |
307 ExternalTabContainer* | 309 ExternalTabContainer* |
308 ExternalTabContainer::GetExternalContainerFromNativeWindow( | 310 ExternalTabContainer::GetExternalContainerFromNativeWindow( |
309 gfx::NativeView native_window) { | 311 gfx::NativeView native_window) { |
310 ExternalTabContainer* tab_container = NULL; | 312 ExternalTabContainer* tab_container = NULL; |
311 if (native_window) { | 313 if (native_window) { |
312 tab_container = reinterpret_cast<ExternalTabContainer*>( | 314 HANDLE handle = ::GetProp(native_window, kWindowObjectKey); |
313 ViewProp::GetValue(native_window, kWindowObjectKey)); | 315 tab_container = reinterpret_cast<ExternalTabContainer*>(handle); |
314 } | 316 } |
315 return tab_container; | 317 return tab_container; |
316 } | 318 } |
317 //////////////////////////////////////////////////////////////////////////////// | 319 //////////////////////////////////////////////////////////////////////////////// |
318 // ExternalTabContainer, TabContentsDelegate implementation: | 320 // ExternalTabContainer, TabContentsDelegate implementation: |
319 | 321 |
320 void ExternalTabContainer::OpenURLFromTab(TabContents* source, | 322 void ExternalTabContainer::OpenURLFromTab(TabContents* source, |
321 const GURL& url, | 323 const GURL& url, |
322 const GURL& referrer, | 324 const GURL& referrer, |
323 WindowOpenDisposition disposition, | 325 WindowOpenDisposition disposition, |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 | 1108 |
1107 if (disposition == CURRENT_TAB) { | 1109 if (disposition == CURRENT_TAB) { |
1108 DCHECK(route_all_top_level_navigations_); | 1110 DCHECK(route_all_top_level_navigations_); |
1109 disposition = NEW_FOREGROUND_TAB; | 1111 disposition = NEW_FOREGROUND_TAB; |
1110 } | 1112 } |
1111 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, | 1113 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, |
1112 transition); | 1114 transition); |
1113 // support only one navigation for a dummy tab before it is killed. | 1115 // support only one navigation for a dummy tab before it is killed. |
1114 ::DestroyWindow(GetNativeView()); | 1116 ::DestroyWindow(GetNativeView()); |
1115 } | 1117 } |
OLD | NEW |