Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: chrome/browser/browser.cc

Issue 12895: Chromium-MultiProfile-Prototype... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser.vcproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <windows.h> 5 #include <windows.h>
6 #include <shellapi.h> 6 #include <shellapi.h>
7 7
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/navigation_controller.h" 30 #include "chrome/browser/navigation_controller.h"
31 #include "chrome/browser/navigation_entry.h" 31 #include "chrome/browser/navigation_entry.h"
32 #include "chrome/browser/options_window.h" 32 #include "chrome/browser/options_window.h"
33 #include "chrome/browser/plugin_process_host.h" 33 #include "chrome/browser/plugin_process_host.h"
34 #include "chrome/browser/plugin_service.h" 34 #include "chrome/browser/plugin_service.h"
35 #include "chrome/browser/profile.h" 35 #include "chrome/browser/profile.h"
36 #include "chrome/browser/ssl_error_info.h" 36 #include "chrome/browser/ssl_error_info.h"
37 #include "chrome/browser/site_instance.h" 37 #include "chrome/browser/site_instance.h"
38 #include "chrome/browser/task_manager.h" 38 #include "chrome/browser/task_manager.h"
39 #include "chrome/browser/url_fixer_upper.h" 39 #include "chrome/browser/url_fixer_upper.h"
40 #include "chrome/browser/user_data_manager.h"
40 #include "chrome/browser/user_metrics.h" 41 #include "chrome/browser/user_metrics.h"
41 #include "chrome/browser/view_ids.h" 42 #include "chrome/browser/view_ids.h"
42 #include "chrome/browser/views/download_tab_view.h" 43 #include "chrome/browser/views/download_tab_view.h"
43 #include "chrome/browser/views/go_button.h" 44 #include "chrome/browser/views/go_button.h"
44 #include "chrome/browser/views/location_bar_view.h" 45 #include "chrome/browser/views/location_bar_view.h"
46 #include "chrome/browser/views/new_profile_dialog.h"
47 #include "chrome/browser/views/select_profile_dialog.h"
45 #include "chrome/browser/views/status_bubble.h" 48 #include "chrome/browser/views/status_bubble.h"
46 #include "chrome/browser/views/toolbar_star_toggle.h" 49 #include "chrome/browser/views/toolbar_star_toggle.h"
47 #include "chrome/browser/web_contents_view.h" 50 #include "chrome/browser/web_contents_view.h"
48 #include "chrome/browser/window_sizer.h" 51 #include "chrome/browser/window_sizer.h"
49 #include "chrome/common/chrome_constants.h" 52 #include "chrome/common/chrome_constants.h"
50 #include "chrome/common/chrome_switches.h" 53 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/l10n_util.h" 54 #include "chrome/common/l10n_util.h"
52 #include "chrome/common/pref_names.h" 55 #include "chrome/common/pref_names.h"
53 #include "chrome/common/pref_service.h" 56 #include "chrome/common/pref_service.h"
54 #include "chrome/common/win_util.h" 57 #include "chrome/common/win_util.h"
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 void Browser::CloseApp() { 650 void Browser::CloseApp() {
648 UserMetrics::RecordAction(L"CloseWebApp", profile_); 651 UserMetrics::RecordAction(L"CloseWebApp", profile_);
649 tabstrip_model_.CloseTabContentsAt(tabstrip_model_.selected_index()); 652 tabstrip_model_.CloseTabContentsAt(tabstrip_model_.selected_index());
650 } 653 }
651 654
652 void Browser::NewWindow() { 655 void Browser::NewWindow() {
653 UserMetrics::RecordAction(L"NewWindow", profile_); 656 UserMetrics::RecordAction(L"NewWindow", profile_);
654 Browser::OpenEmptyWindow(profile_->GetOriginalProfile()); 657 Browser::OpenEmptyWindow(profile_->GetOriginalProfile());
655 } 658 }
656 659
660 void Browser::OpenSelectProfileDialog() {
661 UserMetrics::RecordAction(L"SelectProfile", profile_);
662 SelectProfileDialog::RunDialog();
663 }
664
665 void Browser::OpenNewProfileDialog() {
666 UserMetrics::RecordAction(L"CreateProfile", profile_);
667 NewProfileDialog::RunDialog();
668 }
669
670 void Browser::NewProfileWindowByName(const std::wstring& profile) {
671 UserMetrics::RecordAction(L"NewProfileWindowByName", profile_);
672 UserDataManager::Get()->LaunchChromeForProfile(profile);
673 }
674
675 void Browser::NewProfileWindowByIndex(int index) {
676 UserMetrics::RecordAction(L"NewProfileWindowByIndex", profile_);
677 UserDataManager::Get()->LaunchChromeForProfile(index);
678 }
679
657 void Browser::NewIncognitoWindow() { 680 void Browser::NewIncognitoWindow() {
658 UserMetrics::RecordAction(L"NewIncognitoWindow", profile_); 681 UserMetrics::RecordAction(L"NewIncognitoWindow", profile_);
659 Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile()); 682 Browser::OpenEmptyWindow(profile_->GetOffTheRecordProfile());
660 } 683 }
661 684
662 void Browser::CloseWindow() { 685 void Browser::CloseWindow() {
663 UserMetrics::RecordAction(L"CloseWindow", profile_); 686 UserMetrics::RecordAction(L"CloseWindow", profile_);
664 window_->Close(); 687 window_->Close();
665 } 688 }
666 689
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; 1198 case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break;
1176 case IDC_ABOUT: OpenAboutChromeDialog(); break; 1199 case IDC_ABOUT: OpenAboutChromeDialog(); break;
1177 case IDC_OPENFILE: OpenFile(); break; 1200 case IDC_OPENFILE: OpenFile(); break;
1178 case IDC_TASKMANAGER: OpenTaskManager(); break; 1201 case IDC_TASKMANAGER: OpenTaskManager(); break;
1179 case IDC_OPTIONS: OpenOptionsDialog(); break; 1202 case IDC_OPTIONS: OpenOptionsDialog(); break;
1180 case IDC_HELPMENU: OpenHelpTab(); break; 1203 case IDC_HELPMENU: OpenHelpTab(); break;
1181 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; 1204 case IDC_SHOW_HISTORY: ShowHistoryTab(); break;
1182 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; 1205 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break;
1183 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarksManager(); break; 1206 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarksManager(); break;
1184 case IDC_SHOW_BOOKMARKS_BAR: ToggleBookmarksBar(); break; 1207 case IDC_SHOW_BOOKMARKS_BAR: ToggleBookmarksBar(); break;
1208 case IDC_NEWPROFILEWINDOW:
1209 case IDC_SELECT_PROFILE:
1210 OpenSelectProfileDialog();
1211 break;
1212 case IDC_NEW_PROFILE: OpenNewProfileDialog(); break;
1185 1213
1186 default: 1214 default:
1187 LOG(WARNING) << "Received Unimplemented Command: " << id; 1215 // Handle the user action for creating a new window in a specific profile.
1216 if (id >= IDC_NEWPROFILEWINDOW_MIN_ID &&
1217 id <= IDC_NEWPROFILEWINDOW_MAX_ID) {
1218 int index = id - IDC_NEWPROFILEWINDOW_MIN_ID;
1219 NewProfileWindowByIndex(index);
1220 } else {
1221 LOG(WARNING) << "Received Unimplemented Command: " << id;
1222 }
1188 break; 1223 break;
1189 } 1224 }
1190 } 1225 }
1191 1226
1192 /////////////////////////////////////////////////////////////////////////////// 1227 ///////////////////////////////////////////////////////////////////////////////
1193 // Browser, TabStripModelDelegate implementation: 1228 // Browser, TabStripModelDelegate implementation:
1194 1229
1195 GURL Browser::GetBlankTabURL() const { 1230 GURL Browser::GetBlankTabURL() const {
1196 return NewTabUIURL(); 1231 return NewTabUIURL();
1197 } 1232 }
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 controller_.UpdateCommandEnabled(IDC_STOP, false); 2044 controller_.UpdateCommandEnabled(IDC_STOP, false);
2010 controller_.UpdateCommandEnabled(IDC_SHOW_JS_CONSOLE, false); 2045 controller_.UpdateCommandEnabled(IDC_SHOW_JS_CONSOLE, false);
2011 controller_.UpdateCommandEnabled(IDC_PRINT, false); 2046 controller_.UpdateCommandEnabled(IDC_PRINT, false);
2012 } 2047 }
2013 2048
2014 controller_.UpdateCommandEnabled(IDC_CREATE_SHORTCUT, 2049 controller_.UpdateCommandEnabled(IDC_CREATE_SHORTCUT,
2015 current_tab->type() == TAB_CONTENTS_WEB && 2050 current_tab->type() == TAB_CONTENTS_WEB &&
2016 !current_tab->GetFavIcon().isNull()); 2051 !current_tab->GetFavIcon().isNull());
2017 controller_.UpdateCommandEnabled(IDC_DUPLICATE, 2052 controller_.UpdateCommandEnabled(IDC_DUPLICATE,
2018 CanDuplicateContentsAt(selected_index())); 2053 CanDuplicateContentsAt(selected_index()));
2054
2055 // Enable various IDC_NEWPROFILEWINDOW* commands.
2056 controller_.UpdateCommandEnabled(IDC_NEWPROFILEWINDOW, true);
2057 controller_.UpdateCommandEnabled(IDC_SELECT_PROFILE, true);
2058 controller_.UpdateCommandEnabled(IDC_NEW_PROFILE, true);
2059 for (int i = IDC_NEWPROFILEWINDOW_MIN_ID;
2060 i <= IDC_NEWPROFILEWINDOW_MAX_ID;
2061 ++i) {
2062 controller_.UpdateCommandEnabled(i, true);
2063 }
2019 } 2064 }
2020 2065
2021 void Browser::SetStarredButtonToggled(bool starred) { 2066 void Browser::SetStarredButtonToggled(bool starred) {
2022 window_->GetStarButton()->SetToggled(starred); 2067 window_->GetStarButton()->SetToggled(starred);
2023 } 2068 }
2024 2069
2025 /////////////////////////////////////////////////////////////////////////////// 2070 ///////////////////////////////////////////////////////////////////////////////
2026 // Browser, UI update coalescing and handling (private): 2071 // Browser, UI update coalescing and handling (private):
2027 2072
2028 void Browser::UpdateToolbar(bool should_restore_state) { 2073 void Browser::UpdateToolbar(bool should_restore_state) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 2394
2350 // We need to register the window position pref. 2395 // We need to register the window position pref.
2351 std::wstring window_pref(prefs::kBrowserWindowPlacement); 2396 std::wstring window_pref(prefs::kBrowserWindowPlacement);
2352 window_pref.append(L"_"); 2397 window_pref.append(L"_");
2353 window_pref.append(app_name); 2398 window_pref.append(app_name);
2354 PrefService* prefs = g_browser_process->local_state(); 2399 PrefService* prefs = g_browser_process->local_state();
2355 DCHECK(prefs); 2400 DCHECK(prefs);
2356 2401
2357 prefs->RegisterDictionaryPref(window_pref.c_str()); 2402 prefs->RegisterDictionaryPref(window_pref.c_str());
2358 } 2403 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698