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( | |
|
groby-ooo-7-16
2012/07/31 19:26:17
This seems to have odd ownership rules for intents
Greg Billock
2012/08/01 17:02:26
Yes, callee takes ownership. This is documented in
groby-ooo-7-16
2012/08/01 18:17:06
In this case, please use scoped_ptr. (And .release
Greg Billock
2012/08/07 00:23:57
Done.
| |
| 423 content::WebContents* web_contents, | |
| 424 content::WebIntentsDispatcher* intents_dispatcher) { | |
| 425 | |
| 426 Browser* browser = view() ? view()->browser() | |
| 427 : browser::FindBrowserWithWebContents(web_contents); | |
| 428 | |
| 429 // For background scripts/pages, there will be no view(). In this case, we | |
| 430 // want to treat the intent as a browser-initiated one and deliver it into the | |
| 431 // current browser. It probably came from a context menu click or similar. | |
| 432 if (!browser) | |
| 433 browser = web_intents::GetWebIntentDeliveryBrowser(profile()); | |
| 434 | |
| 435 if (browser) { | |
| 436 static_cast<WebContentsDelegate*>(browser)-> | |
| 437 WebIntentDispatch(NULL, intents_dispatcher); | |
| 438 return; | |
| 439 } | |
| 440 | |
| 441 delete intents_dispatcher; | |
| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 ExtensionTabUtil::CreateTab(new_contents, extension_id_, disposition, | 615 ExtensionTabUtil::CreateTab(new_contents, extension_id_, disposition, |
| 593 initial_pos, user_gesture); | 616 initial_pos, user_gesture); |
| 594 } | 617 } |
| 595 | 618 |
| 596 void ExtensionHost::RenderViewReady() { | 619 void ExtensionHost::RenderViewReady() { |
| 597 content::NotificationService::current()->Notify( | 620 content::NotificationService::current()->Notify( |
| 598 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 621 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 599 content::Source<Profile>(profile_), | 622 content::Source<Profile>(profile_), |
| 600 content::Details<ExtensionHost>(this)); | 623 content::Details<ExtensionHost>(this)); |
| 601 } | 624 } |
| OLD | NEW |