OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/renderer_host/chrome_navigation_ui_data.h" | 5 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/sessions/session_tab_helper.h" | 8 #include "chrome/browser/sessions/session_tab_helper.h" |
9 #include "content/public/browser/navigation_handle.h" | 9 #include "content/public/browser/navigation_handle.h" |
10 #include "content/public/browser/render_frame_host.h" | |
11 #include "content/public/browser/render_process_host.h" | |
12 #include "content/public/browser/site_instance.h" | |
13 #include "content/public/browser/web_contents.h" | |
14 | |
15 #if defined(ENABLE_EXTENSIONS) | |
16 #include "extensions/browser/extension_registry.h" | |
17 #endif | |
10 | 18 |
11 ChromeNavigationUIData::ChromeNavigationUIData() {} | 19 ChromeNavigationUIData::ChromeNavigationUIData() {} |
12 | 20 |
13 ChromeNavigationUIData::ChromeNavigationUIData( | 21 ChromeNavigationUIData::ChromeNavigationUIData( |
14 content::NavigationHandle* navigation_handle) { | 22 content::NavigationHandle* navigation_handle) { |
15 #if defined(ENABLE_EXTENSIONS) | 23 #if defined(ENABLE_EXTENSIONS) |
24 content::WebContents* web_contents = navigation_handle->GetWebContents(); | |
16 SessionTabHelper* session_tab_helper = | 25 SessionTabHelper* session_tab_helper = |
17 SessionTabHelper::FromWebContents(navigation_handle->GetWebContents()); | 26 SessionTabHelper::FromWebContents(web_contents); |
18 int tab_id = session_tab_helper ? session_tab_helper->session_id().id() : -1; | 27 int tab_id = session_tab_helper ? session_tab_helper->session_id().id() : -1; |
19 int window_id = | 28 int window_id = |
20 session_tab_helper ? session_tab_helper->window_id().id() : -1; | 29 session_tab_helper ? session_tab_helper->window_id().id() : -1; |
30 bool from_extension = false; | |
31 extensions::ExtensionRegistry* registry = extensions::ExtensionRegistry::Get( | |
32 web_contents->GetBrowserContext()); | |
33 if (registry) { | |
34 const extensions::Extension* extension = | |
35 registry->enabled_extensions().GetExtensionOrAppByURL( | |
36 web_contents->GetSiteInstance()->GetSiteURL()); | |
alexmos
2016/10/06 22:37:28
Wouldn't going via web_contents be wrong for OOP s
jam
2016/10/06 22:54:31
Right we wouldn't have a RenderFrameHost yet.
Are
alexmos
2016/10/07 01:47:47
Yes, with --isolate-extensions, a top-level extens
jam
2016/10/10 15:36:50
Do you have steps I can use to repro this?
i.e. if
alexmos
2016/10/10 17:04:21
AFAIK extensions aren't allowed to use <webview>,
jam
2016/10/10 21:48:15
I should have been more precise, I meant guestview
| |
37 from_extension = !!extension; | |
38 } | |
21 extension_data_ = base::MakeUnique<extensions::ExtensionNavigationUIData>( | 39 extension_data_ = base::MakeUnique<extensions::ExtensionNavigationUIData>( |
22 navigation_handle, tab_id, window_id); | 40 navigation_handle, from_extension, tab_id, window_id); |
23 #endif | 41 #endif |
24 } | 42 } |
25 | 43 |
26 ChromeNavigationUIData::~ChromeNavigationUIData() {} | 44 ChromeNavigationUIData::~ChromeNavigationUIData() {} |
27 | 45 |
28 std::unique_ptr<content::NavigationUIData> ChromeNavigationUIData::Clone() | 46 std::unique_ptr<content::NavigationUIData> ChromeNavigationUIData::Clone() |
29 const { | 47 const { |
30 std::unique_ptr<ChromeNavigationUIData> copy = | 48 std::unique_ptr<ChromeNavigationUIData> copy = |
31 base::MakeUnique<ChromeNavigationUIData>(); | 49 base::MakeUnique<ChromeNavigationUIData>(); |
32 | 50 |
33 #if defined(ENABLE_EXTENSIONS) | 51 #if defined(ENABLE_EXTENSIONS) |
34 if (extension_data_) | 52 if (extension_data_) |
35 copy->SetExtensionNavigationUIData(extension_data_->DeepCopy()); | 53 copy->SetExtensionNavigationUIData(extension_data_->DeepCopy()); |
36 #endif | 54 #endif |
37 | 55 |
38 return std::move(copy); | 56 return std::move(copy); |
39 } | 57 } |
40 | 58 |
41 #if defined(ENABLE_EXTENSIONS) | 59 #if defined(ENABLE_EXTENSIONS) |
42 void ChromeNavigationUIData::SetExtensionNavigationUIData( | 60 void ChromeNavigationUIData::SetExtensionNavigationUIData( |
43 std::unique_ptr<extensions::ExtensionNavigationUIData> extension_data) { | 61 std::unique_ptr<extensions::ExtensionNavigationUIData> extension_data) { |
44 extension_data_ = std::move(extension_data); | 62 extension_data_ = std::move(extension_data); |
45 } | 63 } |
46 #endif | 64 #endif |
OLD | NEW |