| 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/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_event_router.h" | 17 #include "chrome/browser/extensions/extension_event_router.h" |
| 18 #include "chrome/browser/extensions/extension_process_manager.h" | 18 #include "chrome/browser/extensions/extension_process_manager.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
| 21 #include "chrome/browser/extensions/extension_tab_util.h" | 21 #include "chrome/browser/extensions/extension_tab_util.h" |
| 22 #include "chrome/browser/extensions/extension_window_controller.h" | 22 #include "chrome/browser/extensions/window_controller.h" |
| 23 #include "chrome/browser/file_select_helper.h" | 23 #include "chrome/browser/file_select_helper.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" | 25 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" |
| 26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 30 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
| 31 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 31 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 32 #include "chrome/browser/view_type_utils.h" | 32 #include "chrome/browser/view_type_utils.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 223 } |
| 224 | 224 |
| 225 void ExtensionHost::CreateRenderViewNow() { | 225 void ExtensionHost::CreateRenderViewNow() { |
| 226 LoadInitialURL(); | 226 LoadInitialURL(); |
| 227 if (is_background_page()) { | 227 if (is_background_page()) { |
| 228 DCHECK(IsRenderViewLive()); | 228 DCHECK(IsRenderViewLive()); |
| 229 profile_->GetExtensionService()->DidCreateRenderViewForBackgroundPage(this); | 229 profile_->GetExtensionService()->DidCreateRenderViewForBackgroundPage(this); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 ExtensionWindowController* ExtensionHost::GetExtensionWindowController() const { | 233 extensions::WindowController* |
| 234 ExtensionHost::GetExtensionWindowController() const { |
| 234 return view() && view()->browser() ? | 235 return view() && view()->browser() ? |
| 235 view()->browser()->extension_window_controller() : NULL; | 236 view()->browser()->extension_window_controller() : NULL; |
| 236 } | 237 } |
| 237 | 238 |
| 238 const GURL& ExtensionHost::GetURL() const { | 239 const GURL& ExtensionHost::GetURL() const { |
| 239 return host_contents()->GetURL(); | 240 return host_contents()->GetURL(); |
| 240 } | 241 } |
| 241 | 242 |
| 242 void ExtensionHost::LoadInitialURL() { | 243 void ExtensionHost::LoadInitialURL() { |
| 243 if (!is_background_page() && | 244 if (!is_background_page() && |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 } | 530 } |
| 530 | 531 |
| 531 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 532 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
| 532 render_view_host_ = render_view_host; | 533 render_view_host_ = render_view_host; |
| 533 | 534 |
| 534 if (view()) | 535 if (view()) |
| 535 view()->RenderViewCreated(); | 536 view()->RenderViewCreated(); |
| 536 | 537 |
| 537 // If the host is bound to a window, then extract its id. Extensions hosted | 538 // If the host is bound to a window, then extract its id. Extensions hosted |
| 538 // in ExternalTabContainer objects may not have an associated window. | 539 // in ExternalTabContainer objects may not have an associated window. |
| 539 ExtensionWindowController* window = GetExtensionWindowController(); | 540 extensions::WindowController* window = GetExtensionWindowController(); |
| 540 if (window) { | 541 if (window) { |
| 541 render_view_host->Send(new ExtensionMsg_UpdateBrowserWindowId( | 542 render_view_host->Send(new ExtensionMsg_UpdateBrowserWindowId( |
| 542 render_view_host->GetRoutingID(), window->GetWindowId())); | 543 render_view_host->GetRoutingID(), window->GetWindowId())); |
| 543 } | 544 } |
| 544 } | 545 } |
| 545 | 546 |
| 546 void ExtensionHost::RenderViewDeleted(RenderViewHost* render_view_host) { | 547 void ExtensionHost::RenderViewDeleted(RenderViewHost* render_view_host) { |
| 547 // If our RenderViewHost is deleted, fall back to the host_contents' current | 548 // If our RenderViewHost is deleted, fall back to the host_contents' current |
| 548 // RVH. There is sometimes a small gap between the pending RVH being deleted | 549 // RVH. There is sometimes a small gap between the pending RVH being deleted |
| 549 // and RenderViewCreated being called, so we update it here. | 550 // and RenderViewCreated being called, so we update it here. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 ExtensionTabUtil::CreateTab(new_contents, extension_id_, disposition, | 591 ExtensionTabUtil::CreateTab(new_contents, extension_id_, disposition, |
| 591 initial_pos, user_gesture); | 592 initial_pos, user_gesture); |
| 592 } | 593 } |
| 593 | 594 |
| 594 void ExtensionHost::RenderViewReady() { | 595 void ExtensionHost::RenderViewReady() { |
| 595 content::NotificationService::current()->Notify( | 596 content::NotificationService::current()->Notify( |
| 596 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 597 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 597 content::Source<Profile>(profile_), | 598 content::Source<Profile>(profile_), |
| 598 content::Details<ExtensionHost>(this)); | 599 content::Details<ExtensionHost>(this)); |
| 599 } | 600 } |
| OLD | NEW |