OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_view_host.h" | 5 #include "chrome/browser/extensions/extension_view_host.h" |
6 | 6 |
7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/extension_service.h" | |
10 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
11 #include "chrome/browser/extensions/window_controller.h" | 10 #include "chrome/browser/extensions/window_controller.h" |
12 #include "chrome/browser/file_select_helper.h" | 11 #include "chrome/browser/file_select_helper.h" |
13 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_dialogs.h" | 14 #include "chrome/browser/ui/browser_dialogs.h" |
16 #include "chrome/common/extensions/extension_messages.h" | 15 #include "chrome/common/extensions/extension_messages.h" |
17 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 16 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
18 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
19 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
21 #include "content/public/browser/web_contents_view.h" | 20 #include "content/public/browser/web_contents_view.h" |
| 21 #include "extensions/browser/runtime_data.h" |
22 #include "grit/browser_resources.h" | 22 #include "grit/browser_resources.h" |
23 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/events/keycodes/keyboard_codes.h" | 24 #include "ui/events/keycodes/keyboard_codes.h" |
25 | 25 |
26 using content::NativeWebKeyboardEvent; | 26 using content::NativeWebKeyboardEvent; |
27 using content::OpenURLParams; | 27 using content::OpenURLParams; |
28 using content::RenderViewHost; | 28 using content::RenderViewHost; |
29 using content::WebContents; | 29 using content::WebContents; |
30 using content::WebContentsObserver; | 30 using content::WebContentsObserver; |
31 using web_modal::WebContentsModalDialogManager; | 31 using web_modal::WebContentsModalDialogManager; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 void ExtensionViewHost::OnDocumentAvailable() { | 134 void ExtensionViewHost::OnDocumentAvailable() { |
135 if (extension_host_type() == VIEW_TYPE_EXTENSION_INFOBAR) { | 135 if (extension_host_type() == VIEW_TYPE_EXTENSION_INFOBAR) { |
136 // No style sheet for other types, at the moment. | 136 // No style sheet for other types, at the moment. |
137 InsertInfobarCSS(); | 137 InsertInfobarCSS(); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 void ExtensionViewHost::LoadInitialURL() { | 141 void ExtensionViewHost::LoadInitialURL() { |
142 if (!ExtensionSystem::GetForBrowserContext(browser_context())-> | 142 if (!ExtensionSystem::GetForBrowserContext(browser_context())-> |
143 extension_service()->IsBackgroundPageReady(extension())) { | 143 runtime_data()->IsBackgroundPageReady(extension())) { |
144 // Make sure the background page loads before any others. | 144 // Make sure the background page loads before any others. |
145 registrar()->Add(this, | 145 registrar()->Add(this, |
146 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 146 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
147 content::Source<Extension>(extension())); | 147 content::Source<Extension>(extension())); |
148 return; | 148 return; |
149 } | 149 } |
150 | 150 |
151 // Popups may spawn modal dialogs, which need positioning information. | 151 // Popups may spawn modal dialogs, which need positioning information. |
152 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) { | 152 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) { |
153 WebContentsModalDialogManager::CreateForWebContents(host_contents()); | 153 WebContentsModalDialogManager::CreateForWebContents(host_contents()); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) | 314 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) |
315 return host_contents(); | 315 return host_contents(); |
316 return NULL; | 316 return NULL; |
317 } | 317 } |
318 | 318 |
319 void ExtensionViewHost::Observe(int type, | 319 void ExtensionViewHost::Observe(int type, |
320 const content::NotificationSource& source, | 320 const content::NotificationSource& source, |
321 const content::NotificationDetails& details) { | 321 const content::NotificationDetails& details) { |
322 if (type == chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY) { | 322 if (type == chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY) { |
323 DCHECK(ExtensionSystem::GetForBrowserContext(browser_context())-> | 323 DCHECK(ExtensionSystem::GetForBrowserContext(browser_context())-> |
324 extension_service()->IsBackgroundPageReady(extension())); | 324 runtime_data()->IsBackgroundPageReady(extension())); |
325 LoadInitialURL(); | 325 LoadInitialURL(); |
326 return; | 326 return; |
327 } | 327 } |
328 ExtensionHost::Observe(type, source, details); | 328 ExtensionHost::Observe(type, source, details); |
329 } | 329 } |
330 | 330 |
331 void ExtensionViewHost::InsertInfobarCSS() { | 331 void ExtensionViewHost::InsertInfobarCSS() { |
332 static const base::StringPiece css( | 332 static const base::StringPiece css( |
333 ResourceBundle::GetSharedInstance().GetRawDataResource( | 333 ResourceBundle::GetSharedInstance().GetRawDataResource( |
334 IDR_EXTENSIONS_INFOBAR_CSS)); | 334 IDR_EXTENSIONS_INFOBAR_CSS)); |
335 | 335 |
336 render_view_host()->InsertCSS(base::string16(), css.as_string()); | 336 render_view_host()->InsertCSS(base::string16(), css.as_string()); |
337 } | 337 } |
338 | 338 |
339 } // namespace extensions | 339 } // namespace extensions |
OLD | NEW |