| 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/sessions/tab_restore_service_helper.h" | 5 #include "chrome/browser/sessions/tab_restore_service_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/sessions/session_types.h" | 14 #include "chrome/browser/sessions/session_types.h" |
| 15 #include "chrome/browser/sessions/tab_restore_service_delegate.h" | 15 #include "chrome/browser/sessions/tab_restore_service_delegate.h" |
| 16 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 16 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 17 #include "chrome/common/extensions/extension_constants.h" | |
| 18 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 19 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
| 20 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 21 #include "content/public/browser/session_storage_namespace.h" | 20 #include "content/public/browser/session_storage_namespace.h" |
| 22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 |
| 23 #if defined(ENABLE_EXTENSIONS) |
| 24 #include "chrome/browser/extensions/tab_helper.h" |
| 25 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" |
| 26 #include "chrome/common/extensions/extension_constants.h" |
| 23 #include "extensions/browser/extension_registry.h" | 27 #include "extensions/browser/extension_registry.h" |
| 24 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 25 #include "extensions/common/extension_set.h" | 29 #include "extensions/common/extension_set.h" |
| 26 | |
| 27 #if !defined(OS_ANDROID) | |
| 28 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | |
| 29 #endif | |
| 30 | |
| 31 #if defined(ENABLE_EXTENSIONS) | |
| 32 #include "chrome/browser/extensions/tab_helper.h" | |
| 33 #endif | 30 #endif |
| 34 | 31 |
| 35 using content::NavigationController; | 32 using content::NavigationController; |
| 36 using content::NavigationEntry; | 33 using content::NavigationEntry; |
| 37 using content::WebContents; | 34 using content::WebContents; |
| 38 | 35 |
| 39 namespace { | 36 namespace { |
| 40 | 37 |
| 41 void RecordAppLaunch(Profile* profile, const TabRestoreService::Tab& tab) { | 38 void RecordAppLaunch(Profile* profile, const TabRestoreService::Tab& tab) { |
| 42 #if !defined(OS_ANDROID) | 39 #if defined(ENABLE_EXTENSIONS) |
| 43 GURL url = tab.navigations.at(tab.current_navigation_index).virtual_url(); | 40 GURL url = tab.navigations.at(tab.current_navigation_index).virtual_url(); |
| 44 const extensions::Extension* extension = | 41 const extensions::Extension* extension = |
| 45 extensions::ExtensionRegistry::Get(profile) | 42 extensions::ExtensionRegistry::Get(profile) |
| 46 ->enabled_extensions().GetAppByURL(url); | 43 ->enabled_extensions().GetAppByURL(url); |
| 47 if (!extension) | 44 if (!extension) |
| 48 return; | 45 return; |
| 49 | 46 |
| 50 CoreAppLauncherHandler::RecordAppLaunchType( | 47 CoreAppLauncherHandler::RecordAppLaunchType( |
| 51 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, | 48 extension_misc::APP_LAUNCH_NTP_RECENTLY_CLOSED, |
| 52 extension->GetType()); | 49 extension->GetType()); |
| 53 #endif // !defined(OS_ANDROID) | 50 #endif // defined(ENABLE_EXTENSIONS) |
| 54 } | 51 } |
| 55 | 52 |
| 56 } // namespace | 53 } // namespace |
| 57 | 54 |
| 58 // TabRestoreServiceHelper::Observer ------------------------------------------- | 55 // TabRestoreServiceHelper::Observer ------------------------------------------- |
| 59 | 56 |
| 60 TabRestoreServiceHelper::Observer::~Observer() {} | 57 TabRestoreServiceHelper::Observer::~Observer() {} |
| 61 | 58 |
| 62 void TabRestoreServiceHelper::Observer::OnClearEntries() {} | 59 void TabRestoreServiceHelper::Observer::OnClearEntries() {} |
| 63 | 60 |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 Tab* tab = static_cast<Tab*>(entry); | 589 Tab* tab = static_cast<Tab*>(entry); |
| 593 if (tab->browser_id == old_id) | 590 if (tab->browser_id == old_id) |
| 594 tab->browser_id = new_id; | 591 tab->browser_id = new_id; |
| 595 } | 592 } |
| 596 } | 593 } |
| 597 } | 594 } |
| 598 | 595 |
| 599 base::Time TabRestoreServiceHelper::TimeNow() const { | 596 base::Time TabRestoreServiceHelper::TimeNow() const { |
| 600 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); | 597 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); |
| 601 } | 598 } |
| OLD | NEW |