OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 view_->HandleMouseLeave(); | 576 view_->HandleMouseLeave(); |
577 #endif | 577 #endif |
578 } | 578 } |
579 | 579 |
580 void ExtensionHost::HandleMouseUp() { | 580 void ExtensionHost::HandleMouseUp() { |
581 } | 581 } |
582 | 582 |
583 void ExtensionHost::HandleMouseActivate() { | 583 void ExtensionHost::HandleMouseActivate() { |
584 } | 584 } |
585 | 585 |
| 586 void ExtensionHost::RunFileChooser( |
| 587 RenderViewHost* render_view_host, |
| 588 const ViewHostMsg_RunFileChooser_Params& params) { |
| 589 // This object is destroyed when the file selection is performed or |
| 590 // cancelled. |
| 591 FileSelectHelper* file_select_helper = new FileSelectHelper(profile()); |
| 592 file_select_helper->RunFileChooser(render_view_host, |
| 593 GetAssociatedTabContents(), |
| 594 params); |
| 595 } |
| 596 |
586 void ExtensionHost::CreateNewWindow( | 597 void ExtensionHost::CreateNewWindow( |
587 int route_id, | 598 int route_id, |
588 const ViewHostMsg_CreateWindow_Params& params) { | 599 const ViewHostMsg_CreateWindow_Params& params) { |
589 // TODO(aa): Use the browser's profile if the extension is split mode | 600 // TODO(aa): Use the browser's profile if the extension is split mode |
590 // incognito. | 601 // incognito. |
591 Profile* profile = Profile::FromBrowserContext( | 602 Profile* profile = Profile::FromBrowserContext( |
592 render_view_host()->process()->browser_context()); | 603 render_view_host()->process()->browser_context()); |
593 TabContents* new_contents = delegate_view_helper_.CreateNewWindow( | 604 TabContents* new_contents = delegate_view_helper_.CreateNewWindow( |
594 route_id, | 605 route_id, |
595 profile, | 606 profile, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 void ExtensionHost::TakeFocus(bool reverse) { | 767 void ExtensionHost::TakeFocus(bool reverse) { |
757 } | 768 } |
758 | 769 |
759 ViewType::Type ExtensionHost::GetRenderViewType() const { | 770 ViewType::Type ExtensionHost::GetRenderViewType() const { |
760 return extension_host_type_; | 771 return extension_host_type_; |
761 } | 772 } |
762 | 773 |
763 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { | 774 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { |
764 bool handled = true; | 775 bool handled = true; |
765 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) | 776 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) |
766 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | |
767 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 777 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
768 IPC_MESSAGE_UNHANDLED(handled = false) | 778 IPC_MESSAGE_UNHANDLED(handled = false) |
769 IPC_END_MESSAGE_MAP() | 779 IPC_END_MESSAGE_MAP() |
770 return handled; | 780 return handled; |
771 } | 781 } |
772 | 782 |
773 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 783 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
774 extension_function_dispatcher_.Dispatch(params, render_view_host_); | 784 extension_function_dispatcher_.Dispatch(params, render_view_host_); |
775 } | 785 } |
776 | 786 |
777 const GURL& ExtensionHost::GetURL() const { | 787 const GURL& ExtensionHost::GetURL() const { |
778 return url_; | 788 return url_; |
779 } | 789 } |
780 | 790 |
781 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 791 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
782 if (view_.get()) | 792 if (view_.get()) |
783 view_->RenderViewCreated(); | 793 view_->RenderViewCreated(); |
784 | 794 |
785 if (extension_host_type_ == ViewType::EXTENSION_POPUP || | 795 if (extension_host_type_ == ViewType::EXTENSION_POPUP || |
786 extension_host_type_ == ViewType::EXTENSION_INFOBAR) { | 796 extension_host_type_ == ViewType::EXTENSION_INFOBAR) { |
787 render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( | 797 render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( |
788 render_view_host->routing_id(), | 798 render_view_host->routing_id(), |
789 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow)); | 799 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow)); |
790 } | 800 } |
791 } | 801 } |
792 | |
793 void ExtensionHost::OnRunFileChooser( | |
794 const ViewHostMsg_RunFileChooser_Params& params) { | |
795 if (file_select_helper_.get() == NULL) | |
796 file_select_helper_.reset(new FileSelectHelper(profile())); | |
797 file_select_helper_->RunFileChooser(render_view_host_, | |
798 GetAssociatedTabContents(), params); | |
799 } | |
OLD | NEW |