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_view.h" | 9 #include "chrome/browser/extensions/extension_view.h" |
10 #include "chrome/browser/extensions/window_controller.h" | 10 #include "chrome/browser/extensions/window_controller.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 ExtensionViewHost::ExtensionViewHost( | 57 ExtensionViewHost::ExtensionViewHost( |
58 const Extension* extension, | 58 const Extension* extension, |
59 content::SiteInstance* site_instance, | 59 content::SiteInstance* site_instance, |
60 const GURL& url, | 60 const GURL& url, |
61 ViewType host_type) | 61 ViewType host_type) |
62 : ExtensionHost(extension, site_instance, url, host_type), | 62 : ExtensionHost(extension, site_instance, url, host_type), |
63 associated_web_contents_(NULL) { | 63 associated_web_contents_(NULL) { |
64 // Not used for panels, see PanelHost. | 64 // Not used for panels, see PanelHost. |
65 DCHECK(host_type == VIEW_TYPE_EXTENSION_DIALOG || | 65 DCHECK(host_type == VIEW_TYPE_EXTENSION_DIALOG || |
66 host_type == VIEW_TYPE_EXTENSION_INFOBAR || | |
67 host_type == VIEW_TYPE_EXTENSION_POPUP); | 66 host_type == VIEW_TYPE_EXTENSION_POPUP); |
68 } | 67 } |
69 | 68 |
70 ExtensionViewHost::~ExtensionViewHost() { | 69 ExtensionViewHost::~ExtensionViewHost() { |
71 // The hosting WebContents will be deleted in the base class, so unregister | 70 // The hosting WebContents will be deleted in the base class, so unregister |
72 // this object before it deletes the attached WebContentsModalDialogManager. | 71 // this object before it deletes the attached WebContentsModalDialogManager. |
73 WebContentsModalDialogManager* manager = | 72 WebContentsModalDialogManager* manager = |
74 WebContentsModalDialogManager::FromWebContents(host_contents()); | 73 WebContentsModalDialogManager::FromWebContents(host_contents()); |
75 if (manager) | 74 if (manager) |
76 manager->SetDelegate(NULL); | 75 manager->SetDelegate(NULL); |
(...skipping 21 matching lines...) Expand all Loading... |
98 view_->HandleKeyboardEvent(source, event); | 97 view_->HandleKeyboardEvent(source, event); |
99 } | 98 } |
100 | 99 |
101 // ExtensionHost overrides: | 100 // ExtensionHost overrides: |
102 | 101 |
103 void ExtensionViewHost::OnDidStopLoading() { | 102 void ExtensionViewHost::OnDidStopLoading() { |
104 DCHECK(did_stop_loading()); | 103 DCHECK(did_stop_loading()); |
105 view_->DidStopLoading(); | 104 view_->DidStopLoading(); |
106 } | 105 } |
107 | 106 |
108 void ExtensionViewHost::OnDocumentAvailable() { | |
109 if (extension_host_type() == VIEW_TYPE_EXTENSION_INFOBAR) { | |
110 // No style sheet for other types, at the moment. | |
111 InsertInfobarCSS(); | |
112 } | |
113 } | |
114 | |
115 void ExtensionViewHost::LoadInitialURL() { | 107 void ExtensionViewHost::LoadInitialURL() { |
116 if (!ExtensionSystem::Get(browser_context())-> | 108 if (!ExtensionSystem::Get(browser_context())-> |
117 runtime_data()->IsBackgroundPageReady(extension())) { | 109 runtime_data()->IsBackgroundPageReady(extension())) { |
118 // Make sure the background page loads before any others. | 110 // Make sure the background page loads before any others. |
119 registrar()->Add(this, | 111 registrar()->Add(this, |
120 extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, | 112 extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
121 content::Source<Extension>(extension())); | 113 content::Source<Extension>(extension())); |
122 return; | 114 return; |
123 } | 115 } |
124 | 116 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 const content::NotificationDetails& details) { | 299 const content::NotificationDetails& details) { |
308 if (type == extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY) { | 300 if (type == extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY) { |
309 DCHECK(ExtensionSystem::Get(browser_context())-> | 301 DCHECK(ExtensionSystem::Get(browser_context())-> |
310 runtime_data()->IsBackgroundPageReady(extension())); | 302 runtime_data()->IsBackgroundPageReady(extension())); |
311 LoadInitialURL(); | 303 LoadInitialURL(); |
312 return; | 304 return; |
313 } | 305 } |
314 ExtensionHost::Observe(type, source, details); | 306 ExtensionHost::Observe(type, source, details); |
315 } | 307 } |
316 | 308 |
317 void ExtensionViewHost::InsertInfobarCSS() { | |
318 static const base::StringPiece css( | |
319 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
320 IDR_EXTENSIONS_INFOBAR_CSS)); | |
321 | |
322 host_contents()->InsertCSS(css.as_string()); | |
323 } | |
324 | |
325 } // namespace extensions | 309 } // namespace extensions |
OLD | NEW |