OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/guest_view/chrome_guest_view_manager_delegate.h" | 5 #include "chrome/browser/guest_view/chrome_guest_view_manager_delegate.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "components/framelet/browser/framelet_guest.h" |
8 #include "chrome/browser/task_management/web_contents_tags.h" | |
9 | 8 |
10 #if defined(OS_CHROMEOS) | 9 namespace chrome { |
11 #include "chrome/browser/chromeos/app_mode/app_session.h" | |
12 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | |
13 #endif | |
14 | 10 |
15 namespace extensions { | 11 // static |
16 | 12 guest_view::GuestViewManagerDelegate* ChromeGuestViewManagerDelegate::Create( |
17 ChromeGuestViewManagerDelegate::ChromeGuestViewManagerDelegate( | 13 content::BrowserContext* browser_context) { |
18 content::BrowserContext* context) | 14 return new ChromeGuestViewManagerDelegate(browser_context); |
19 : ExtensionsGuestViewManagerDelegate(context) { | |
20 } | 15 } |
21 | 16 |
22 ChromeGuestViewManagerDelegate::~ChromeGuestViewManagerDelegate() { | 17 ChromeGuestViewManagerDelegate::~ChromeGuestViewManagerDelegate() { |
23 } | 18 } |
24 | 19 |
25 void ChromeGuestViewManagerDelegate::OnGuestAdded( | 20 void ChromeGuestViewManagerDelegate::DispatchEvent( |
26 content::WebContents* guest_web_contents) const { | 21 const std::string& event_name, |
27 // Attaches the task-manager-specific tag for the GuestViews to its | 22 scoped_ptr<base::DictionaryValue> args, |
28 // |guest_web_contents| so that their corresponding tasks show up in the task | 23 guest_view::GuestViewBase* guest, |
29 // manager. | 24 int instance_id) { |
30 task_management::WebContentsTags::CreateForGuestContents(guest_web_contents); | 25 // TODO(paulmeyer): Implement special case for framelet. |
| 26 GuestViewManagerDelegateBase::DispatchEvent(event_name, std::move(args), |
| 27 guest, instance_id); |
| 28 } |
31 | 29 |
32 #if defined(OS_CHROMEOS) | 30 bool ChromeGuestViewManagerDelegate::IsGuestAvailableToContext( |
33 // Notifies kiosk session about the added guest. | 31 guest_view::GuestViewBase* guest) { |
34 chromeos::AppSession* app_session = | 32 // Framelet is available in any context including the drive-by web. |
35 chromeos::KioskAppManager::Get()->app_session(); | 33 if (guest->IsViewType(framelet::FrameletGuest::Type)) |
36 if (app_session) | 34 return true; |
37 app_session->OnGuestAdded(guest_web_contents); | 35 return GuestViewManagerDelegateBase::IsGuestAvailableToContext(guest); |
| 36 } |
| 37 |
| 38 void ChromeGuestViewManagerDelegate::RegisterAdditionalGuestViewTypes() { |
| 39 guest_view::GuestViewManager* manager = |
| 40 guest_view::GuestViewManager::FromBrowserContext(context_); |
| 41 manager->RegisterGuestViewType<framelet::FrameletGuest>(); |
| 42 GuestViewManagerDelegateBase::RegisterAdditionalGuestViewTypes(); |
| 43 } |
| 44 |
| 45 ChromeGuestViewManagerDelegate::ChromeGuestViewManagerDelegate( |
| 46 content::BrowserContext* context) |
| 47 #if defined(ENABLE_EXTENSIONS) |
| 48 : GuestViewManagerDelegateBase(context) { |
| 49 #else |
| 50 : GuestViewManagerDelegateBase(), context_(context) { |
38 #endif | 51 #endif |
39 } | 52 } |
40 | 53 |
41 } // namespace extensions | 54 } // namespace chrome |
OLD | NEW |