OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return; | 128 return; |
129 } | 129 } |
130 | 130 |
131 LOG(INFO) << "Navigating to " << url_.spec(); | 131 LOG(INFO) << "Navigating to " << url_.spec(); |
132 render_view_host_->NavigateToURL(url_); | 132 render_view_host_->NavigateToURL(url_); |
133 } | 133 } |
134 | 134 |
135 void ExtensionHost::Observe(NotificationType type, | 135 void ExtensionHost::Observe(NotificationType type, |
136 const NotificationSource& source, | 136 const NotificationSource& source, |
137 const NotificationDetails& details) { | 137 const NotificationDetails& details) { |
138 DCHECK(type == NotificationType::EXTENSION_BACKGROUND_PAGE_READY); | 138 if (type == NotificationType::EXTENSION_BACKGROUND_PAGE_READY) { |
139 DCHECK(extension_->GetBackgroundPageReady()); | 139 DCHECK(extension_->GetBackgroundPageReady()); |
140 NavigateToURL(url_); | 140 NavigateToURL(url_); |
| 141 } else if (type == NotificationType::BROWSER_THEME_CHANGED) { |
| 142 InsertThemeCSS(); |
| 143 } else { |
| 144 NOTREACHED(); |
| 145 } |
141 } | 146 } |
142 | 147 |
143 void ExtensionHost::UpdatePreferredWidth(int pref_width) { | 148 void ExtensionHost::UpdatePreferredWidth(int pref_width) { |
144 if (view_.get()) | 149 if (view_.get()) |
145 view_->UpdatePreferredWidth(pref_width); | 150 view_->UpdatePreferredWidth(pref_width); |
146 } | 151 } |
147 | 152 |
148 void ExtensionHost::RenderViewGone(RenderViewHost* render_view_host) { | 153 void ExtensionHost::RenderViewGone(RenderViewHost* render_view_host) { |
149 LOG(INFO) << "Sending EXTENSION_PROCESS_CRASHED for " + extension_->name(); | 154 LOG(INFO) << "Sending EXTENSION_PROCESS_CRASHED for " + extension_->name(); |
150 DCHECK_EQ(render_view_host_, render_view_host); | 155 DCHECK_EQ(render_view_host_, render_view_host); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 extension_host_type_ == ViewType::EXTENSION_MOLE) { | 239 extension_host_type_ == ViewType::EXTENSION_MOLE) { |
235 #if defined(TOOLKIT_VIEWS) | 240 #if defined(TOOLKIT_VIEWS) |
236 if (view_.get()) | 241 if (view_.get()) |
237 view_->DidStopLoading(); | 242 view_->DidStopLoading(); |
238 #endif | 243 #endif |
239 } | 244 } |
240 } | 245 } |
241 | 246 |
242 void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { | 247 void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) { |
243 document_element_available_ = true; | 248 document_element_available_ = true; |
244 if (is_background_page()) | 249 if (is_background_page()) { |
245 extension_->SetBackgroundPageReady(); | 250 extension_->SetBackgroundPageReady(); |
246 else | 251 } else { |
247 InsertThemeCSS(); | 252 InsertThemeCSS(); |
| 253 |
| 254 // Listen for browser changes so we can resend the CSS. |
| 255 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, |
| 256 NotificationService::AllSources()); |
| 257 } |
248 } | 258 } |
249 | 259 |
250 void ExtensionHost::RunJavaScriptMessage(const std::wstring& message, | 260 void ExtensionHost::RunJavaScriptMessage(const std::wstring& message, |
251 const std::wstring& default_prompt, | 261 const std::wstring& default_prompt, |
252 const GURL& frame_url, | 262 const GURL& frame_url, |
253 const int flags, | 263 const int flags, |
254 IPC::Message* reply_msg, | 264 IPC::Message* reply_msg, |
255 bool* did_suppress_message) { | 265 bool* did_suppress_message) { |
256 // Automatically cancel the javascript alert (otherwise the renderer hangs | 266 // Automatically cancel the javascript alert (otherwise the renderer hangs |
257 // indefinitely). | 267 // indefinitely). |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 window_id = ExtensionTabUtil::GetWindowId( | 421 window_id = ExtensionTabUtil::GetWindowId( |
412 const_cast<ExtensionHost* >(this)->GetBrowser()); | 422 const_cast<ExtensionHost* >(this)->GetBrowser()); |
413 } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) { | 423 } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) { |
414 // Background page is not attached to any browser window, so pass -1. | 424 // Background page is not attached to any browser window, so pass -1. |
415 window_id = -1; | 425 window_id = -1; |
416 } else { | 426 } else { |
417 NOTREACHED(); | 427 NOTREACHED(); |
418 } | 428 } |
419 return window_id; | 429 return window_id; |
420 } | 430 } |
OLD | NEW |