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/menu_manager.h" | 5 #include "chrome/browser/extensions/menu_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_tab_util.h" | 17 #include "chrome/browser/extensions/extension_tab_util.h" |
18 #include "chrome/browser/extensions/menu_manager_factory.h" | 18 #include "chrome/browser/extensions/menu_manager_factory.h" |
19 #include "chrome/browser/extensions/tab_helper.h" | 19 #include "chrome/browser/extensions/tab_helper.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/common/extensions/api/chrome_web_view_internal.h" |
21 #include "chrome/common/extensions/api/context_menus.h" | 22 #include "chrome/common/extensions/api/context_menus.h" |
22 #include "chrome/common/extensions/api/web_view_internal.h" | |
23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/context_menu_params.h" | 27 #include "content/public/common/context_menu_params.h" |
28 #include "extensions/browser/event_router.h" | 28 #include "extensions/browser/event_router.h" |
29 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
30 #include "extensions/browser/extension_system.h" | 30 #include "extensions/browser/extension_system.h" |
31 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 31 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
32 #include "extensions/browser/state_store.h" | 32 #include "extensions/browser/state_store.h" |
33 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
34 #include "extensions/common/manifest_handlers/background_info.h" | 34 #include "extensions/common/manifest_handlers/background_info.h" |
35 #include "ui/gfx/favicon_size.h" | 35 #include "ui/gfx/favicon_size.h" |
36 #include "ui/gfx/text_elider.h" | 36 #include "ui/gfx/text_elider.h" |
37 | 37 |
38 using content::WebContents; | 38 using content::WebContents; |
39 using extensions::ExtensionSystem; | 39 using extensions::ExtensionSystem; |
40 | 40 |
41 namespace extensions { | 41 namespace extensions { |
42 | 42 |
43 namespace context_menus = api::context_menus; | 43 namespace context_menus = api::context_menus; |
44 namespace web_view = api::web_view_internal; | 44 namespace chrome_web_view = api::chrome_web_view_internal; |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // Keys for serialization to and from Value to store in the preferences. | 48 // Keys for serialization to and from Value to store in the preferences. |
49 const char kContextMenusKey[] = "context_menus"; | 49 const char kContextMenusKey[] = "context_menus"; |
50 | 50 |
51 const char kCheckedKey[] = "checked"; | 51 const char kCheckedKey[] = "checked"; |
52 const char kContextsKey[] = "contexts"; | 52 const char kContextsKey[] = "contexts"; |
53 const char kDocumentURLPatternsKey[] = "document_url_patterns"; | 53 const char kDocumentURLPatternsKey[] = "document_url_patterns"; |
54 const char kEnabledKey[] = "enabled"; | 54 const char kEnabledKey[] = "enabled"; |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 new Event(webview_guest ? kOnWebviewContextMenus | 705 new Event(webview_guest ? kOnWebviewContextMenus |
706 : kOnContextMenus, | 706 : kOnContextMenus, |
707 scoped_ptr<base::ListValue>(args->DeepCopy()))); | 707 scoped_ptr<base::ListValue>(args->DeepCopy()))); |
708 event->restrict_to_browser_context = context; | 708 event->restrict_to_browser_context = context; |
709 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 709 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
710 event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); | 710 event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); |
711 } | 711 } |
712 { | 712 { |
713 // Dispatch to .contextMenus.onClicked handler. | 713 // Dispatch to .contextMenus.onClicked handler. |
714 scoped_ptr<Event> event( | 714 scoped_ptr<Event> event( |
715 new Event(webview_guest ? web_view::OnClicked::kEventName | 715 new Event(webview_guest ? chrome_web_view::OnClicked::kEventName |
716 : context_menus::OnClicked::kEventName, | 716 : context_menus::OnClicked::kEventName, |
717 args.Pass())); | 717 args.Pass())); |
718 event->restrict_to_browser_context = context; | 718 event->restrict_to_browser_context = context; |
719 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 719 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
720 if (webview_guest) | 720 if (webview_guest) |
721 event->filter_info.SetInstanceID(webview_guest->view_instance_id()); | 721 event->filter_info.SetInstanceID(webview_guest->view_instance_id()); |
722 event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); | 722 event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); |
723 } | 723 } |
724 } | 724 } |
725 | 725 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 if (uid < other.uid) | 946 if (uid < other.uid) |
947 return true; | 947 return true; |
948 if (uid == other.uid) | 948 if (uid == other.uid) |
949 return string_uid < other.string_uid; | 949 return string_uid < other.string_uid; |
950 } | 950 } |
951 } | 951 } |
952 return false; | 952 return false; |
953 } | 953 } |
954 | 954 |
955 } // namespace extensions | 955 } // namespace extensions |
OLD | NEW |