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

Side by Side Diff: chrome/browser/extensions/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: Test passes! Don't know if it's right though Created 6 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 RenderViewHost* ExtensionHost::render_view_host() const { 174 RenderViewHost* ExtensionHost::render_view_host() const {
175 // TODO(mpcomplete): This can be NULL. How do we handle that? 175 // TODO(mpcomplete): This can be NULL. How do we handle that?
176 return render_view_host_; 176 return render_view_host_;
177 } 177 }
178 178
179 bool ExtensionHost::IsRenderViewLive() const { 179 bool ExtensionHost::IsRenderViewLive() const {
180 return render_view_host()->IsRenderViewLive(); 180 return render_view_host()->IsRenderViewLive();
181 } 181 }
182 182
183 void ExtensionHost::CreateRenderViewSoon() { 183 void ExtensionHost::CreateRenderViewSoon(const base::Closure& continuation) {
184 if ((render_process_host() && render_process_host()->HasConnection())) { 184 if ((render_process_host() && render_process_host()->HasConnection())) {
185 // If the process is already started, go ahead and initialize the RenderView 185 // If the process is already started, go ahead and initialize the RenderView
186 // synchronously. The process creation is the real meaty part that we want 186 // synchronously. The process creation is the real meaty part that we want
187 // to defer. 187 // to defer.
188 CreateRenderViewNow(); 188 CreateRenderViewNow();
189 if (!continuation.is_null())
190 continuation.Run();
189 } else { 191 } else {
192 if (!continuation.is_null())
193 when_render_view_created_.push_back(continuation);
190 ProcessCreationQueue::GetInstance()->CreateSoon(this); 194 ProcessCreationQueue::GetInstance()->CreateSoon(this);
191 } 195 }
192 } 196 }
193 197
194 void ExtensionHost::CreateRenderViewNow() { 198 void ExtensionHost::CreateRenderViewNow() {
195 LoadInitialURL(); 199 LoadInitialURL();
196 if (IsBackgroundPage()) { 200 if (IsBackgroundPage()) {
197 DCHECK(IsRenderViewLive()); 201 DCHECK(IsRenderViewLive());
198 // Connect orphaned dev-tools instances. 202 // Connect orphaned dev-tools instances.
199 delegate_->OnRenderViewCreatedForBackgroundPage(this); 203 delegate_->OnRenderViewCreatedForBackgroundPage(this);
200 } 204 }
205 std::vector<base::Closure> running;
206 running.swap(when_render_view_created_);
207 for (std::vector<base::Closure>::const_iterator it = running.begin();
208 it != running.end();
209 ++it) {
210 it->Run();
211 }
201 } 212 }
202 213
203 const GURL& ExtensionHost::GetURL() const { 214 const GURL& ExtensionHost::GetURL() const {
204 return host_contents()->GetURL(); 215 return host_contents()->GetURL();
205 } 216 }
206 217
207 void ExtensionHost::LoadInitialURL() { 218 void ExtensionHost::LoadInitialURL() {
208 host_contents_->GetController().LoadURL( 219 host_contents_->GetController().LoadURL(
209 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK, 220 initial_url_, content::Referrer(), content::PAGE_TRANSITION_LINK,
210 std::string()); 221 std::string());
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 bool ExtensionHost::PreHandleGestureEvent( 448 bool ExtensionHost::PreHandleGestureEvent(
438 content::WebContents* source, 449 content::WebContents* source,
439 const blink::WebGestureEvent& event) { 450 const blink::WebGestureEvent& event) {
440 // Disable pinch zooming. 451 // Disable pinch zooming.
441 return event.type == blink::WebGestureEvent::GesturePinchBegin || 452 return event.type == blink::WebGestureEvent::GesturePinchBegin ||
442 event.type == blink::WebGestureEvent::GesturePinchUpdate || 453 event.type == blink::WebGestureEvent::GesturePinchUpdate ||
443 event.type == blink::WebGestureEvent::GesturePinchEnd; 454 event.type == blink::WebGestureEvent::GesturePinchEnd;
444 } 455 }
445 456
446 } // namespace extensions 457 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698