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/api/generated_api_functions.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_tab_util.h" | 19 #include "chrome/browser/extensions/extension_tab_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" | 21 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" |
21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
24 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 25 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
26 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 465 } |
465 UnhandledKeyboardEvent(event); | 466 UnhandledKeyboardEvent(event); |
466 } | 467 } |
467 | 468 |
468 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { | 469 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { |
469 bool handled = true; | 470 bool handled = true; |
470 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) | 471 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) |
471 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 472 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
472 IPC_MESSAGE_UNHANDLED(handled = false) | 473 IPC_MESSAGE_UNHANDLED(handled = false) |
473 IPC_END_MESSAGE_MAP() | 474 IPC_END_MESSAGE_MAP() |
| 475 |
| 476 if (!handled) { |
| 477 scoped_ptr<extensions::ExtensionAPIHost> extension_api_host( |
| 478 new extensions::ExtensionAPIHost(render_view_host_, |
| 479 &extension_function_dispatcher_)); |
| 480 handled = extension_api_host->OnMessageReceived(message); |
| 481 } |
| 482 |
474 return handled; | 483 return handled; |
475 } | 484 } |
476 | 485 |
477 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 486 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
478 extension_function_dispatcher_.Dispatch(params, render_view_host()); | 487 extension_function_dispatcher_.Dispatch(params, render_view_host()); |
479 } | 488 } |
480 | 489 |
481 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { | 490 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { |
482 render_view_host_ = render_view_host; | 491 render_view_host_ = render_view_host; |
483 | 492 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 params.user_gesture = user_gesture; | 575 params.user_gesture = user_gesture; |
567 browser::Navigate(¶ms); | 576 browser::Navigate(¶ms); |
568 } | 577 } |
569 | 578 |
570 void ExtensionHost::RenderViewReady() { | 579 void ExtensionHost::RenderViewReady() { |
571 content::NotificationService::current()->Notify( | 580 content::NotificationService::current()->Notify( |
572 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, | 581 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
573 content::Source<Profile>(profile_), | 582 content::Source<Profile>(profile_), |
574 content::Details<ExtensionHost>(this)); | 583 content::Details<ExtensionHost>(this)); |
575 } | 584 } |
OLD | NEW |