Chromium Code Reviews

Side by Side Diff: chrome/browser/extensions/extension_host.cc

Issue 5685007: Rename all methods accessing Singleton<T> as GetInstance(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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 48 matching lines...)
59 using WebKit::WebDragOperation; 59 using WebKit::WebDragOperation;
60 using WebKit::WebDragOperationsMask; 60 using WebKit::WebDragOperationsMask;
61 61
62 // static 62 // static
63 bool ExtensionHost::enable_dom_automation_ = false; 63 bool ExtensionHost::enable_dom_automation_ = false;
64 64
65 // Helper class that rate-limits the creation of renderer processes for 65 // Helper class that rate-limits the creation of renderer processes for
66 // ExtensionHosts, to avoid blocking the UI. 66 // ExtensionHosts, to avoid blocking the UI.
67 class ExtensionHost::ProcessCreationQueue { 67 class ExtensionHost::ProcessCreationQueue {
68 public: 68 public:
69 static ProcessCreationQueue* get() { 69 static ProcessCreationQueue* GetInstance() {
70 return Singleton<ProcessCreationQueue>::get(); 70 return Singleton<ProcessCreationQueue>::get();
71 } 71 }
72 72
73 // Add a host to the queue for RenderView creation. 73 // Add a host to the queue for RenderView creation.
74 void CreateSoon(ExtensionHost* host) { 74 void CreateSoon(ExtensionHost* host) {
75 queue_.push_back(host); 75 queue_.push_back(host);
76 PostTask(); 76 PostTask();
77 } 77 }
78 78
79 // Remove a host from the queue (in case it's being deleted). 79 // Remove a host from the queue (in case it's being deleted).
(...skipping 68 matching lines...)
148 // be the same extension that this points to. 148 // be the same extension that this points to.
149 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 149 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
150 Source<Profile>(profile_)); 150 Source<Profile>(profile_));
151 } 151 }
152 152
153 ExtensionHost::~ExtensionHost() { 153 ExtensionHost::~ExtensionHost() {
154 NotificationService::current()->Notify( 154 NotificationService::current()->Notify(
155 NotificationType::EXTENSION_HOST_DESTROYED, 155 NotificationType::EXTENSION_HOST_DESTROYED,
156 Source<Profile>(profile_), 156 Source<Profile>(profile_),
157 Details<ExtensionHost>(this)); 157 Details<ExtensionHost>(this));
158 ProcessCreationQueue::get()->Remove(this); 158 ProcessCreationQueue::GetInstance()->Remove(this);
159 render_view_host_->Shutdown(); // deletes render_view_host 159 render_view_host_->Shutdown(); // deletes render_view_host
160 } 160 }
161 161
162 void ExtensionHost::CreateView(Browser* browser) { 162 void ExtensionHost::CreateView(Browser* browser) {
163 #if defined(TOOLKIT_VIEWS) 163 #if defined(TOOLKIT_VIEWS)
164 view_.reset(new ExtensionView(this, browser)); 164 view_.reset(new ExtensionView(this, browser));
165 // We own |view_|, so don't auto delete when it's removed from the view 165 // We own |view_|, so don't auto delete when it's removed from the view
166 // hierarchy. 166 // hierarchy.
167 view_->set_parent_owned(false); 167 view_->set_parent_owned(false);
168 #elif defined(OS_MACOSX) 168 #elif defined(OS_MACOSX)
(...skipping 21 matching lines...)
190 } 190 }
191 191
192 void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) { 192 void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) {
193 render_view_host_->set_view(host_view); 193 render_view_host_->set_view(host_view);
194 if (render_view_host_->process()->HasConnection()) { 194 if (render_view_host_->process()->HasConnection()) {
195 // If the process is already started, go ahead and initialize the RenderView 195 // If the process is already started, go ahead and initialize the RenderView
196 // synchronously. The process creation is the real meaty part that we want 196 // synchronously. The process creation is the real meaty part that we want
197 // to defer. 197 // to defer.
198 CreateRenderViewNow(); 198 CreateRenderViewNow();
199 } else { 199 } else {
200 ProcessCreationQueue::get()->CreateSoon(this); 200 ProcessCreationQueue::GetInstance()->CreateSoon(this);
201 } 201 }
202 } 202 }
203 203
204 void ExtensionHost::CreateRenderViewNow() { 204 void ExtensionHost::CreateRenderViewNow() {
205 render_view_host_->CreateRenderView(string16()); 205 render_view_host_->CreateRenderView(string16());
206 NavigateToURL(url_); 206 NavigateToURL(url_);
207 DCHECK(IsRenderViewLive()); 207 DCHECK(IsRenderViewLive());
208 if (is_background_page()) 208 if (is_background_page())
209 profile_->GetExtensionsService()->DidCreateRenderViewForBackgroundPage( 209 profile_->GetExtensionsService()->DidCreateRenderViewForBackgroundPage(
210 this); 210 this);
(...skipping 565 matching lines...)
776 // Extensions hosted in ExternalTabContainer objects may not have 776 // Extensions hosted in ExternalTabContainer objects may not have
777 // an associated browser. 777 // an associated browser.
778 Browser* browser = GetBrowser(); 778 Browser* browser = GetBrowser();
779 if (browser) 779 if (browser)
780 window_id = ExtensionTabUtil::GetWindowId(browser); 780 window_id = ExtensionTabUtil::GetWindowId(browser);
781 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { 781 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) {
782 NOTREACHED(); 782 NOTREACHED();
783 } 783 }
784 return window_id; 784 return window_id;
785 } 785 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.cc ('k') | chrome/browser/extensions/extensions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine