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