Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

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

Issue 182253010: Register a Service Worker when an extension is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to r261176 Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_host.h" 5 #include "extensions/browser/extension_host.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 RenderViewHost* ExtensionHost::render_view_host() const { 167 RenderViewHost* ExtensionHost::render_view_host() const {
168 // TODO(mpcomplete): This can be NULL. How do we handle that? 168 // TODO(mpcomplete): This can be NULL. How do we handle that?
169 return render_view_host_; 169 return render_view_host_;
170 } 170 }
171 171
172 bool ExtensionHost::IsRenderViewLive() const { 172 bool ExtensionHost::IsRenderViewLive() const {
173 return render_view_host()->IsRenderViewLive(); 173 return render_view_host()->IsRenderViewLive();
174 } 174 }
175 175
176 void ExtensionHost::CreateRenderViewSoon() { 176 void ExtensionHost::CreateRenderViewSoon(const base::Closure& continuation) {
177 if ((render_process_host() && render_process_host()->HasConnection())) { 177 if ((render_process_host() && render_process_host()->HasConnection())) {
178 // If the process is already started, go ahead and initialize the RenderView 178 // If the process is already started, go ahead and initialize the RenderView
179 // synchronously. The process creation is the real meaty part that we want 179 // synchronously. The process creation is the real meaty part that we want
180 // to defer. 180 // to defer.
181 CreateRenderViewNow(); 181 CreateRenderViewNow();
182 if (!continuation.is_null())
183 continuation.Run();
182 } else { 184 } else {
185 if (!continuation.is_null())
186 when_render_view_created_.push_back(continuation);
183 ProcessCreationQueue::GetInstance()->CreateSoon(this); 187 ProcessCreationQueue::GetInstance()->CreateSoon(this);
184 } 188 }
185 } 189 }
186 190
191 static void RunAll(const std::vector<base::Closure>& callbacks) {
192 for (std::vector<base::Closure>::const_iterator it = callbacks.begin();
193 it != callbacks.end();
194 ++it) {
195 it->Run();
196 }
197 }
198
187 void ExtensionHost::CreateRenderViewNow() { 199 void ExtensionHost::CreateRenderViewNow() {
188 LoadInitialURL(); 200 LoadInitialURL();
189 if (IsBackgroundPage()) { 201 if (IsBackgroundPage()) {
190 DCHECK(IsRenderViewLive()); 202 DCHECK(IsRenderViewLive());
191 // Connect orphaned dev-tools instances. 203 // Connect orphaned dev-tools instances.
192 delegate_->OnRenderViewCreatedForBackgroundPage(this); 204 delegate_->OnRenderViewCreatedForBackgroundPage(this);
193 } 205 }
206 std::vector<base::Closure> running;
207 running.swap(when_render_view_created_);
208 base::MessageLoop::current()->PostDelayedTask(
209 FROM_HERE,
210 base::Bind(&RunAll, running),
211 base::TimeDelta::FromMilliseconds(10));
194 } 212 }
195 213
196 const GURL& ExtensionHost::GetURL() const { 214 const GURL& ExtensionHost::GetURL() const {
197 return host_contents()->GetURL(); 215 return host_contents()->GetURL();
198 } 216 }
199 217
200 void ExtensionHost::LoadInitialURL() { 218 void ExtensionHost::LoadInitialURL() {
201 host_contents_->GetController().LoadURL( 219 host_contents_->GetController().LoadURL(
202 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, 220 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK,
203 std::string()); 221 std::string());
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 439
422 void ExtensionHost::RequestMediaAccessPermission( 440 void ExtensionHost::RequestMediaAccessPermission(
423 content::WebContents* web_contents, 441 content::WebContents* web_contents,
424 const content::MediaStreamRequest& request, 442 const content::MediaStreamRequest& request,
425 const content::MediaResponseCallback& callback) { 443 const content::MediaResponseCallback& callback) {
426 delegate_->ProcessMediaAccessRequest( 444 delegate_->ProcessMediaAccessRequest(
427 web_contents, request, callback, extension()); 445 web_contents, request, callback, extension());
428 } 446 }
429 447
430 } // namespace extensions 448 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698