| 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/extensions/extension_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "app/keyboard_codes.h" | 9 #include "app/keyboard_codes.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 view_->Init(); | 170 view_->Init(); |
| 171 #elif defined(TOOLKIT_USES_GTK) | 171 #elif defined(TOOLKIT_USES_GTK) |
| 172 view_.reset(new ExtensionViewGtk(this, browser)); | 172 view_.reset(new ExtensionViewGtk(this, browser)); |
| 173 view_->Init(); | 173 view_->Init(); |
| 174 #else | 174 #else |
| 175 // TODO(port) | 175 // TODO(port) |
| 176 NOTREACHED(); | 176 NOTREACHED(); |
| 177 #endif | 177 #endif |
| 178 } | 178 } |
| 179 | 179 |
| 180 TabContents* ExtensionHost::associated_tab_contents() const { |
| 181 return associated_tab_contents_; |
| 182 } |
| 183 |
| 180 RenderProcessHost* ExtensionHost::render_process_host() const { | 184 RenderProcessHost* ExtensionHost::render_process_host() const { |
| 181 return render_view_host_->process(); | 185 return render_view_host_->process(); |
| 182 } | 186 } |
| 183 | 187 |
| 184 SiteInstance* ExtensionHost::site_instance() const { | 188 SiteInstance* ExtensionHost::site_instance() const { |
| 185 return render_view_host_->site_instance(); | 189 return render_view_host_->site_instance(); |
| 186 } | 190 } |
| 187 | 191 |
| 188 bool ExtensionHost::IsRenderViewLive() const { | 192 bool ExtensionHost::IsRenderViewLive() const { |
| 189 return render_view_host_->IsRenderViewLive(); | 193 return render_view_host_->IsRenderViewLive(); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 Browser* browser = extension_function_dispatcher_->GetCurrentBrowser(true); | 441 Browser* browser = extension_function_dispatcher_->GetCurrentBrowser(true); |
| 438 if (browser) { | 442 if (browser) { |
| 439 TabContents* active_tab = browser->GetSelectedTabContents(); | 443 TabContents* active_tab = browser->GetSelectedTabContents(); |
| 440 if (active_tab) | 444 if (active_tab) |
| 441 return active_tab->view()->GetTopLevelNativeWindow(); | 445 return active_tab->view()->GetTopLevelNativeWindow(); |
| 442 } | 446 } |
| 443 | 447 |
| 444 return NULL; | 448 return NULL; |
| 445 } | 449 } |
| 446 | 450 |
| 451 TabContents* ExtensionHost::AsTabContents() { |
| 452 return NULL; |
| 453 } |
| 454 |
| 455 ExtensionHost* ExtensionHost::AsExtensionHost() { |
| 456 return this; |
| 457 } |
| 458 |
| 447 void ExtensionHost::OnMessageBoxClosed(IPC::Message* reply_msg, | 459 void ExtensionHost::OnMessageBoxClosed(IPC::Message* reply_msg, |
| 448 bool success, | 460 bool success, |
| 449 const std::wstring& prompt) { | 461 const std::wstring& prompt) { |
| 450 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt); | 462 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt); |
| 451 } | 463 } |
| 452 | 464 |
| 453 void ExtensionHost::Close(RenderViewHost* render_view_host) { | 465 void ExtensionHost::Close(RenderViewHost* render_view_host) { |
| 454 if (extension_host_type_ == ViewType::EXTENSION_POPUP || | 466 if (extension_host_type_ == ViewType::EXTENSION_POPUP || |
| 455 extension_host_type_ == ViewType::EXTENSION_INFOBAR) { | 467 extension_host_type_ == ViewType::EXTENSION_INFOBAR) { |
| 456 NotificationService::current()->Notify( | 468 NotificationService::current()->Notify( |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 void ExtensionHost::HandleMouseUp() { | 747 void ExtensionHost::HandleMouseUp() { |
| 736 } | 748 } |
| 737 | 749 |
| 738 void ExtensionHost::HandleMouseActivate() { | 750 void ExtensionHost::HandleMouseActivate() { |
| 739 } | 751 } |
| 740 | 752 |
| 741 ViewType::Type ExtensionHost::GetRenderViewType() const { | 753 ViewType::Type ExtensionHost::GetRenderViewType() const { |
| 742 return extension_host_type_; | 754 return extension_host_type_; |
| 743 } | 755 } |
| 744 | 756 |
| 757 const GURL& ExtensionHost::GetURL() const { |
| 758 return url_; |
| 759 } |
| 760 |
| 745 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 761 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
| 746 if (view_.get()) | 762 if (view_.get()) |
| 747 view_->RenderViewCreated(); | 763 view_->RenderViewCreated(); |
| 748 | 764 |
| 749 // TODO(mpcomplete): This is duplicated in DidNavigate, which means that | 765 // TODO(mpcomplete): This is duplicated in DidNavigate, which means that |
| 750 // we'll create 2 EFDs for the first navigation. We should try to find a | 766 // we'll create 2 EFDs for the first navigation. We should try to find a |
| 751 // better way to unify them. | 767 // better way to unify them. |
| 752 // See http://code.google.com/p/chromium/issues/detail?id=18240 | 768 // See http://code.google.com/p/chromium/issues/detail?id=18240 |
| 753 extension_function_dispatcher_.reset( | 769 extension_function_dispatcher_.reset( |
| 754 ExtensionFunctionDispatcher::Create(render_view_host, this, url_)); | 770 ExtensionFunctionDispatcher::Create(render_view_host, this, url_)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 776 // Extensions hosted in ExternalTabContainer objects may not have | 792 // Extensions hosted in ExternalTabContainer objects may not have |
| 777 // an associated browser. | 793 // an associated browser. |
| 778 Browser* browser = GetBrowser(); | 794 Browser* browser = GetBrowser(); |
| 779 if (browser) | 795 if (browser) |
| 780 window_id = ExtensionTabUtil::GetWindowId(browser); | 796 window_id = ExtensionTabUtil::GetWindowId(browser); |
| 781 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { | 797 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { |
| 782 NOTREACHED(); | 798 NOTREACHED(); |
| 783 } | 799 } |
| 784 return window_id; | 800 return window_id; |
| 785 } | 801 } |
| OLD | NEW |