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 #if !defined(OS_ANDROID) |
| 426 scoped_ptr<content::WebIntentsDispatcher> dispatcher(intents_dispatcher); |
| 427 |
| 428 Browser* browser = view() ? view()->browser() |
| 429 : browser::FindBrowserWithWebContents(web_contents); |
| 430 |
| 431 // For background scripts/pages, there will be no view(). In this case, we |
| 432 // want to treat the intent as a browser-initiated one and deliver it into the |
| 433 // current browser. It probably came from a context menu click or similar. |
| 434 if (!browser) |
| 435 browser = web_intents::GetBrowserForBackgroundWebIntentDelivery(profile()); |
| 436 |
| 437 if (browser) { |
| 438 static_cast<WebContentsDelegate*>(browser)-> |
| 439 WebIntentDispatch(NULL, dispatcher.release()); |
| 440 } |
| 441 #endif |
| 442 } |
| 443 |
421 void ExtensionHost::WillRunJavaScriptDialog() { | 444 void ExtensionHost::WillRunJavaScriptDialog() { |
422 ExtensionProcessManager* pm = | 445 ExtensionProcessManager* pm = |
423 ExtensionSystem::Get(profile_)->process_manager(); | 446 ExtensionSystem::Get(profile_)->process_manager(); |
424 if (pm) | 447 if (pm) |
425 pm->IncrementLazyKeepaliveCount(extension()); | 448 pm->IncrementLazyKeepaliveCount(extension()); |
426 } | 449 } |
427 | 450 |
428 void ExtensionHost::DidCloseJavaScriptDialog() { | 451 void ExtensionHost::DidCloseJavaScriptDialog() { |
429 ExtensionProcessManager* pm = | 452 ExtensionProcessManager* pm = |
430 ExtensionSystem::Get(profile_)->process_manager(); | 453 ExtensionSystem::Get(profile_)->process_manager(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 } | 620 } |
598 | 621 |
599 void ExtensionHost::RenderViewReady() { | 622 void ExtensionHost::RenderViewReady() { |
600 content::NotificationService::current()->Notify( | 623 content::NotificationService::current()->Notify( |
601 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 624 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
602 content::Source<Profile>(profile_), | 625 content::Source<Profile>(profile_), |
603 content::Details<ExtensionHost>(this)); | 626 content::Details<ExtensionHost>(this)); |
604 } | 627 } |
605 | 628 |
606 } // namespace extensions | 629 } // namespace extensions |
OLD | NEW |