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_function_dispatcher.h" | 5 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "chrome/browser/extensions/extension_tts_api.h" | 46 #include "chrome/browser/extensions/extension_tts_api.h" |
47 #include "chrome/browser/extensions/extension_web_ui.h" | 47 #include "chrome/browser/extensions/extension_web_ui.h" |
48 #include "chrome/browser/extensions/extension_webrequest_api.h" | 48 #include "chrome/browser/extensions/extension_webrequest_api.h" |
49 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 49 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
50 #include "chrome/browser/extensions/extensions_quota_service.h" | 50 #include "chrome/browser/extensions/extensions_quota_service.h" |
51 #include "chrome/browser/external_protocol_handler.h" | 51 #include "chrome/browser/external_protocol_handler.h" |
52 #include "chrome/browser/metrics/user_metrics.h" | 52 #include "chrome/browser/metrics/user_metrics.h" |
53 #include "chrome/browser/profiles/profile.h" | 53 #include "chrome/browser/profiles/profile.h" |
54 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 54 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
55 #include "chrome/browser/ui/webui/favicon_source.h" | 55 #include "chrome/browser/ui/webui/favicon_source.h" |
56 #include "chrome/common/render_messages.h" | 56 #include "chrome/common/extensions/extension_messages.h" |
57 #include "chrome/common/render_messages_params.h" | |
58 #include "chrome/common/url_constants.h" | 57 #include "chrome/common/url_constants.h" |
59 #include "content/browser/renderer_host/render_process_host.h" | 58 #include "content/browser/renderer_host/render_process_host.h" |
60 #include "content/browser/renderer_host/render_view_host.h" | 59 #include "content/browser/renderer_host/render_view_host.h" |
61 #include "content/common/notification_service.h" | 60 #include "content/common/notification_service.h" |
62 #include "content/common/result_codes.h" | 61 #include "content/common/result_codes.h" |
63 #include "third_party/skia/include/core/SkBitmap.h" | 62 #include "third_party/skia/include/core/SkBitmap.h" |
64 | 63 |
65 #if defined(TOOLKIT_VIEWS) | 64 #if defined(TOOLKIT_VIEWS) |
66 #include "chrome/browser/extensions/extension_input_api.h" | 65 #include "chrome/browser/extensions/extension_input_api.h" |
67 #endif | 66 #endif |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // to make sure that the FaviconSource is registered with the | 413 // to make sure that the FaviconSource is registered with the |
415 // ChromeURLDataManager. | 414 // ChromeURLDataManager. |
416 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { | 415 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { |
417 FaviconSource* favicon_source = new FaviconSource(profile_); | 416 FaviconSource* favicon_source = new FaviconSource(profile_); |
418 profile_->GetChromeURLDataManager()->AddDataSource(favicon_source); | 417 profile_->GetChromeURLDataManager()->AddDataSource(favicon_source); |
419 } | 418 } |
420 | 419 |
421 // Update the extension permissions. Doing this each time we create an EFD | 420 // Update the extension permissions. Doing this each time we create an EFD |
422 // ensures that new processes are informed of permissions for newly installed | 421 // ensures that new processes are informed of permissions for newly installed |
423 // extensions. | 422 // extensions. |
424 render_view_host->Send(new ViewMsg_Extension_SetAPIPermissions( | 423 render_view_host->Send(new ExtensionMsg_SetAPIPermissions( |
425 extension->id(), extension->api_permissions())); | 424 extension->id(), extension->api_permissions())); |
426 render_view_host->Send(new ViewMsg_Extension_SetHostPermissions( | 425 render_view_host->Send(new ExtensionMsg_SetHostPermissions( |
427 extension->url(), extension->host_permissions())); | 426 extension->url(), extension->host_permissions())); |
428 | 427 |
429 NotificationService::current()->Notify( | 428 NotificationService::current()->Notify( |
430 NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED, | 429 NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED, |
431 Source<Profile>(profile_), | 430 Source<Profile>(profile_), |
432 Details<ExtensionFunctionDispatcher>(this)); | 431 Details<ExtensionFunctionDispatcher>(this)); |
433 } | 432 } |
434 | 433 |
435 ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { | 434 ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { |
436 peer_->dispatcher_ = NULL; | 435 peer_->dispatcher_ = NULL; |
(...skipping 24 matching lines...) Expand all Loading... |
461 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, | 460 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, |
462 // a background_page onload chrome.tabs api call can make it into here | 461 // a background_page onload chrome.tabs api call can make it into here |
463 // before the browser is sufficiently initialized to return here. | 462 // before the browser is sufficiently initialized to return here. |
464 // A similar situation may arise during shutdown. | 463 // A similar situation may arise during shutdown. |
465 // TODO(rafaelw): Delay creation of background_page until the browser | 464 // TODO(rafaelw): Delay creation of background_page until the browser |
466 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 | 465 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
467 return browser; | 466 return browser; |
468 } | 467 } |
469 | 468 |
470 void ExtensionFunctionDispatcher::HandleRequest( | 469 void ExtensionFunctionDispatcher::HandleRequest( |
471 const ViewHostMsg_DomMessage_Params& params) { | 470 const ExtensionHostMsg_DomMessage_Params& params) { |
472 scoped_refptr<ExtensionFunction> function( | 471 scoped_refptr<ExtensionFunction> function( |
473 FactoryRegistry::GetInstance()->NewFunction(params.name)); | 472 FactoryRegistry::GetInstance()->NewFunction(params.name)); |
474 function->set_dispatcher_peer(peer_); | 473 function->set_dispatcher_peer(peer_); |
475 function->set_profile(profile_); | 474 function->set_profile(profile_); |
476 function->set_extension_id(extension_id()); | 475 function->set_extension_id(extension_id()); |
477 function->SetArgs(¶ms.arguments); | 476 function->SetArgs(¶ms.arguments); |
478 function->set_source_url(params.source_url); | 477 function->set_source_url(params.source_url); |
479 function->set_request_id(params.request_id); | 478 function->set_request_id(params.request_id); |
480 function->set_has_callback(params.has_callback); | 479 function->set_has_callback(params.has_callback); |
481 function->set_user_gesture(params.user_gesture); | 480 function->set_user_gesture(params.user_gesture); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 NOTREACHED(); | 520 NOTREACHED(); |
522 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_EFD")); | 521 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_EFD")); |
523 base::KillProcess(render_view_host_->process()->GetHandle(), | 522 base::KillProcess(render_view_host_->process()->GetHandle(), |
524 ResultCodes::KILLED_BAD_MESSAGE, false); | 523 ResultCodes::KILLED_BAD_MESSAGE, false); |
525 } | 524 } |
526 } | 525 } |
527 | 526 |
528 Profile* ExtensionFunctionDispatcher::profile() { | 527 Profile* ExtensionFunctionDispatcher::profile() { |
529 return profile_; | 528 return profile_; |
530 } | 529 } |
OLD | NEW |