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/notifications/balloon_host.h" | 5 #include "chrome/browser/notifications/balloon_host.h" |
6 | 6 |
7 #include "chrome/browser/notifications/balloon.h" | 7 #include "chrome/browser/notifications/balloon.h" |
8 #include "chrome/browser/notifications/balloon_collection_impl.h" | 8 #include "chrome/browser/notifications/balloon_collection_impl.h" |
9 #include "chrome/browser/notifications/notification.h" | 9 #include "chrome/browser/notifications/notification.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/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
14 #include "chrome/browser/ui/browser_tabstrip.h" | 14 #include "chrome/browser/ui/browser_tabstrip.h" |
15 #include "chrome/browser/ui/host_desktop.h" | 15 #include "chrome/browser/ui/host_desktop.h" |
16 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 16 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
17 #include "chrome/browser/view_type_utils.h" | |
18 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/extensions/extension_messages.h" | 18 #include "chrome/common/extensions/extension_messages.h" |
20 #include "chrome/common/render_messages.h" | 19 #include "chrome/common/render_messages.h" |
21 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
22 #include "content/public/browser/navigation_controller.h" | 21 #include "content/public/browser/navigation_controller.h" |
23 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
24 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
25 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/site_instance.h" | 26 #include "content/public/browser/site_instance.h" |
28 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
29 #include "content/public/common/bindings_policy.h" | 28 #include "content/public/common/bindings_policy.h" |
30 #include "content/public/common/renderer_preferences.h" | 29 #include "content/public/common/renderer_preferences.h" |
| 30 #include "extensions/browser/view_type_utils.h" |
31 #include "ipc/ipc_message.h" | 31 #include "ipc/ipc_message.h" |
32 | 32 |
33 using content::SiteInstance; | 33 using content::SiteInstance; |
34 using content::WebContents; | 34 using content::WebContents; |
35 | 35 |
36 BalloonHost::BalloonHost(Balloon* balloon) | 36 BalloonHost::BalloonHost(Balloon* balloon) |
37 : balloon_(balloon), | 37 : balloon_(balloon), |
38 initialized_(false), | 38 initialized_(false), |
39 should_notify_on_disconnect_(false), | 39 should_notify_on_disconnect_(false), |
40 enable_web_ui_(false), | 40 enable_web_ui_(false), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 void BalloonHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 133 void BalloonHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
134 extension_function_dispatcher_.Dispatch(params, | 134 extension_function_dispatcher_.Dispatch(params, |
135 web_contents_->GetRenderViewHost()); | 135 web_contents_->GetRenderViewHost()); |
136 } | 136 } |
137 | 137 |
138 void BalloonHost::Init() { | 138 void BalloonHost::Init() { |
139 DCHECK(!web_contents_.get()) << "BalloonViewHost already initialized."; | 139 DCHECK(!web_contents_.get()) << "BalloonViewHost already initialized."; |
140 web_contents_.reset(WebContents::Create( | 140 web_contents_.reset(WebContents::Create( |
141 WebContents::CreateParams(balloon_->profile(), site_instance_.get()))); | 141 WebContents::CreateParams(balloon_->profile(), site_instance_.get()))); |
142 chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_NOTIFICATION); | 142 extensions::SetViewType( |
| 143 web_contents_.get(), extensions::VIEW_TYPE_NOTIFICATION); |
143 web_contents_->SetDelegate(this); | 144 web_contents_->SetDelegate(this); |
144 Observe(web_contents_.get()); | 145 Observe(web_contents_.get()); |
145 renderer_preferences_util::UpdateFromSystemSettings( | 146 renderer_preferences_util::UpdateFromSystemSettings( |
146 web_contents_->GetMutableRendererPrefs(), balloon_->profile()); | 147 web_contents_->GetMutableRendererPrefs(), balloon_->profile()); |
147 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 148 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
148 | 149 |
149 web_contents_->GetController().LoadURL( | 150 web_contents_->GetController().LoadURL( |
150 balloon_->notification().content_url(), content::Referrer(), | 151 balloon_->notification().content_url(), content::Referrer(), |
151 content::PAGE_TRANSITION_LINK, std::string()); | 152 content::PAGE_TRANSITION_LINK, std::string()); |
152 | 153 |
(...skipping 27 matching lines...) Expand all Loading... |
180 bool BalloonHost::CanLoadDataURLsInWebUI() const { | 181 bool BalloonHost::CanLoadDataURLsInWebUI() const { |
181 #if defined(OS_CHROMEOS) | 182 #if defined(OS_CHROMEOS) |
182 // Chrome OS uses data URLs in WebUI BalloonHosts. We normally do not allow | 183 // Chrome OS uses data URLs in WebUI BalloonHosts. We normally do not allow |
183 // data URLs in WebUI renderers, but normal pages cannot target BalloonHosts, | 184 // data URLs in WebUI renderers, but normal pages cannot target BalloonHosts, |
184 // so this should be safe. | 185 // so this should be safe. |
185 return true; | 186 return true; |
186 #else | 187 #else |
187 return false; | 188 return false; |
188 #endif | 189 #endif |
189 } | 190 } |
OLD | NEW |