| 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/ui/startup/startup_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "apps/app_restore_service.h" | 10 #include "apps/app_restore_service.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 #include "content/public/browser/dom_storage_context.h" | 85 #include "content/public/browser/dom_storage_context.h" |
| 86 #include "content/public/browser/notification_observer.h" | 86 #include "content/public/browser/notification_observer.h" |
| 87 #include "content/public/browser/notification_registrar.h" | 87 #include "content/public/browser/notification_registrar.h" |
| 88 #include "content/public/browser/storage_partition.h" | 88 #include "content/public/browser/storage_partition.h" |
| 89 #include "content/public/browser/web_contents.h" | 89 #include "content/public/browser/web_contents.h" |
| 90 #include "content/public/browser/web_contents_view.h" | 90 #include "content/public/browser/web_contents_view.h" |
| 91 #include "extensions/browser/extension_prefs.h" | 91 #include "extensions/browser/extension_prefs.h" |
| 92 #include "extensions/browser/extension_registry.h" | 92 #include "extensions/browser/extension_registry.h" |
| 93 #include "extensions/browser/extension_system.h" | 93 #include "extensions/browser/extension_system.h" |
| 94 #include "extensions/common/constants.h" | 94 #include "extensions/common/constants.h" |
| 95 #include "extensions/common/extension.h" |
| 96 #include "extensions/common/extension_set.h" |
| 95 #include "grit/locale_settings.h" | 97 #include "grit/locale_settings.h" |
| 96 #include "ui/base/l10n/l10n_util.h" | 98 #include "ui/base/l10n/l10n_util.h" |
| 97 #include "ui/base/resource/resource_bundle.h" | 99 #include "ui/base/resource/resource_bundle.h" |
| 98 | 100 |
| 99 #if defined(OS_MACOSX) | 101 #if defined(OS_MACOSX) |
| 100 #include "base/mac/mac_util.h" | 102 #include "base/mac/mac_util.h" |
| 101 #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h" | 103 #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h" |
| 102 #endif | 104 #endif |
| 103 | 105 |
| 104 #if defined(TOOLKIT_GTK) | 106 #if defined(TOOLKIT_GTK) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 223 |
| 222 void RecordCmdLineAppHistogram(extensions::Manifest::Type app_type) { | 224 void RecordCmdLineAppHistogram(extensions::Manifest::Type app_type) { |
| 223 CoreAppLauncherHandler::RecordAppLaunchType( | 225 CoreAppLauncherHandler::RecordAppLaunchType( |
| 224 extension_misc::APP_LAUNCH_CMD_LINE_APP, | 226 extension_misc::APP_LAUNCH_CMD_LINE_APP, |
| 225 app_type); | 227 app_type); |
| 226 } | 228 } |
| 227 | 229 |
| 228 void RecordAppLaunches(Profile* profile, | 230 void RecordAppLaunches(Profile* profile, |
| 229 const std::vector<GURL>& cmd_line_urls, | 231 const std::vector<GURL>& cmd_line_urls, |
| 230 StartupTabs& autolaunch_tabs) { | 232 StartupTabs& autolaunch_tabs) { |
| 231 ExtensionService* extension_service = profile->GetExtensionService(); | 233 const extensions::ExtensionSet& extensions = |
| 232 DCHECK(extension_service); | 234 extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
| 233 for (size_t i = 0; i < cmd_line_urls.size(); ++i) { | 235 for (size_t i = 0; i < cmd_line_urls.size(); ++i) { |
| 234 const extensions::Extension* extension = | 236 const extensions::Extension* extension = |
| 235 extension_service->GetInstalledApp(cmd_line_urls.at(i)); | 237 extensions.GetAppByURL(cmd_line_urls.at(i)); |
| 236 if (extension) { | 238 if (extension) { |
| 237 CoreAppLauncherHandler::RecordAppLaunchType( | 239 CoreAppLauncherHandler::RecordAppLaunchType( |
| 238 extension_misc::APP_LAUNCH_CMD_LINE_URL, | 240 extension_misc::APP_LAUNCH_CMD_LINE_URL, |
| 239 extension->GetType()); | 241 extension->GetType()); |
| 240 } | 242 } |
| 241 } | 243 } |
| 242 for (size_t i = 0; i < autolaunch_tabs.size(); ++i) { | 244 for (size_t i = 0; i < autolaunch_tabs.size(); ++i) { |
| 243 const extensions::Extension* extension = | 245 const extensions::Extension* extension = |
| 244 extension_service->GetInstalledApp(autolaunch_tabs.at(i).url); | 246 extensions.GetAppByURL(autolaunch_tabs.at(i).url); |
| 245 if (extension) { | 247 if (extension) { |
| 246 CoreAppLauncherHandler::RecordAppLaunchType( | 248 CoreAppLauncherHandler::RecordAppLaunchType( |
| 247 extension_misc::APP_LAUNCH_AUTOLAUNCH, | 249 extension_misc::APP_LAUNCH_AUTOLAUNCH, |
| 248 extension->GetType()); | 250 extension->GetType()); |
| 249 } | 251 } |
| 250 } | 252 } |
| 251 } | 253 } |
| 252 | 254 |
| 253 bool IsNewTabURL(Profile* profile, const GURL& url) { | 255 bool IsNewTabURL(Profile* profile, const GURL& url) { |
| 254 GURL ntp_url(chrome::kChromeUINewTabURL); | 256 GURL ntp_url(chrome::kChromeUINewTabURL); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 #endif | 508 #endif |
| 507 GURL url(url_string); | 509 GURL url(url_string); |
| 508 | 510 |
| 509 // Restrict allowed URLs for --app switch. | 511 // Restrict allowed URLs for --app switch. |
| 510 if (!url.is_empty() && url.is_valid()) { | 512 if (!url.is_empty() && url.is_valid()) { |
| 511 ChildProcessSecurityPolicy* policy = | 513 ChildProcessSecurityPolicy* policy = |
| 512 ChildProcessSecurityPolicy::GetInstance(); | 514 ChildProcessSecurityPolicy::GetInstance(); |
| 513 if (policy->IsWebSafeScheme(url.scheme()) || | 515 if (policy->IsWebSafeScheme(url.scheme()) || |
| 514 url.SchemeIs(content::kFileScheme)) { | 516 url.SchemeIs(content::kFileScheme)) { |
| 515 const extensions::Extension* extension = | 517 const extensions::Extension* extension = |
| 516 profile->GetExtensionService()->GetInstalledApp(url); | 518 extensions::ExtensionRegistry::Get(profile) |
| 519 ->enabled_extensions().GetAppByURL(url); |
| 517 if (extension) { | 520 if (extension) { |
| 518 RecordCmdLineAppHistogram(extension->GetType()); | 521 RecordCmdLineAppHistogram(extension->GetType()); |
| 519 } else { | 522 } else { |
| 520 CoreAppLauncherHandler::RecordAppLaunchType( | 523 CoreAppLauncherHandler::RecordAppLaunchType( |
| 521 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY, | 524 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY, |
| 522 extensions::Manifest::TYPE_HOSTED_APP); | 525 extensions::Manifest::TYPE_HOSTED_APP); |
| 523 } | 526 } |
| 524 | 527 |
| 525 WebContents* app_tab = OpenAppShortcutWindow(profile, url); | 528 WebContents* app_tab = OpenAppShortcutWindow(profile, url); |
| 526 | 529 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 } | 954 } |
| 952 | 955 |
| 953 #if !defined(OS_WIN) | 956 #if !defined(OS_WIN) |
| 954 // static | 957 // static |
| 955 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( | 958 bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( |
| 956 Profile* profile, | 959 Profile* profile, |
| 957 const std::vector<GURL>& startup_urls) { | 960 const std::vector<GURL>& startup_urls) { |
| 958 return false; | 961 return false; |
| 959 } | 962 } |
| 960 #endif | 963 #endif |
| OLD | NEW |