| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/new_profile_dialog.h" | 5 #include "chrome/browser/views/new_profile_dialog.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/message_box_flags.h" | 10 #include "app/message_box_flags.h" |
| 11 #include "base/file_util.h" |
| 12 #include "base/i18n/file_util_icu.h" |
| 11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 12 #include "base/i18n/file_util_icu.h" | 14 #include "base/path_service.h" |
| 13 #include "chrome/browser/user_data_manager.h" | 15 #include "chrome/browser/user_data_manager.h" |
| 14 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
| 15 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 16 #include "grit/locale_settings.h" | 18 #include "grit/locale_settings.h" |
| 17 #include "views/controls/message_box_view.h" | 19 #include "views/controls/message_box_view.h" |
| 18 #include "views/controls/textfield/textfield.h" | 20 #include "views/controls/textfield/textfield.h" |
| 19 #include "views/view.h" | 21 #include "views/view.h" |
| 20 #include "views/window/window.h" | 22 #include "views/window/window.h" |
| 21 | 23 |
| 24 #if defined(OS_WIN) |
| 25 #include "base/win_util.h" |
| 26 #endif // defined(OS_WIN) |
| 27 |
| 22 namespace browser { | 28 namespace browser { |
| 23 | 29 |
| 24 // Declared in browser_dialogs.h so others don't have to depend on our header. | 30 // Declared in browser_dialogs.h so others don't have to depend on our header. |
| 25 void ShowNewProfileDialog() { | 31 void ShowNewProfileDialog() { |
| 26 NewProfileDialog::RunDialog(); | 32 NewProfileDialog::RunDialog(); |
| 27 } | 33 } |
| 28 | 34 |
| 29 } // namespace browser | 35 } // namespace browser |
| 30 | 36 |
| 31 // static | 37 // static |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 GetDialogClientView()->UpdateDialogButtons(); | 98 GetDialogClientView()->UpdateDialogButtons(); |
| 93 } | 99 } |
| 94 | 100 |
| 95 bool NewProfileDialog::Accept() { | 101 bool NewProfileDialog::Accept() { |
| 96 std::wstring profile_name = message_box_view_->GetInputText(); | 102 std::wstring profile_name = message_box_view_->GetInputText(); |
| 97 if (profile_name.empty()) { | 103 if (profile_name.empty()) { |
| 98 NOTREACHED(); | 104 NOTREACHED(); |
| 99 return true; | 105 return true; |
| 100 } | 106 } |
| 101 // Create a desktop shortcut if the corresponding checkbox is checked. | 107 // Create a desktop shortcut if the corresponding checkbox is checked. |
| 102 if (message_box_view_->IsCheckBoxSelected()) | 108 if (message_box_view_->IsCheckBoxSelected()) { |
| 103 UserDataManager::Get()->CreateDesktopShortcutForProfile( | 109 UserDataManager::Get()->CreateDesktopShortcutForProfile( |
| 104 profile_name); | 110 profile_name); |
| 111 } else { |
| 112 #if defined(OS_WIN) |
| 113 if (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) { |
| 114 // For Win7, we need to have a shortcut in a place that Windows would |
| 115 // index to provide correct relaunch info. |
| 116 // See http://crbug.com/32106 |
| 117 FilePath temp_path; |
| 118 if (PathService::Get(base::DIR_APP_DATA, &temp_path)) { |
| 119 temp_path = temp_path.Append( |
| 120 L"Microsoft\\Internet Explorer\\Quick Launch\\User Pinned"); |
| 121 UserDataManager::Get()->CreateShortcutForProfileInFolder( |
| 122 temp_path, |
| 123 profile_name); |
| 124 } |
| 125 } |
| 126 #endif // defined(OS_WIN) |
| 127 } |
| 105 | 128 |
| 106 UserDataManager::Get()->LaunchChromeForProfile(profile_name); | 129 UserDataManager::Get()->LaunchChromeForProfile(profile_name); |
| 107 UserDataManager::Get()->RefreshUserDataDirProfiles(); | 130 UserDataManager::Get()->RefreshUserDataDirProfiles(); |
| 108 return true; | 131 return true; |
| 109 } | 132 } |
| 110 | 133 |
| 111 views::View* NewProfileDialog::GetContentsView() { | 134 views::View* NewProfileDialog::GetContentsView() { |
| 112 return message_box_view_; | 135 return message_box_view_; |
| 113 } | 136 } |
| OLD | NEW |