| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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.h" | 5 #include "chrome/browser/external_tab_container.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/win_util.h" | 8 #include "base/win_util.h" |
| 9 #include "chrome/browser/automation/automation_provider.h" | 9 #include "chrome/browser/automation/automation_provider.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| 11 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 11 #include "chrome/browser/load_notification_details.h" | 12 #include "chrome/browser/load_notification_details.h" |
| 12 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
| 13 #include "chrome/browser/tab_contents/provisional_load_details.h" | 14 #include "chrome/browser/tab_contents/provisional_load_details.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
| 15 #include "chrome/browser/views/tab_contents_container_view.h" | 16 #include "chrome/browser/views/tab_contents_container_view.h" |
| 16 #include "chrome/browser/tab_contents/web_contents.h" | 17 #include "chrome/browser/tab_contents/web_contents.h" |
| 17 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 18 #include "chrome/common/win_util.h" | 19 #include "chrome/common/win_util.h" |
| 19 // Included for SetRootViewForHWND. | 20 // Included for SetRootViewForHWND. |
| 20 #include "chrome/views/widget/widget_win.h" | 21 #include "chrome/views/widget/widget_win.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 case SINGLETON_TAB: | 156 case SINGLETON_TAB: |
| 156 case NEW_FOREGROUND_TAB: | 157 case NEW_FOREGROUND_TAB: |
| 157 case NEW_BACKGROUND_TAB: | 158 case NEW_BACKGROUND_TAB: |
| 158 case NEW_WINDOW: | 159 case NEW_WINDOW: |
| 159 if (automation_) { | 160 if (automation_) { |
| 160 automation_->Send(new AutomationMsg_OpenURL(0, url, disposition)); | 161 automation_->Send(new AutomationMsg_OpenURL(0, url, disposition)); |
| 161 } | 162 } |
| 162 break; | 163 break; |
| 163 default: | 164 default: |
| 164 break; | 165 break; |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 | 168 |
| 168 void ExternalTabContainer::NavigationStateChanged(const TabContents* source, | 169 void ExternalTabContainer::NavigationStateChanged(const TabContents* source, |
| 169 unsigned changed_flags) { | 170 unsigned changed_flags) { |
| 170 if (automation_) { | 171 if (automation_) { |
| 171 automation_->Send( | 172 automation_->Send( |
| 172 new AutomationMsg_NavigationStateChanged(0, changed_flags)); | 173 new AutomationMsg_NavigationStateChanged(0, changed_flags)); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 | 176 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 static_cast<TabContents*>(tab_contents_)->SetInitialFocus(reverse); | 392 static_cast<TabContents*>(tab_contents_)->SetInitialFocus(reverse); |
| 392 } | 393 } |
| 393 } | 394 } |
| 394 | 395 |
| 395 // static | 396 // static |
| 396 bool ExternalTabContainer::IsExternalTabContainer(HWND window) { | 397 bool ExternalTabContainer::IsExternalTabContainer(HWND window) { |
| 397 std::wstring class_name = win_util::GetClassName(window); | 398 std::wstring class_name = win_util::GetClassName(window); |
| 398 return _wcsicmp(class_name.c_str(), chrome::kExternalTabWindowClass) == 0; | 399 return _wcsicmp(class_name.c_str(), chrome::kExternalTabWindowClass) == 0; |
| 399 } | 400 } |
| 400 | 401 |
| 402 ExtensionFunctionDispatcher* ExternalTabContainer:: |
| 403 CreateExtensionFunctionDispatcher(RenderViewHost* render_view_host, |
| 404 const std::string& extension_id) { |
| 405 return new ExtensionFunctionDispatcher(render_view_host, NULL, extension_id); |
| 406 } |
| 407 |
| 401 // static | 408 // static |
| 402 ExternalTabContainer* ExternalTabContainer::GetContainerForTab( | 409 ExternalTabContainer* ExternalTabContainer::GetContainerForTab( |
| 403 HWND tab_window) { | 410 HWND tab_window) { |
| 404 HWND parent_window = ::GetParent(tab_window); | 411 HWND parent_window = ::GetParent(tab_window); |
| 405 if (!::IsWindow(parent_window)) { | 412 if (!::IsWindow(parent_window)) { |
| 406 return NULL; | 413 return NULL; |
| 407 } | 414 } |
| 408 if (!IsExternalTabContainer(parent_window)) { | 415 if (!IsExternalTabContainer(parent_window)) { |
| 409 return NULL; | 416 return NULL; |
| 410 } | 417 } |
| 411 ExternalTabContainer* container = reinterpret_cast<ExternalTabContainer*>( | 418 ExternalTabContainer* container = reinterpret_cast<ExternalTabContainer*>( |
| 412 GetProp(parent_window, kWindowObjectKey)); | 419 GetProp(parent_window, kWindowObjectKey)); |
| 413 return container; | 420 return container; |
| 414 } | 421 } |
| OLD | NEW |