OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 5 |
6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" | 6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" |
7 | 7 |
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
9 #include "chrome/browser/favicon/favicon_helper.h" | 9 #include "chrome/browser/favicon/favicon_helper.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 11 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
12 #include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h" | 12 #include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h" |
13 #include "chrome/common/chrome_version_info.h" | 13 #include "chrome/common/chrome_version_info.h" |
14 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" | 14 #include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
15 #include "components/guest_view/browser/guest_view_event.h" | 15 #include "components/guest_view/browser/guest_view_event.h" |
16 #include "components/pdf/browser/pdf_web_contents_helper.h" | |
17 #include "components/renderer_context_menu/context_menu_delegate.h" | 16 #include "components/renderer_context_menu/context_menu_delegate.h" |
18 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
19 #include "extensions/browser/api/web_request/web_request_api.h" | 18 #include "extensions/browser/api/web_request/web_request_api.h" |
20 #include "extensions/browser/guest_view/web_view/web_view_constants.h" | 19 #include "extensions/browser/guest_view/web_view/web_view_constants.h" |
21 | 20 |
22 #if defined(ENABLE_PRINTING) | |
23 #if defined(ENABLE_PRINT_PREVIEW) | |
24 #include "chrome/browser/printing/print_preview_message_handler.h" | |
25 #include "chrome/browser/printing/print_view_manager.h" | |
26 #else | |
27 #include "chrome/browser/printing/print_view_manager_basic.h" | |
28 #endif // defined(ENABLE_PRINT_PREVIEW) | |
29 #endif // defined(ENABLE_PRINTING) | |
30 | |
31 using guest_view::GuestViewEvent; | 21 using guest_view::GuestViewEvent; |
32 | 22 |
33 namespace extensions { | 23 namespace extensions { |
34 | 24 |
35 ChromeWebViewGuestDelegate::ChromeWebViewGuestDelegate( | 25 ChromeWebViewGuestDelegate::ChromeWebViewGuestDelegate( |
36 WebViewGuest* web_view_guest) | 26 WebViewGuest* web_view_guest) |
37 : pending_context_menu_request_id_(0), | 27 : pending_context_menu_request_id_(0), |
38 chromevox_injected_(false), | 28 chromevox_injected_(false), |
39 web_view_guest_(web_view_guest), | 29 web_view_guest_(web_view_guest), |
40 weak_ptr_factory_(this) { | 30 weak_ptr_factory_(this) { |
(...skipping 20 matching lines...) Expand all Loading... | |
61 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 51 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
62 scoped_ptr<base::ListValue> items = | 52 scoped_ptr<base::ListValue> items = |
63 MenuModelToValue(pending_menu_->menu_model()); | 53 MenuModelToValue(pending_menu_->menu_model()); |
64 args->Set(webview::kContextMenuItems, items.release()); | 54 args->Set(webview::kContextMenuItems, items.release()); |
65 args->SetInteger(webview::kRequestId, request_id); | 55 args->SetInteger(webview::kRequestId, request_id); |
66 web_view_guest()->DispatchEventToView( | 56 web_view_guest()->DispatchEventToView( |
67 new GuestViewEvent(webview::kEventContextMenuShow, args.Pass())); | 57 new GuestViewEvent(webview::kEventContextMenuShow, args.Pass())); |
68 return true; | 58 return true; |
69 } | 59 } |
70 | 60 |
71 // TODO(hanxi) Investigate which of these observers should move to the | |
72 // extension module in the future. | |
73 void ChromeWebViewGuestDelegate::OnAttachWebViewHelpers( | |
74 content::WebContents* contents) { | |
75 favicon::CreateContentFaviconDriverForWebContents(contents); | |
76 ChromeExtensionWebContentsObserver::CreateForWebContents(contents); | |
77 #if defined(ENABLE_PRINTING) | |
78 #if defined(ENABLE_PRINT_PREVIEW) | |
79 printing::PrintViewManager::CreateForWebContents(contents); | |
80 printing::PrintPreviewMessageHandler::CreateForWebContents(contents); | |
81 #else | |
82 printing::PrintViewManagerBasic::CreateForWebContents(contents); | |
83 #endif // defined(ENABLE_PRINT_PREVIEW) | |
84 #endif // defined(ENABLE_PRINTING) | |
85 pdf::PDFWebContentsHelper::CreateForWebContentsWithClient( | |
86 contents, | |
87 scoped_ptr<pdf::PDFWebContentsHelperClient>( | |
88 new ChromePDFWebContentsHelperClient())); | |
89 } | |
Fady Samuel
2015/06/10 20:51:18
Wow, have you moved all of this into extensions? I
Devlin
2015/06/10 20:59:20
This all moved into the ChromeExtensionAPIClient::
| |
90 | |
91 void ChromeWebViewGuestDelegate::OnDidInitialize() { | 61 void ChromeWebViewGuestDelegate::OnDidInitialize() { |
92 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
93 chromeos::AccessibilityManager* accessibility_manager = | 63 chromeos::AccessibilityManager* accessibility_manager = |
94 chromeos::AccessibilityManager::Get(); | 64 chromeos::AccessibilityManager::Get(); |
95 CHECK(accessibility_manager); | 65 CHECK(accessibility_manager); |
96 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 66 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
97 base::Bind(&ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged, | 67 base::Bind(&ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged, |
98 weak_ptr_factory_.GetWeakPtr())); | 68 weak_ptr_factory_.GetWeakPtr())); |
99 #endif | 69 #endif |
100 } | 70 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { | 135 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { |
166 if (details.enabled) | 136 if (details.enabled) |
167 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); | 137 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); |
168 else | 138 else |
169 chromevox_injected_ = false; | 139 chromevox_injected_ = false; |
170 } | 140 } |
171 } | 141 } |
172 #endif | 142 #endif |
173 | 143 |
174 } // namespace extensions | 144 } // namespace extensions |
OLD | NEW |