Chromium Code Reviews| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 #include "content/public/browser/child_process_security_policy.h" | 78 #include "content/public/browser/child_process_security_policy.h" |
| 79 #include "content/public/browser/dom_storage_context.h" | 79 #include "content/public/browser/dom_storage_context.h" |
| 80 #include "content/public/browser/notification_observer.h" | 80 #include "content/public/browser/notification_observer.h" |
| 81 #include "content/public/browser/notification_registrar.h" | 81 #include "content/public/browser/notification_registrar.h" |
| 82 #include "content/public/browser/storage_partition.h" | 82 #include "content/public/browser/storage_partition.h" |
| 83 #include "content/public/browser/web_contents.h" | 83 #include "content/public/browser/web_contents.h" |
| 84 #include "content/public/browser/web_contents_view.h" | 84 #include "content/public/browser/web_contents_view.h" |
| 85 #include "grit/locale_settings.h" | 85 #include "grit/locale_settings.h" |
| 86 #include "ui/base/l10n/l10n_util.h" | 86 #include "ui/base/l10n/l10n_util.h" |
| 87 #include "ui/base/resource/resource_bundle.h" | 87 #include "ui/base/resource/resource_bundle.h" |
| 88 #include "ui/gfx/screen.h" | |
| 89 | |
| 90 #if defined(USE_ASH) | |
| 91 #include "ash/launcher/launcher_types.h" | |
| 92 #endif | |
| 88 | 93 |
| 89 #if defined(OS_MACOSX) | 94 #if defined(OS_MACOSX) |
| 90 #include "base/mac/mac_util.h" | 95 #include "base/mac/mac_util.h" |
| 91 #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h" | 96 #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h" |
| 92 #endif | 97 #endif |
| 93 | 98 |
| 94 #if defined(TOOLKIT_GTK) | 99 #if defined(TOOLKIT_GTK) |
| 95 #include "chrome/browser/ui/gtk/gtk_util.h" | 100 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 96 #endif | 101 #endif |
| 97 | 102 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 // preference is set, launch as a window. | 207 // preference is set, launch as a window. |
| 203 extension_misc::LaunchContainer launch_container = | 208 extension_misc::LaunchContainer launch_container = |
| 204 extensions_service->extension_prefs()->GetLaunchContainer( | 209 extensions_service->extension_prefs()->GetLaunchContainer( |
| 205 extension, extensions::ExtensionPrefs::LAUNCH_WINDOW); | 210 extension, extensions::ExtensionPrefs::LAUNCH_WINDOW); |
| 206 | 211 |
| 207 *out_extension = extension; | 212 *out_extension = extension; |
| 208 *out_launch_container = launch_container; | 213 *out_launch_container = launch_container; |
| 209 return true; | 214 return true; |
| 210 } | 215 } |
| 211 | 216 |
| 217 // Parse two comma-separated integers from str. Return true on success. | |
| 218 bool ParseCommaSeparatedIntegers(const std::string& str, | |
| 219 int* ret_num1, | |
| 220 int* ret_num2) { | |
| 221 size_t num1_size = str.find_first_of(','); | |
|
sky
2012/09/19 17:20:14
Seems like this would be a lot simpler if you used
Nikita (slow)
2012/09/20 15:01:27
Done.
| |
| 222 if (num1_size == std::string::npos) | |
| 223 return false; | |
| 224 | |
| 225 size_t num2_pos = num1_size + 1; | |
| 226 size_t num2_size = str.size() - num2_pos; | |
| 227 int num1, num2; | |
| 228 if (!base::StringToInt(str.substr(0, num1_size), &num1) || | |
| 229 !base::StringToInt(str.substr(num2_pos, num2_size), &num2)) | |
| 230 return false; | |
| 231 | |
| 232 *ret_num1 = num1; | |
| 233 *ret_num2 = num2; | |
| 234 return true; | |
| 235 } | |
| 236 | |
| 212 void RecordCmdLineAppHistogram() { | 237 void RecordCmdLineAppHistogram() { |
| 213 AppLauncherHandler::RecordAppLaunchType( | 238 AppLauncherHandler::RecordAppLaunchType( |
| 214 extension_misc::APP_LAUNCH_CMD_LINE_APP); | 239 extension_misc::APP_LAUNCH_CMD_LINE_APP); |
| 215 } | 240 } |
| 216 | 241 |
| 217 void RecordAppLaunches(Profile* profile, | 242 void RecordAppLaunches(Profile* profile, |
| 218 const std::vector<GURL>& cmd_line_urls, | 243 const std::vector<GURL>& cmd_line_urls, |
| 219 StartupTabs& autolaunch_tabs) { | 244 StartupTabs& autolaunch_tabs) { |
| 220 ExtensionService* extension_service = profile->GetExtensionService(); | 245 ExtensionService* extension_service = profile->GetExtensionService(); |
| 221 DCHECK(extension_service); | 246 DCHECK(extension_service); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 ChildProcessSecurityPolicy::GetInstance(); | 527 ChildProcessSecurityPolicy::GetInstance(); |
| 503 if (policy->IsWebSafeScheme(url.scheme()) || | 528 if (policy->IsWebSafeScheme(url.scheme()) || |
| 504 url.SchemeIs(chrome::kFileScheme)) { | 529 url.SchemeIs(chrome::kFileScheme)) { |
| 505 if (profile->GetExtensionService()->IsInstalledApp(url)) { | 530 if (profile->GetExtensionService()->IsInstalledApp(url)) { |
| 506 RecordCmdLineAppHistogram(); | 531 RecordCmdLineAppHistogram(); |
| 507 } else { | 532 } else { |
| 508 AppLauncherHandler::RecordAppLaunchType( | 533 AppLauncherHandler::RecordAppLaunchType( |
| 509 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY); | 534 extension_misc::APP_LAUNCH_CMD_LINE_APP_LEGACY); |
| 510 } | 535 } |
| 511 | 536 |
| 537 gfx::Rect override_bounds; | |
| 538 | |
| 539 if (command_line_.HasSwitch(switches::kAppWindowSize)) { | |
|
sky
2012/09/19 17:20:14
Move this into its own function.
Nikita (slow)
2012/09/20 15:01:27
Done.
| |
| 540 int width, height; | |
| 541 std::string switch_value = | |
| 542 command_line_.GetSwitchValueASCII(switches::kAppWindowSize); | |
| 543 if (ParseCommaSeparatedIntegers(switch_value, &width, &height)) { | |
| 544 override_bounds.set_size(gfx::Size(width, height)); | |
|
sky
2012/09/19 17:20:14
Make sure the size fits in the work area too.
Nikita (slow)
2012/09/20 15:01:27
Not sure if this is really needs to be done here a
Nikita (slow)
2012/09/20 15:01:27
Done.
| |
| 545 const gfx::Rect work_area = | |
| 546 gfx::Screen::GetPrimaryDisplay().work_area(); | |
| 547 override_bounds.set_x( | |
| 548 (work_area.width() - override_bounds.width()) / 2); | |
| 549 int extra_height_work_area = 0; | |
| 550 #if defined(USE_ASH) | |
| 551 // In case of Ash we should center app window on the rest of the | |
| 552 // working area outside of launcher. | |
| 553 extra_height_work_area = ash::kLauncherPreferredSize; | |
|
sky
2012/09/19 17:20:14
The work area shouldn't include kLauncherPreferred
Nikita (slow)
2012/09/19 17:46:42
Probably you're right but from what I've seen on l
Nikita (slow)
2012/09/20 16:55:00
Removed for now.
Work area should not include laun
| |
| 554 #endif | |
| 555 override_bounds.set_y((work_area.height() - | |
| 556 override_bounds.height() - extra_height_work_area) / 2); | |
| 557 } | |
| 558 } | |
| 559 | |
| 512 WebContents* app_tab = application_launch::OpenAppShortcutWindow( | 560 WebContents* app_tab = application_launch::OpenAppShortcutWindow( |
| 513 profile, | 561 profile, |
| 514 url); | 562 url, |
| 563 override_bounds); | |
| 515 | 564 |
| 516 if (out_app_contents) | 565 if (out_app_contents) |
| 517 *out_app_contents = app_tab; | 566 *out_app_contents = app_tab; |
| 518 | 567 |
| 519 return (app_tab != NULL); | 568 return (app_tab != NULL); |
| 520 } | 569 } |
| 521 } | 570 } |
| 522 return false; | 571 return false; |
| 523 } | 572 } |
| 524 | 573 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 942 // New: | 991 // New: |
| 943 prefs->GetString(prefs::kHomePage), | 992 prefs->GetString(prefs::kHomePage), |
| 944 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), | 993 prefs->GetBoolean(prefs::kHomePageIsNewTabPage), |
| 945 prefs->GetBoolean(prefs::kShowHomeButton), | 994 prefs->GetBoolean(prefs::kShowHomeButton), |
| 946 // Backup: | 995 // Backup: |
| 947 backup_homepage, | 996 backup_homepage, |
| 948 backup_homepage_is_ntp, | 997 backup_homepage_is_ntp, |
| 949 backup_show_home_button)); | 998 backup_show_home_button)); |
| 950 } | 999 } |
| 951 } | 1000 } |
| OLD | NEW |