| 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/win_util.h" | 8 #include "app/win_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/win_util.h" | 10 #include "base/win_util.h" |
| 11 #include "chrome/browser/automation/automation_provider.h" | 11 #include "chrome/browser/automation/automation_provider.h" |
| 12 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
| 13 #include "chrome/browser/extensions/extension_function_dispatcher.h" | |
| 14 #include "chrome/browser/load_notification_details.h" | 13 #include "chrome/browser/load_notification_details.h" |
| 15 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
| 16 #include "chrome/browser/tab_contents/provisional_load_details.h" | 15 #include "chrome/browser/tab_contents/provisional_load_details.h" |
| 17 #include "chrome/browser/views/tab_contents/render_view_context_menu_external_wi
n.h" | 16 #include "chrome/browser/views/tab_contents/render_view_context_menu_external_wi
n.h" |
| 18 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
| 19 #include "chrome/browser/views/tab_contents/tab_contents_container.h" | 18 #include "chrome/browser/views/tab_contents/tab_contents_container.h" |
| 19 #include "chrome/common/bindings_policy.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/notification_service.h" | 21 #include "chrome/common/notification_service.h" |
| 22 #include "chrome/test/automation/automation_messages.h" | 22 #include "chrome/test/automation/automation_messages.h" |
| 23 | 23 |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 | 25 |
| 26 static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject"; | 26 static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject"; |
| 27 | 27 |
| 28 // TODO(sanjeevr): The external_accel_table_ and external_accel_entry_count_ | 28 // TODO(sanjeevr): The external_accel_table_ and external_accel_entry_count_ |
| 29 // member variables are now obsolete and we don't use them. | 29 // member variables are now obsolete and we don't use them. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| 61 // TODO(jcampan): limit focus traversal to contents. | 61 // TODO(jcampan): limit focus traversal to contents. |
| 62 | 62 |
| 63 // We don't ever remove the prop because the lifetime of this object | 63 // We don't ever remove the prop because the lifetime of this object |
| 64 // is the same as the lifetime of the window | 64 // is the same as the lifetime of the window |
| 65 SetProp(GetNativeView(), kWindowObjectKey, this); | 65 SetProp(GetNativeView(), kWindowObjectKey, this); |
| 66 | 66 |
| 67 tab_contents_ = new TabContents(profile, NULL, MSG_ROUTING_NONE, NULL); | 67 tab_contents_ = new TabContents(profile, NULL, MSG_ROUTING_NONE, NULL); |
| 68 tab_contents_->set_delegate(this); | 68 tab_contents_->set_delegate(this); |
| 69 tab_contents_->render_view_host()->AllowExternalHostBindings(); | 69 tab_contents_->render_view_host()->AllowBindings( |
| 70 BindingsPolicy::EXTERNAL_HOST); |
| 70 | 71 |
| 71 // Create a TabContentsContainer to handle focus cycling using Tab and | 72 // Create a TabContentsContainer to handle focus cycling using Tab and |
| 72 // Shift-Tab. | 73 // Shift-Tab. |
| 73 tab_contents_container_ = new TabContentsContainer; | 74 tab_contents_container_ = new TabContentsContainer; |
| 74 SetContentsView(tab_contents_container_); | 75 SetContentsView(tab_contents_container_); |
| 75 | 76 |
| 76 // Note that SetTabContents must be called after AddChildView is called | 77 // Note that SetTabContents must be called after AddChildView is called |
| 77 tab_contents_container_->ChangeTabContents(tab_contents_); | 78 tab_contents_container_->ChangeTabContents(tab_contents_); |
| 78 | 79 |
| 79 NavigationController* controller = &tab_contents_->controller(); | 80 NavigationController* controller = &tab_contents_->controller(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 void ExternalTabContainer::ForwardMessageToExternalHost( | 240 void ExternalTabContainer::ForwardMessageToExternalHost( |
| 240 const std::string& message, const std::string& origin, | 241 const std::string& message, const std::string& origin, |
| 241 const std::string& target) { | 242 const std::string& target) { |
| 242 if(automation_) { | 243 if(automation_) { |
| 243 automation_->Send( | 244 automation_->Send( |
| 244 new AutomationMsg_ForwardMessageToExternalHost(0, tab_handle_, | 245 new AutomationMsg_ForwardMessageToExternalHost(0, tab_handle_, |
| 245 message, origin, target)); | 246 message, origin, target)); |
| 246 } | 247 } |
| 247 } | 248 } |
| 248 | 249 |
| 249 ExtensionFunctionDispatcher* ExternalTabContainer:: | |
| 250 CreateExtensionFunctionDispatcher(RenderViewHost* render_view_host, | |
| 251 const std::string& extension_id) { | |
| 252 return new ExtensionFunctionDispatcher(render_view_host, NULL, extension_id); | |
| 253 } | |
| 254 | |
| 255 bool ExternalTabContainer::TakeFocus(bool reverse) { | 250 bool ExternalTabContainer::TakeFocus(bool reverse) { |
| 256 if (automation_) { | 251 if (automation_) { |
| 257 automation_->Send(new AutomationMsg_TabbedOut(0, tab_handle_, | 252 automation_->Send(new AutomationMsg_TabbedOut(0, tab_handle_, |
| 258 win_util::IsShiftPressed())); | 253 win_util::IsShiftPressed())); |
| 259 } | 254 } |
| 260 | 255 |
| 261 return true; | 256 return true; |
| 262 } | 257 } |
| 263 | 258 |
| 264 bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) { | 259 bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (tab_contents_) { | 408 if (tab_contents_) { |
| 414 NotificationService::current()->Notify( | 409 NotificationService::current()->Notify( |
| 415 NotificationType::EXTERNAL_TAB_CLOSED, | 410 NotificationType::EXTERNAL_TAB_CLOSED, |
| 416 Source<NavigationController>(&tab_contents_->controller()), | 411 Source<NavigationController>(&tab_contents_->controller()), |
| 417 Details<ExternalTabContainer>(this)); | 412 Details<ExternalTabContainer>(this)); |
| 418 | 413 |
| 419 delete tab_contents_; | 414 delete tab_contents_; |
| 420 tab_contents_ = NULL; | 415 tab_contents_ = NULL; |
| 421 } | 416 } |
| 422 } | 417 } |
| OLD | NEW |