OLD | NEW |
---|---|
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 "base/lazy_instance.h" | |
Devlin
2015/02/20 00:07:57
don't need
Yoyo Zhou
2015/02/20 20:00:01
Done - also removed from extension_host.cc.
| |
7 #include "chrome/browser/background/background_contents_service.h" | 8 #include "chrome/browser/background/background_contents_service.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/renderer_preferences_util.h" | 12 #include "chrome/browser/renderer_preferences_util.h" |
12 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 13 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/session_storage_namespace.h" | 17 #include "content/public/browser/session_storage_namespace.h" |
17 #include "content/public/browser/site_instance.h" | 18 #include "content/public/browser/site_instance.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "extensions/browser/extension_host_delegate.h" | |
21 #include "extensions/browser/extension_host_queue.h" | |
22 #include "extensions/browser/extensions_browser_client.h" | |
23 #include "extensions/browser/serial_extension_host_queue.h" | |
Devlin
2015/02/20 00:07:57
don't need
| |
19 #include "extensions/browser/view_type_utils.h" | 24 #include "extensions/browser/view_type_utils.h" |
20 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
21 | 26 |
22 using content::SiteInstance; | 27 using content::SiteInstance; |
23 using content::WebContents; | 28 using content::WebContents; |
24 | 29 |
25 BackgroundContents::BackgroundContents( | 30 BackgroundContents::BackgroundContents( |
26 SiteInstance* site_instance, | 31 SiteInstance* site_instance, |
27 int routing_id, | 32 int routing_id, |
28 int main_frame_routing_id, | 33 int main_frame_routing_id, |
29 Delegate* delegate, | 34 Delegate* delegate, |
30 const std::string& partition_id, | 35 const std::string& partition_id, |
31 content::SessionStorageNamespace* session_storage_namespace) | 36 content::SessionStorageNamespace* session_storage_namespace) |
32 : delegate_(delegate) { | 37 : delegate_(delegate), |
38 extension_host_delegate_(extensions::ExtensionsBrowserClient::Get() | |
39 ->CreateExtensionHostDelegate()) { | |
33 profile_ = Profile::FromBrowserContext( | 40 profile_ = Profile::FromBrowserContext( |
34 site_instance->GetBrowserContext()); | 41 site_instance->GetBrowserContext()); |
35 | 42 |
36 WebContents::CreateParams create_params(profile_, site_instance); | 43 WebContents::CreateParams create_params(profile_, site_instance); |
37 create_params.routing_id = routing_id; | 44 create_params.routing_id = routing_id; |
38 create_params.main_frame_routing_id = main_frame_routing_id; | 45 create_params.main_frame_routing_id = main_frame_routing_id; |
39 if (session_storage_namespace) { | 46 if (session_storage_namespace) { |
40 content::SessionStorageNamespaceMap session_storage_namespace_map; | 47 content::SessionStorageNamespaceMap session_storage_namespace_map; |
41 session_storage_namespace_map.insert( | 48 session_storage_namespace_map.insert( |
42 std::make_pair(partition_id, session_storage_namespace)); | 49 std::make_pair(partition_id, session_storage_namespace)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 82 |
76 // Unregister for any notifications before notifying observers that we are | 83 // Unregister for any notifications before notifying observers that we are |
77 // going away - this prevents any re-entrancy due to chained notifications | 84 // going away - this prevents any re-entrancy due to chained notifications |
78 // (http://crbug.com/237781). | 85 // (http://crbug.com/237781). |
79 registrar_.RemoveAll(); | 86 registrar_.RemoveAll(); |
80 | 87 |
81 content::NotificationService::current()->Notify( | 88 content::NotificationService::current()->Notify( |
82 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, | 89 chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
83 content::Source<Profile>(profile_), | 90 content::Source<Profile>(profile_), |
84 content::Details<BackgroundContents>(this)); | 91 content::Details<BackgroundContents>(this)); |
92 | |
93 extension_host_delegate_->GetExtensionHostQueue()->Remove(this); | |
85 } | 94 } |
86 | 95 |
87 const GURL& BackgroundContents::GetURL() const { | 96 const GURL& BackgroundContents::GetURL() const { |
88 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL(); | 97 return web_contents_.get() ? web_contents_->GetURL() : GURL::EmptyGURL(); |
89 } | 98 } |
90 | 99 |
100 void BackgroundContents::CreateRenderViewSoon(const GURL& url) { | |
101 initial_url_ = url; | |
102 extension_host_delegate_->GetExtensionHostQueue()->Add(this); | |
103 } | |
104 | |
91 void BackgroundContents::CloseContents(WebContents* source) { | 105 void BackgroundContents::CloseContents(WebContents* source) { |
92 content::NotificationService::current()->Notify( | 106 content::NotificationService::current()->Notify( |
93 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, | 107 chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, |
94 content::Source<Profile>(profile_), | 108 content::Source<Profile>(profile_), |
95 content::Details<BackgroundContents>(this)); | 109 content::Details<BackgroundContents>(this)); |
96 delete this; | 110 delete this; |
97 } | 111 } |
98 | 112 |
99 bool BackgroundContents::ShouldSuppressDialogs(WebContents* source) { | 113 bool BackgroundContents::ShouldSuppressDialogs(WebContents* source) { |
100 return true; | 114 return true; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 167 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
154 case chrome::NOTIFICATION_APP_TERMINATING: { | 168 case chrome::NOTIFICATION_APP_TERMINATING: { |
155 delete this; | 169 delete this; |
156 break; | 170 break; |
157 } | 171 } |
158 default: | 172 default: |
159 NOTREACHED() << "Unexpected notification sent."; | 173 NOTREACHED() << "Unexpected notification sent."; |
160 break; | 174 break; |
161 } | 175 } |
162 } | 176 } |
177 | |
178 void BackgroundContents::CreateRenderViewNow() { | |
179 web_contents()->GetController().LoadURL(initial_url_, content::Referrer(), | |
180 ui::PAGE_TRANSITION_LINK, | |
181 std::string()); | |
182 } | |
OLD | NEW |