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

Side by Side Diff: chrome/browser/background/background_contents.cc

Issue 955713004: Merge 317853 - Make BackgroundContentsService start up BackgroundContents with a delay, as for Exte… (Closed) Base URL: https://chromium.googlesource.com/chromium/src@2311
Patch Set: Created 5 years, 10 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
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/background/background_contents.h" 5 #include "chrome/browser/background/background_contents.h"
6 6
7 #include "chrome/browser/background/background_contents_service.h" 7 #include "chrome/browser/background/background_contents_service.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/renderer_preferences_util.h" 11 #include "chrome/browser/renderer_preferences_util.h"
12 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 12 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/session_storage_namespace.h" 16 #include "content/public/browser/session_storage_namespace.h"
17 #include "content/public/browser/site_instance.h" 17 #include "content/public/browser/site_instance.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "extensions/browser/extension_host_delegate.h"
20 #include "extensions/browser/extension_host_queue.h"
21 #include "extensions/browser/extensions_browser_client.h"
19 #include "extensions/browser/view_type_utils.h" 22 #include "extensions/browser/view_type_utils.h"
20 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
21 24
22 using content::SiteInstance; 25 using content::SiteInstance;
23 using content::WebContents; 26 using content::WebContents;
24 27
25 BackgroundContents::BackgroundContents( 28 BackgroundContents::BackgroundContents(
26 SiteInstance* site_instance, 29 SiteInstance* site_instance,
27 int routing_id, 30 int routing_id,
28 int main_frame_routing_id, 31 int main_frame_routing_id,
29 Delegate* delegate, 32 Delegate* delegate,
30 const std::string& partition_id, 33 const std::string& partition_id,
31 content::SessionStorageNamespace* session_storage_namespace) 34 content::SessionStorageNamespace* session_storage_namespace)
32 : delegate_(delegate) { 35 : delegate_(delegate),
36 extension_host_delegate_(extensions::ExtensionsBrowserClient::Get()
37 ->CreateExtensionHostDelegate()) {
33 profile_ = Profile::FromBrowserContext( 38 profile_ = Profile::FromBrowserContext(
34 site_instance->GetBrowserContext()); 39 site_instance->GetBrowserContext());
35 40
36 WebContents::CreateParams create_params(profile_, site_instance); 41 WebContents::CreateParams create_params(profile_, site_instance);
37 create_params.routing_id = routing_id; 42 create_params.routing_id = routing_id;
38 create_params.main_frame_routing_id = main_frame_routing_id; 43 create_params.main_frame_routing_id = main_frame_routing_id;
39 if (session_storage_namespace) { 44 if (session_storage_namespace) {
40 content::SessionStorageNamespaceMap session_storage_namespace_map; 45 content::SessionStorageNamespaceMap session_storage_namespace_map;
41 session_storage_namespace_map.insert( 46 session_storage_namespace_map.insert(
42 std::make_pair(partition_id, session_storage_namespace)); 47 std::make_pair(partition_id, session_storage_namespace));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 80
76 // Unregister for any notifications before notifying observers that we are 81 // Unregister for any notifications before notifying observers that we are
77 // going away - this prevents any re-entrancy due to chained notifications 82 // going away - this prevents any re-entrancy due to chained notifications
78 // (http://crbug.com/237781). 83 // (http://crbug.com/237781).
79 registrar_.RemoveAll(); 84 registrar_.RemoveAll();
80 85
81 content::NotificationService::current()->Notify( 86 content::NotificationService::current()->Notify(
82 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, 87 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED,
83 content::Source<Profile>(profile_), 88 content::Source<Profile>(profile_),
84 content::Details<BackgroundContents>(this)); 89 content::Details<BackgroundContents>(this));
90
91 extension_host_delegate_->GetExtensionHostQueue()->Remove(this);
85 } 92 }
86 93
87 const GURL& BackgroundContents::GetURL() const { 94 const GURL& BackgroundContents::GetURL() const {
88 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL(); 95 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL();
89 } 96 }
90 97
98 void BackgroundContents::CreateRenderViewSoon(const GURL& url) {
99 initial_url_ = url;
100 extension_host_delegate_->GetExtensionHostQueue()->Add(this);
101 }
102
91 void BackgroundContents::CloseContents(WebContents* source) { 103 void BackgroundContents::CloseContents(WebContents* source) {
92 content::NotificationService::current()->Notify( 104 content::NotificationService::current()->Notify(
93 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, 105 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED,
94 content::Source<Profile>(profile_), 106 content::Source<Profile>(profile_),
95 content::Details<BackgroundContents>(this)); 107 content::Details<BackgroundContents>(this));
96 delete this; 108 delete this;
97 } 109 }
98 110
99 bool BackgroundContents::ShouldSuppressDialogs(WebContents* source) { 111 bool BackgroundContents::ShouldSuppressDialogs(WebContents* source) {
100 return true; 112 return true;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 case chrome::NOTIFICATION_PROFILE_DESTROYED: 165 case chrome::NOTIFICATION_PROFILE_DESTROYED:
154 case chrome::NOTIFICATION_APP_TERMINATING: { 166 case chrome::NOTIFICATION_APP_TERMINATING: {
155 delete this; 167 delete this;
156 break; 168 break;
157 } 169 }
158 default: 170 default:
159 NOTREACHED() << "Unexpected notification sent."; 171 NOTREACHED() << "Unexpected notification sent.";
160 break; 172 break;
161 } 173 }
162 } 174 }
175
176 void BackgroundContents::CreateRenderViewNow() {
177 web_contents()->GetController().LoadURL(initial_url_, content::Referrer(),
178 ui::PAGE_TRANSITION_LINK,
179 std::string());
180 }
OLDNEW
« no previous file with comments | « chrome/browser/background/background_contents.h ('k') | chrome/browser/background/background_contents_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698