OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/renderer_host/chrome_navigation_ui_data.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/sessions/session_tab_helper.h" |
| 9 #include "content/public/browser/navigation_handle.h" |
| 10 |
| 11 ChromeNavigationUIData::ChromeNavigationUIData() {} |
| 12 |
| 13 ChromeNavigationUIData::ChromeNavigationUIData( |
| 14 content::NavigationHandle* navigation_handle) { |
| 15 #if defined(ENABLE_EXTENSIONS) |
| 16 SessionTabHelper* session_tab_helper = |
| 17 SessionTabHelper::FromWebContents(navigation_handle->GetWebContents()); |
| 18 int tab_id = session_tab_helper ? session_tab_helper->session_id().id() : -1; |
| 19 int window_id = |
| 20 session_tab_helper ? session_tab_helper->window_id().id() : -1; |
| 21 extension_data_ = base::MakeUnique<extensions::ExtensionNavigationUIData>( |
| 22 navigation_handle, tab_id, window_id); |
| 23 #endif |
| 24 } |
| 25 |
| 26 ChromeNavigationUIData::~ChromeNavigationUIData() {} |
| 27 |
| 28 std::unique_ptr<content::NavigationUIData> ChromeNavigationUIData::Clone() |
| 29 const { |
| 30 std::unique_ptr<ChromeNavigationUIData> copy = |
| 31 base::MakeUnique<ChromeNavigationUIData>(); |
| 32 |
| 33 #if defined(ENABLE_EXTENSIONS) |
| 34 if (extension_data_) |
| 35 copy->SetExtensionNavigationUIData(extension_data_->DeepCopy()); |
| 36 #endif |
| 37 |
| 38 return std::move(copy); |
| 39 } |
| 40 |
| 41 #if defined(ENABLE_EXTENSIONS) |
| 42 void ChromeNavigationUIData::SetExtensionNavigationUIData( |
| 43 std::unique_ptr<extensions::ExtensionNavigationUIData> extension_data) { |
| 44 extension_data_ = std::move(extension_data); |
| 45 } |
| 46 #endif |
OLD | NEW |