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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "chrome/browser/ui/startup/autolaunch_prompt.h" | 62 #include "chrome/browser/ui/startup/autolaunch_prompt.h" |
63 #include "chrome/browser/ui/startup/bad_flags_prompt.h" | 63 #include "chrome/browser/ui/startup/bad_flags_prompt.h" |
64 #include "chrome/browser/ui/startup/default_browser_prompt.h" | 64 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
65 #include "chrome/browser/ui/startup/google_api_keys_infobar_delegate.h" | 65 #include "chrome/browser/ui/startup/google_api_keys_infobar_delegate.h" |
66 #include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" | 66 #include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" |
67 #include "chrome/browser/ui/startup/session_crashed_bubble.h" | 67 #include "chrome/browser/ui/startup/session_crashed_bubble.h" |
68 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" | 68 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" |
69 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 69 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
70 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 70 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
71 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 71 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
72 #include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h" | |
73 #include "chrome/common/chrome_constants.h" | 72 #include "chrome/common/chrome_constants.h" |
74 #include "chrome/common/chrome_paths.h" | 73 #include "chrome/common/chrome_paths.h" |
75 #include "chrome/common/chrome_result_codes.h" | 74 #include "chrome/common/chrome_result_codes.h" |
76 #include "chrome/common/chrome_switches.h" | 75 #include "chrome/common/chrome_switches.h" |
77 #include "chrome/common/chrome_version_info.h" | 76 #include "chrome/common/chrome_version_info.h" |
78 #include "chrome/common/extensions/extension_constants.h" | 77 #include "chrome/common/extensions/extension_constants.h" |
| 78 #include "chrome/common/extensions/extension_metrics.h" |
79 #include "chrome/common/url_constants.h" | 79 #include "chrome/common/url_constants.h" |
80 #include "chrome/grit/locale_settings.h" | 80 #include "chrome/grit/locale_settings.h" |
81 #include "chrome/installer/util/browser_distribution.h" | 81 #include "chrome/installer/util/browser_distribution.h" |
82 #include "components/google/core/browser/google_util.h" | 82 #include "components/google/core/browser/google_util.h" |
83 #include "content/public/browser/child_process_security_policy.h" | 83 #include "content/public/browser/child_process_security_policy.h" |
84 #include "content/public/browser/dom_storage_context.h" | 84 #include "content/public/browser/dom_storage_context.h" |
85 #include "content/public/browser/notification_observer.h" | 85 #include "content/public/browser/notification_observer.h" |
86 #include "content/public/browser/notification_registrar.h" | 86 #include "content/public/browser/notification_registrar.h" |
87 #include "content/public/browser/storage_partition.h" | 87 #include "content/public/browser/storage_partition.h" |
88 #include "content/public/browser/web_contents.h" | 88 #include "content/public/browser/web_contents.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 extensions::ExtensionPrefs::Get(profile), extension)) { | 204 extensions::ExtensionPrefs::Get(profile), extension)) { |
205 launch_container = extensions::LAUNCH_CONTAINER_WINDOW; | 205 launch_container = extensions::LAUNCH_CONTAINER_WINDOW; |
206 } | 206 } |
207 | 207 |
208 *out_extension = extension; | 208 *out_extension = extension; |
209 *out_launch_container = launch_container; | 209 *out_launch_container = launch_container; |
210 return true; | 210 return true; |
211 } | 211 } |
212 | 212 |
213 void RecordCmdLineAppHistogram(extensions::Manifest::Type app_type) { | 213 void RecordCmdLineAppHistogram(extensions::Manifest::Type app_type) { |
214 CoreAppLauncherHandler::RecordAppLaunchType( | 214 extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_CMD_LINE_APP, |
215 extension_misc::APP_LAUNCH_CMD_LINE_APP, | 215 app_type); |
216 app_type); | |
217 } | 216 } |
218 | 217 |
219 void RecordAppLaunches(Profile* profile, | 218 void RecordAppLaunches(Profile* profile, |
220 const std::vector<GURL>& cmd_line_urls, | 219 const std::vector<GURL>& cmd_line_urls, |
221 const StartupTabs& autolaunch_tabs) { | 220 const StartupTabs& autolaunch_tabs) { |
222 const extensions::ExtensionSet& extensions = | 221 const extensions::ExtensionSet& extensions = |
223 extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); | 222 extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); |
224 for (size_t i = 0; i < cmd_line_urls.size(); ++i) { | 223 for (size_t i = 0; i < cmd_line_urls.size(); ++i) { |
225 const extensions::Extension* extension = | 224 const extensions::Extension* extension = |
226 extensions.GetAppByURL(cmd_line_urls.at(i)); | 225 extensions.GetAppByURL(cmd_line_urls.at(i)); |
227 if (extension) { | 226 if (extension) { |
228 CoreAppLauncherHandler::RecordAppLaunchType( | 227 extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_CMD_LINE_URL, |
229 extension_misc::APP_LAUNCH_CMD_LINE_URL, | 228 extension->GetType()); |
230 extension->GetType()); | |
231 } | 229 } |
232 } | 230 } |
233 for (size_t i = 0; i < autolaunch_tabs.size(); ++i) { | 231 for (size_t i = 0; i < autolaunch_tabs.size(); ++i) { |
234 const extensions::Extension* extension = | 232 const extensions::Extension* extension = |
235 extensions.GetAppByURL(autolaunch_tabs.at(i).url); | 233 extensions.GetAppByURL(autolaunch_tabs.at(i).url); |
236 if (extension) { | 234 if (extension) { |
237 CoreAppLauncherHandler::RecordAppLaunchType( | 235 extensions::RecordAppLaunchType(extension_misc::APP_LAUNCH_AUTOLAUNCH, |
238 extension_misc::APP_LAUNCH_AUTOLAUNCH, | 236 extension->GetType()); |
239 extension->GetType()); | |
240 } | 237 } |
241 } | 238 } |
242 } | 239 } |
243 | 240 |
244 class WebContentsCloseObserver : public content::NotificationObserver { | 241 class WebContentsCloseObserver : public content::NotificationObserver { |
245 public: | 242 public: |
246 WebContentsCloseObserver() : contents_(NULL) {} | 243 WebContentsCloseObserver() : contents_(NULL) {} |
247 ~WebContentsCloseObserver() override {} | 244 ~WebContentsCloseObserver() override {} |
248 | 245 |
249 void SetContents(content::WebContents* contents) { | 246 void SetContents(content::WebContents* contents) { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 ChildProcessSecurityPolicy* policy = | 485 ChildProcessSecurityPolicy* policy = |
489 ChildProcessSecurityPolicy::GetInstance(); | 486 ChildProcessSecurityPolicy::GetInstance(); |
490 if (policy->IsWebSafeScheme(url.scheme()) || | 487 if (policy->IsWebSafeScheme(url.scheme()) || |
491 url.SchemeIs(url::kFileScheme)) { | 488 url.SchemeIs(url::kFileScheme)) { |
492 const extensions::Extension* extension = | 489 const extensions::Extension* extension = |
493 extensions::ExtensionRegistry::Get(profile) | 490 extensions::ExtensionRegistry::Get(profile) |
494 ->enabled_extensions().GetAppByURL(url); | 491 ->enabled_extensions().GetAppByURL(url); |
495 if (extension) { | 492 if (extension) { |
496 RecordCmdLineAppHistogram(extension->GetType()); | 493 RecordCmdLineAppHistogram(extension->GetType()); |
497 } else { | 494 } else { |
498 CoreAppLauncherHandler::RecordAppLaunchType( | 495 extensions::RecordAppLaunchType( |
499 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY, | 496 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY, |
500 extensions::Manifest::TYPE_HOSTED_APP); | 497 extensions::Manifest::TYPE_HOSTED_APP); |
501 } | 498 } |
502 | 499 |
503 WebContents* app_tab = OpenAppShortcutWindow(profile, url); | 500 WebContents* app_tab = OpenAppShortcutWindow(profile, url); |
504 | 501 |
505 if (out_app_contents) | 502 if (out_app_contents) |
506 *out_app_contents = app_tab; | 503 *out_app_contents = app_tab; |
507 | 504 |
508 return (app_tab != NULL); | 505 return (app_tab != NULL); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 // behavior is desired because completing or skipping the sync promo | 902 // behavior is desired because completing or skipping the sync promo |
906 // causes a redirect to the NTP. | 903 // causes a redirect to the NTP. |
907 if (!startup_urls->empty() && | 904 if (!startup_urls->empty() && |
908 startup_urls->at(0) == GURL(chrome::kChromeUINewTabURL)) | 905 startup_urls->at(0) == GURL(chrome::kChromeUINewTabURL)) |
909 startup_urls->at(0) = sync_promo_url; | 906 startup_urls->at(0) = sync_promo_url; |
910 else | 907 else |
911 startup_urls->insert(startup_urls->begin(), sync_promo_url); | 908 startup_urls->insert(startup_urls->begin(), sync_promo_url); |
912 } | 909 } |
913 } | 910 } |
914 } | 911 } |
OLD | NEW |