Chromium Code Reviews| 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" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "chrome/common/render_messages.h" | 38 #include "chrome/common/render_messages.h" |
| 39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 40 #include "content/public/browser/content_browser_client.h" | 40 #include "content/public/browser/content_browser_client.h" |
| 41 #include "content/public/browser/native_web_keyboard_event.h" | 41 #include "content/public/browser/native_web_keyboard_event.h" |
| 42 #include "content/public/browser/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
| 43 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
| 44 #include "content/public/browser/render_view_host.h" | 44 #include "content/public/browser/render_view_host.h" |
| 45 #include "content/public/browser/site_instance.h" | 45 #include "content/public/browser/site_instance.h" |
| 46 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 47 #include "content/public/browser/web_contents_view.h" | 47 #include "content/public/browser/web_contents_view.h" |
| 48 #include "content/public/browser/web_intents_dispatcher.h" | |
| 48 #include "grit/browser_resources.h" | 49 #include "grit/browser_resources.h" |
| 49 #include "grit/chromium_strings.h" | 50 #include "grit/chromium_strings.h" |
| 50 #include "grit/generated_resources.h" | 51 #include "grit/generated_resources.h" |
| 51 #include "ui/base/keycodes/keyboard_codes.h" | 52 #include "ui/base/keycodes/keyboard_codes.h" |
| 52 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "ui/base/layout.h" | 54 #include "ui/base/layout.h" |
| 54 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
| 55 | 56 |
| 56 using WebKit::WebDragOperation; | 57 using WebKit::WebDragOperation; |
| 57 using WebKit::WebDragOperationsMask; | 58 using WebKit::WebDragOperationsMask; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 void ExtensionHost::OnStartDownload( | 412 void ExtensionHost::OnStartDownload( |
| 412 content::WebContents* source, content::DownloadItem* download) { | 413 content::WebContents* source, content::DownloadItem* download) { |
| 413 // If |source| is in the context of a Browser, show the DownloadShelf on that | 414 // If |source| is in the context of a Browser, show the DownloadShelf on that |
| 414 // Browser. | 415 // Browser. |
| 415 if (!view() || !view()->browser()) | 416 if (!view() || !view()->browser()) |
| 416 return; | 417 return; |
| 417 static_cast<content::WebContentsDelegate*>(view()->browser())-> | 418 static_cast<content::WebContentsDelegate*>(view()->browser())-> |
| 418 OnStartDownload(source, download); | 419 OnStartDownload(source, download); |
| 419 } | 420 } |
| 420 | 421 |
| 422 void ExtensionHost::WebIntentDispatch( | |
| 423 content::WebContents* web_contents, | |
| 424 content::WebIntentsDispatcher* intents_dispatcher) { | |
| 425 scoped_ptr<content::WebIntentsDispatcher> dispatcher(intents_dispatcher); | |
| 426 | |
| 427 Browser* browser = view() ? view()->browser() | |
| 428 : browser::FindBrowserWithWebContents(web_contents); | |
|
Ben Goodger (Google)
2012/08/07 21:18:16
Browser* browser = view() ? view()->browser() :
Greg Billock
2012/08/07 22:48:45
Done.
| |
| 429 | |
| 430 // For background scripts/pages, there will be no view(). In this case, we | |
| 431 // want to treat the intent as a browser-initiated one and deliver it into the | |
| 432 // current browser. It probably came from a context menu click or similar. | |
| 433 if (!browser) | |
| 434 browser = web_intents::GetWebIntentDeliveryBrowser(profile()); | |
| 435 | |
| 436 if (browser) { | |
| 437 static_cast<WebContentsDelegate*>(browser)-> | |
| 438 WebIntentDispatch(NULL, dispatcher.release()); | |
| 439 return; | |
|
Ben Goodger (Google)
2012/08/07 21:18:16
return seems unnecessary
Greg Billock
2012/08/07 22:48:45
Done. Forgot to kill this after switching to scope
| |
| 440 } | |
| 441 } | |
| 442 | |
| 421 void ExtensionHost::WillRunJavaScriptDialog() { | 443 void ExtensionHost::WillRunJavaScriptDialog() { |
| 422 ExtensionProcessManager* pm = | 444 ExtensionProcessManager* pm = |
| 423 ExtensionSystem::Get(profile_)->process_manager(); | 445 ExtensionSystem::Get(profile_)->process_manager(); |
| 424 if (pm) | 446 if (pm) |
| 425 pm->IncrementLazyKeepaliveCount(extension()); | 447 pm->IncrementLazyKeepaliveCount(extension()); |
| 426 } | 448 } |
| 427 | 449 |
| 428 void ExtensionHost::DidCloseJavaScriptDialog() { | 450 void ExtensionHost::DidCloseJavaScriptDialog() { |
| 429 ExtensionProcessManager* pm = | 451 ExtensionProcessManager* pm = |
| 430 ExtensionSystem::Get(profile_)->process_manager(); | 452 ExtensionSystem::Get(profile_)->process_manager(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 } | 616 } |
| 595 | 617 |
| 596 void ExtensionHost::RenderViewReady() { | 618 void ExtensionHost::RenderViewReady() { |
| 597 content::NotificationService::current()->Notify( | 619 content::NotificationService::current()->Notify( |
| 598 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 620 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 599 content::Source<Profile>(profile_), | 621 content::Source<Profile>(profile_), |
| 600 content::Details<ExtensionHost>(this)); | 622 content::Details<ExtensionHost>(this)); |
| 601 } | 623 } |
| 602 | 624 |
| 603 } // namespace extensions | 625 } // namespace extensions |
| OLD | NEW |