| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_tab_util.h" | 18 #include "chrome/browser/extensions/extension_tab_util.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/renderer_preferences_util.h" |
| 20 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" | 21 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" |
| 21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 27 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_view_type.h" | 28 #include "chrome/common/chrome_view_type.h" |
| 28 #include "chrome/common/extensions/extension.h" | 29 #include "chrome/common/extensions/extension.h" |
| 29 #include "chrome/common/extensions/extension_constants.h" | 30 #include "chrome/common/extensions/extension_constants.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 ALLOW_THIS_IN_INITIALIZER_LIST( | 128 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 128 extension_function_dispatcher_(profile_, this)), | 129 extension_function_dispatcher_(profile_, this)), |
| 129 extension_host_type_(host_type), | 130 extension_host_type_(host_type), |
| 130 associated_tab_contents_(NULL) { | 131 associated_tab_contents_(NULL) { |
| 131 host_contents_.reset(new TabContents( | 132 host_contents_.reset(new TabContents( |
| 132 profile_, site_instance, MSG_ROUTING_NONE, NULL, NULL)); | 133 profile_, site_instance, MSG_ROUTING_NONE, NULL, NULL)); |
| 133 TabContentsObserver::Observe(host_contents_.get()); | 134 TabContentsObserver::Observe(host_contents_.get()); |
| 134 host_contents_->set_delegate(this); | 135 host_contents_->set_delegate(this); |
| 135 host_contents_->set_view_type(host_type); | 136 host_contents_->set_view_type(host_type); |
| 136 | 137 |
| 138 // TODO(mpcomplete): This was lifted from PrefsTabHelper, but it might be |
| 139 // better to reuse all of PrefsTabHelper. We'd first have to make it not |
| 140 // depend on TabContentsWrapper. |
| 141 renderer_preferences_util::UpdateFromSystemSettings( |
| 142 host_contents_->GetMutableRendererPrefs(), profile_); |
| 143 |
| 137 render_view_host_ = host_contents_->render_view_host(); | 144 render_view_host_ = host_contents_->render_view_host(); |
| 138 | 145 |
| 139 // Listen for when an extension is unloaded from the same profile, as it may | 146 // Listen for when an extension is unloaded from the same profile, as it may |
| 140 // be the same extension that this points to. | 147 // be the same extension that this points to. |
| 141 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 148 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 142 content::Source<Profile>(profile_)); | 149 content::Source<Profile>(profile_)); |
| 143 } | 150 } |
| 144 | 151 |
| 145 // This "mock" constructor should only be used by unit tests. | 152 // This "mock" constructor should only be used by unit tests. |
| 146 ExtensionHost::ExtensionHost(const Extension* extension, | 153 ExtensionHost::ExtensionHost(const Extension* extension, |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 browser->AddTabContents(contents, disposition, initial_pos, user_gesture); | 524 browser->AddTabContents(contents, disposition, initial_pos, user_gesture); |
| 518 } | 525 } |
| 519 | 526 |
| 520 | 527 |
| 521 void ExtensionHost::RenderViewReady() { | 528 void ExtensionHost::RenderViewReady() { |
| 522 content::NotificationService::current()->Notify( | 529 content::NotificationService::current()->Notify( |
| 523 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 530 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 524 content::Source<Profile>(profile_), | 531 content::Source<Profile>(profile_), |
| 525 content::Details<ExtensionHost>(this)); | 532 content::Details<ExtensionHost>(this)); |
| 526 } | 533 } |
| OLD | NEW |