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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // Listen for when the render process' handle is available so we can add it | 150 // Listen for when the render process' handle is available so we can add it |
151 // to the task manager then. | 151 // to the task manager then. |
152 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 152 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
153 Source<RenderProcessHost>(render_process_host())); | 153 Source<RenderProcessHost>(render_process_host())); |
154 // Listen for when an extension is unloaded from the same profile, as it may | 154 // Listen for when an extension is unloaded from the same profile, as it may |
155 // be the same extension that this points to. | 155 // be the same extension that this points to. |
156 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 156 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
157 Source<Profile>(profile_)); | 157 Source<Profile>(profile_)); |
158 } | 158 } |
159 | 159 |
160 // This "mock" constructor should only be used by unit tests. | |
161 ExtensionHost::ExtensionHost(const Extension* extension, | |
162 content::ViewType host_type) | |
163 : extension_(extension), | |
164 extension_id_(extension->id()), | |
165 profile_(NULL), | |
166 render_view_host_(NULL), | |
167 did_stop_loading_(false), | |
168 document_element_available_(false), | |
169 url_(GURL()), | |
170 ALLOW_THIS_IN_INITIALIZER_LIST( | |
171 extension_function_dispatcher_(profile_, this)), | |
172 extension_host_type_(host_type), | |
173 associated_tab_contents_(NULL) { | |
174 } | |
175 | |
176 ExtensionHost::~ExtensionHost() { | 160 ExtensionHost::~ExtensionHost() { |
177 NotificationService::current()->Notify( | 161 NotificationService::current()->Notify( |
178 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 162 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
179 Source<Profile>(profile_), | 163 Source<Profile>(profile_), |
180 Details<ExtensionHost>(this)); | 164 Details<ExtensionHost>(this)); |
181 ProcessCreationQueue::GetInstance()->Remove(this); | 165 ProcessCreationQueue::GetInstance()->Remove(this); |
182 GetJavaScriptDialogCreatorInstance()->ResetJavaScriptState(this); | 166 GetJavaScriptDialogCreatorInstance()->ResetJavaScriptState(this); |
183 // render_view_host_ may be NULL in unit tests. | 167 render_view_host_->Shutdown(); // deletes render_view_host |
184 if (render_view_host_) | |
185 render_view_host_->Shutdown(); // deletes render_view_host | |
186 } | 168 } |
187 | 169 |
188 void ExtensionHost::CreateView(Browser* browser) { | 170 void ExtensionHost::CreateView(Browser* browser) { |
189 #if defined(TOOLKIT_VIEWS) | 171 #if defined(TOOLKIT_VIEWS) |
190 view_.reset(new ExtensionView(this, browser)); | 172 view_.reset(new ExtensionView(this, browser)); |
191 // We own |view_|, so don't auto delete when it's removed from the view | 173 // We own |view_|, so don't auto delete when it's removed from the view |
192 // hierarchy. | 174 // hierarchy. |
193 view_->set_parent_owned(false); | 175 view_->set_parent_owned(false); |
194 #elif defined(OS_MACOSX) | 176 #elif defined(OS_MACOSX) |
195 view_.reset(new ExtensionViewMac(this, browser)); | 177 view_.reset(new ExtensionViewMac(this, browser)); |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 794 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
813 if (view_.get()) | 795 if (view_.get()) |
814 view_->RenderViewCreated(); | 796 view_->RenderViewCreated(); |
815 | 797 |
816 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || | 798 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP || |
817 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { | 799 extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_INFOBAR) { |
818 render_view_host->EnablePreferredSizeMode( | 800 render_view_host->EnablePreferredSizeMode( |
819 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); | 801 kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
820 } | 802 } |
821 } | 803 } |
OLD | NEW |