| OLD | NEW | 
|---|
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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/browser.h" | 5 #include "chrome/browser/browser.h" | 
| 6 | 6 | 
| 7 #include "app/animation.h" | 7 #include "app/animation.h" | 
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" | 
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" | 
| 10 #include "base/idle_timer.h" | 10 #include "base/idle_timer.h" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 29 #include "chrome/browser/location_bar.h" | 29 #include "chrome/browser/location_bar.h" | 
| 30 #include "chrome/browser/metrics/user_metrics.h" | 30 #include "chrome/browser/metrics/user_metrics.h" | 
| 31 #include "chrome/browser/net/url_fixer_upper.h" | 31 #include "chrome/browser/net/url_fixer_upper.h" | 
| 32 #include "chrome/browser/options_window.h" | 32 #include "chrome/browser/options_window.h" | 
| 33 #include "chrome/browser/profile.h" | 33 #include "chrome/browser/profile.h" | 
| 34 #include "chrome/browser/renderer_host/site_instance.h" | 34 #include "chrome/browser/renderer_host/site_instance.h" | 
| 35 #include "chrome/browser/sessions/session_service.h" | 35 #include "chrome/browser/sessions/session_service.h" | 
| 36 #include "chrome/browser/sessions/session_types.h" | 36 #include "chrome/browser/sessions/session_types.h" | 
| 37 #include "chrome/browser/sessions/tab_restore_service.h" | 37 #include "chrome/browser/sessions/tab_restore_service.h" | 
| 38 #include "chrome/browser/status_bubble.h" | 38 #include "chrome/browser/status_bubble.h" | 
|  | 39 #include "chrome/browser/tab_contents/geoloc_infobar_delegate.h" | 
| 39 #include "chrome/browser/tab_contents/interstitial_page.h" | 40 #include "chrome/browser/tab_contents/interstitial_page.h" | 
| 40 #include "chrome/browser/tab_contents/navigation_controller.h" | 41 #include "chrome/browser/tab_contents/navigation_controller.h" | 
| 41 #include "chrome/browser/tab_contents/navigation_entry.h" | 42 #include "chrome/browser/tab_contents/navigation_entry.h" | 
| 42 #include "chrome/browser/tab_contents/tab_contents.h" | 43 #include "chrome/browser/tab_contents/tab_contents.h" | 
| 43 #include "chrome/browser/tab_contents/tab_contents_view.h" | 44 #include "chrome/browser/tab_contents/tab_contents_view.h" | 
| 44 #include "chrome/browser/window_sizer.h" | 45 #include "chrome/browser/window_sizer.h" | 
| 45 #include "chrome/common/chrome_constants.h" | 46 #include "chrome/common/chrome_constants.h" | 
| 46 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" | 
| 47 #include "chrome/common/extensions/extension.h" | 48 #include "chrome/common/extensions/extension.h" | 
| 48 #include "chrome/common/notification_service.h" | 49 #include "chrome/common/notification_service.h" | 
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 899   UpdateCommandsForFullscreenMode(window_->IsFullscreen()); | 900   UpdateCommandsForFullscreenMode(window_->IsFullscreen()); | 
| 900 #endif | 901 #endif | 
| 901 } | 902 } | 
| 902 | 903 | 
| 903 void Browser::Exit() { | 904 void Browser::Exit() { | 
| 904   UserMetrics::RecordAction(L"Exit", profile_); | 905   UserMetrics::RecordAction(L"Exit", profile_); | 
| 905   BrowserList::CloseAllBrowsers(true); | 906   BrowserList::CloseAllBrowsers(true); | 
| 906 } | 907 } | 
| 907 | 908 | 
| 908 void Browser::BookmarkCurrentPage() { | 909 void Browser::BookmarkCurrentPage() { | 
|  | 910   /* | 
| 909   UserMetrics::RecordAction(L"Star", profile_); | 911   UserMetrics::RecordAction(L"Star", profile_); | 
| 910 | 912 | 
| 911   TabContents* contents = GetSelectedTabContents(); | 913   TabContents* contents = GetSelectedTabContents(); | 
| 912   if (!contents->ShouldDisplayURL()) | 914   if (!contents->ShouldDisplayURL()) | 
| 913     return; | 915     return; | 
| 914   const GURL& url = contents->GetURL(); | 916   const GURL& url = contents->GetURL(); | 
| 915   if (url.is_empty() || !url.is_valid()) | 917   if (url.is_empty() || !url.is_valid()) | 
| 916     return; | 918     return; | 
| 917   std::wstring title = UTF16ToWideHack(contents->GetTitle()); | 919   std::wstring title = UTF16ToWideHack(contents->GetTitle()); | 
| 918 | 920 | 
| 919   BookmarkModel* model = contents->profile()->GetBookmarkModel(); | 921   BookmarkModel* model = contents->profile()->GetBookmarkModel(); | 
| 920   if (!model || !model->IsLoaded()) | 922   if (!model || !model->IsLoaded()) | 
| 921     return;  // Ignore requests until bookmarks are loaded. | 923     return;  // Ignore requests until bookmarks are loaded. | 
| 922 | 924 | 
| 923   bool was_bookmarked = model->IsBookmarked(url); | 925   bool was_bookmarked = model->IsBookmarked(url); | 
| 924   model->SetURLStarred(url, title, true); | 926   model->SetURLStarred(url, title, true); | 
| 925   if (window_->IsActive()) { | 927   if (window_->IsActive()) { | 
| 926     // Only show the bubble if the window is active, otherwise we may get into | 928     // Only show the bubble if the window is active, otherwise we may get into | 
| 927     // weird situations were the bubble is deleted as soon as it is shown. | 929     // weird situations were the bubble is deleted as soon as it is shown. | 
| 928     window_->ShowBookmarkBubble(url, was_bookmarked); | 930     window_->ShowBookmarkBubble(url, was_bookmarked); | 
| 929   } | 931   } | 
|  | 932   */ | 
|  | 933   TabContents* tab = GetSelectedTabContents(); | 
|  | 934   tab->AddInfoBar(new GeolocInfoBarDelegate(tab)); | 
| 930 } | 935 } | 
| 931 | 936 | 
| 932 void Browser::SavePage() { | 937 void Browser::SavePage() { | 
| 933   UserMetrics::RecordAction(L"SavePage", profile_); | 938   UserMetrics::RecordAction(L"SavePage", profile_); | 
| 934   GetSelectedTabContents()->OnSavePage(); | 939   GetSelectedTabContents()->OnSavePage(); | 
| 935 } | 940 } | 
| 936 | 941 | 
| 937 void Browser::ViewSource() { | 942 void Browser::ViewSource() { | 
| 938   UserMetrics::RecordAction(L"ViewSource", profile_); | 943   UserMetrics::RecordAction(L"ViewSource", profile_); | 
| 939 | 944 | 
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1215 } | 1220 } | 
| 1216 | 1221 | 
| 1217 #if defined(OS_CHROMEOS) | 1222 #if defined(OS_CHROMEOS) | 
| 1218 void Browser::ShowControlPanel() { | 1223 void Browser::ShowControlPanel() { | 
| 1219   GURL url("http://localhost:8080"); | 1224   GURL url("http://localhost:8080"); | 
| 1220   AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1, | 1225   AddTabWithURL(url, GURL(), PageTransition::AUTO_BOOKMARK, true, -1, | 
| 1221                 false, NULL); | 1226                 false, NULL); | 
| 1222 } | 1227 } | 
| 1223 #endif | 1228 #endif | 
| 1224 | 1229 | 
|  | 1230 void Browser::OpenApiPermissionsPanel() { | 
|  | 1231   UserMetrics::RecordAction(L"ApiPermissions", profile_); | 
|  | 1232   window_->ShowApiPermissionsPanel(); | 
|  | 1233 } | 
|  | 1234 | 
| 1225 /////////////////////////////////////////////////////////////////////////////// | 1235 /////////////////////////////////////////////////////////////////////////////// | 
| 1226 | 1236 | 
| 1227 // static | 1237 // static | 
| 1228 void Browser::RegisterPrefs(PrefService* prefs) { | 1238 void Browser::RegisterPrefs(PrefService* prefs) { | 
| 1229   prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 1239   prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement); | 
| 1230   prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); | 1240   prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0); | 
| 1231   prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1); | 1241   prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1); | 
| 1232 } | 1242 } | 
| 1233 | 1243 | 
| 1234 // static | 1244 // static | 
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1430     case IDC_OPTIONS:               OpenOptionsDialog();           break; | 1440     case IDC_OPTIONS:               OpenOptionsDialog();           break; | 
| 1431     case IDC_EDIT_SEARCH_ENGINES:   OpenKeywordEditor();           break; | 1441     case IDC_EDIT_SEARCH_ENGINES:   OpenKeywordEditor();           break; | 
| 1432     case IDC_VIEW_PASSWORDS:        OpenPasswordManager();         break; | 1442     case IDC_VIEW_PASSWORDS:        OpenPasswordManager();         break; | 
| 1433     case IDC_CLEAR_BROWSING_DATA:   OpenClearBrowsingDataDialog(); break; | 1443     case IDC_CLEAR_BROWSING_DATA:   OpenClearBrowsingDataDialog(); break; | 
| 1434     case IDC_IMPORT_SETTINGS:       OpenImportSettingsDialog();    break; | 1444     case IDC_IMPORT_SETTINGS:       OpenImportSettingsDialog();    break; | 
| 1435     case IDC_ABOUT:                 OpenAboutChromeDialog();       break; | 1445     case IDC_ABOUT:                 OpenAboutChromeDialog();       break; | 
| 1436     case IDC_HELP_PAGE:             OpenHelpTab();                 break; | 1446     case IDC_HELP_PAGE:             OpenHelpTab();                 break; | 
| 1437 #if defined(OS_CHROMEOS) | 1447 #if defined(OS_CHROMEOS) | 
| 1438     case IDC_CONTROL_PANEL:         ShowControlPanel();            break; | 1448     case IDC_CONTROL_PANEL:         ShowControlPanel();            break; | 
| 1439 #endif | 1449 #endif | 
|  | 1450     case IDC_API_PERMISSIONS_PANEL: OpenApiPermissionsPanel();     break; | 
| 1440 | 1451 | 
| 1441     default: | 1452     default: | 
| 1442       LOG(WARNING) << "Received Unimplemented Command: " << id; | 1453       LOG(WARNING) << "Received Unimplemented Command: " << id; | 
| 1443       break; | 1454       break; | 
| 1444   } | 1455   } | 
| 1445 } | 1456 } | 
| 1446 | 1457 | 
| 1447 /////////////////////////////////////////////////////////////////////////////// | 1458 /////////////////////////////////////////////////////////////////////////////// | 
| 1448 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: | 1459 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: | 
| 1449 | 1460 | 
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2210   command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, true); | 2221   command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, true); | 
| 2211   command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true); | 2222   command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true); | 
| 2212   command_updater_.UpdateCommandEnabled(IDC_SELECT_PROFILE, true); | 2223   command_updater_.UpdateCommandEnabled(IDC_SELECT_PROFILE, true); | 
| 2213   command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true); | 2224   command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true); | 
| 2214   command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true); | 2225   command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true); | 
| 2215   command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); | 2226   command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); | 
| 2216   command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true); | 2227   command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true); | 
| 2217 #if defined(OS_CHROMEOS) | 2228 #if defined(OS_CHROMEOS) | 
| 2218   command_updater_.UpdateCommandEnabled(IDC_CONTROL_PANEL, true); | 2229   command_updater_.UpdateCommandEnabled(IDC_CONTROL_PANEL, true); | 
| 2219 #endif | 2230 #endif | 
|  | 2231   command_updater_.UpdateCommandEnabled(IDC_API_PERMISSIONS_PANEL, true); | 
| 2220 | 2232 | 
| 2221   // Initialize other commands based on the window type. | 2233   // Initialize other commands based on the window type. | 
| 2222   { | 2234   { | 
| 2223     bool normal_window = type() == TYPE_NORMAL; | 2235     bool normal_window = type() == TYPE_NORMAL; | 
| 2224 | 2236 | 
| 2225     // Navigation commands | 2237     // Navigation commands | 
| 2226     command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window); | 2238     command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window); | 
| 2227 | 2239 | 
| 2228     // Window management commands | 2240     // Window management commands | 
| 2229     command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window); | 2241     command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window); | 
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2799 /////////////////////////////////////////////////////////////////////////////// | 2811 /////////////////////////////////////////////////////////////////////////////// | 
| 2800 // BrowserToolbarModel (private): | 2812 // BrowserToolbarModel (private): | 
| 2801 | 2813 | 
| 2802 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2814 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 
| 2803   // This |current_tab| can be NULL during the initialization of the | 2815   // This |current_tab| can be NULL during the initialization of the | 
| 2804   // toolbar during window creation (i.e. before any tabs have been added | 2816   // toolbar during window creation (i.e. before any tabs have been added | 
| 2805   // to the window). | 2817   // to the window). | 
| 2806   TabContents* current_tab = browser_->GetSelectedTabContents(); | 2818   TabContents* current_tab = browser_->GetSelectedTabContents(); | 
| 2807   return current_tab ? ¤t_tab->controller() : NULL; | 2819   return current_tab ? ¤t_tab->controller() : NULL; | 
| 2808 } | 2820 } | 
| OLD | NEW | 
|---|