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

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

Issue 3129003: remove toolstrips (Closed)
Patch Set: merge Created 10 years, 4 months 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
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser_resources.grd » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 26 matching lines...) Expand all
37 #include "chrome/browser/dock_info.h" 37 #include "chrome/browser/dock_info.h"
38 #include "chrome/browser/dom_ui/filebrowse_ui.h" 38 #include "chrome/browser/dom_ui/filebrowse_ui.h"
39 #include "chrome/browser/download/download_item.h" 39 #include "chrome/browser/download/download_item.h"
40 #include "chrome/browser/download/download_item_model.h" 40 #include "chrome/browser/download/download_item_model.h"
41 #include "chrome/browser/download/download_manager.h" 41 #include "chrome/browser/download/download_manager.h"
42 #include "chrome/browser/download/download_shelf.h" 42 #include "chrome/browser/download/download_shelf.h"
43 #include "chrome/browser/download/download_started_animation.h" 43 #include "chrome/browser/download/download_started_animation.h"
44 #include "chrome/browser/extensions/crashed_extension_infobar.h" 44 #include "chrome/browser/extensions/crashed_extension_infobar.h"
45 #include "chrome/browser/extensions/extension_browser_event_router.h" 45 #include "chrome/browser/extensions/extension_browser_event_router.h"
46 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" 46 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h"
47 #include "chrome/browser/extensions/extension_shelf_model.h" 47 #include "chrome/browser/extensions/extension_host.h"
48 #include "chrome/browser/extensions/extension_tabs_module.h" 48 #include "chrome/browser/extensions/extension_tabs_module.h"
49 #include "chrome/browser/extensions/extensions_service.h" 49 #include "chrome/browser/extensions/extensions_service.h"
50 #include "chrome/browser/find_bar.h" 50 #include "chrome/browser/find_bar.h"
51 #include "chrome/browser/find_bar_controller.h" 51 #include "chrome/browser/find_bar_controller.h"
52 #include "chrome/browser/first_run/first_run.h" 52 #include "chrome/browser/first_run/first_run.h"
53 #include "chrome/browser/google_url_tracker.h" 53 #include "chrome/browser/google_url_tracker.h"
54 #include "chrome/browser/google_util.h" 54 #include "chrome/browser/google_util.h"
55 #include "chrome/browser/host_zoom_map.h" 55 #include "chrome/browser/host_zoom_map.h"
56 #include "chrome/browser/location_bar.h" 56 #include "chrome/browser/location_bar.h"
57 #include "chrome/browser/metrics/user_metrics.h" 57 #include "chrome/browser/metrics/user_metrics.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 Browser* Browser::CreateForDevTools(Profile* profile) { 348 Browser* Browser::CreateForDevTools(Profile* profile) {
349 Browser* browser = new Browser(TYPE_DEVTOOLS, profile); 349 Browser* browser = new Browser(TYPE_DEVTOOLS, profile);
350 browser->app_name_ = DevToolsWindow::kDevToolsApp; 350 browser->app_name_ = DevToolsWindow::kDevToolsApp;
351 browser->CreateBrowserWindow(); 351 browser->CreateBrowserWindow();
352 return browser; 352 return browser;
353 } 353 }
354 354
355 void Browser::CreateBrowserWindow() { 355 void Browser::CreateBrowserWindow() {
356 DCHECK(!window_); 356 DCHECK(!window_);
357 357
358 if (SupportsWindowFeature(FEATURE_EXTENSIONSHELF))
359 extension_shelf_model_.reset(new ExtensionShelfModel(this));
360
361 window_ = BrowserWindow::CreateBrowserWindow(this); 358 window_ = BrowserWindow::CreateBrowserWindow(this);
362 359
363 #if defined(OS_WIN) 360 #if defined(OS_WIN)
364 // Set the app user model id for this application to that of the application 361 // Set the app user model id for this application to that of the application
365 // name. See http://crbug.com/7028. 362 // name. See http://crbug.com/7028.
366 win_util::SetAppIdForWindow( 363 win_util::SetAppIdForWindow(
367 type_ & TYPE_APP ? 364 type_ & TYPE_APP ?
368 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : 365 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) :
369 ShellIntegration::GetChromiumAppId(profile_->GetPath()), 366 ShellIntegration::GetChromiumAppId(profile_->GetPath()),
370 window()->GetNativeHandle()); 367 window()->GetNativeHandle());
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 unsigned int features = FEATURE_INFOBAR; 1149 unsigned int features = FEATURE_INFOBAR;
1153 1150
1154 #if !defined(OS_CHROMEOS) 1151 #if !defined(OS_CHROMEOS)
1155 // Chrome OS opens a FileBrowse pop up instead of using download shelf. 1152 // Chrome OS opens a FileBrowse pop up instead of using download shelf.
1156 // So FEATURE_DOWNLOADSHELF is only added for non-chromeos platforms. 1153 // So FEATURE_DOWNLOADSHELF is only added for non-chromeos platforms.
1157 features |= FEATURE_DOWNLOADSHELF; 1154 features |= FEATURE_DOWNLOADSHELF;
1158 #endif // !defined(OS_CHROMEOS) 1155 #endif // !defined(OS_CHROMEOS)
1159 1156
1160 if (type() == TYPE_NORMAL) { 1157 if (type() == TYPE_NORMAL) {
1161 features |= FEATURE_BOOKMARKBAR; 1158 features |= FEATURE_BOOKMARKBAR;
1162 features |= FEATURE_EXTENSIONSHELF;
1163 } 1159 }
1164 1160
1165 if (!hide_ui_for_fullscreen) { 1161 if (!hide_ui_for_fullscreen) {
1166 if (type() != TYPE_NORMAL && type() != TYPE_EXTENSION_APP) 1162 if (type() != TYPE_NORMAL && type() != TYPE_EXTENSION_APP)
1167 features |= FEATURE_TITLEBAR; 1163 features |= FEATURE_TITLEBAR;
1168 1164
1169 if (type() == TYPE_NORMAL || type() == TYPE_EXTENSION_APP) 1165 if (type() == TYPE_NORMAL || type() == TYPE_EXTENSION_APP)
1170 features |= FEATURE_TABSTRIP; 1166 features |= FEATURE_TABSTRIP;
1171 1167
1172 if (type() == TYPE_NORMAL || type() == TYPE_EXTENSION_APP) 1168 if (type() == TYPE_NORMAL || type() == TYPE_EXTENSION_APP)
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 return; 1720 return;
1725 ShowBrokenPageTab(contents); 1721 ShowBrokenPageTab(contents);
1726 #endif 1722 #endif
1727 } 1723 }
1728 1724
1729 void Browser::ToggleBookmarkBar() { 1725 void Browser::ToggleBookmarkBar() {
1730 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarksBar"), profile_); 1726 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarksBar"), profile_);
1731 window_->ToggleBookmarkBar(); 1727 window_->ToggleBookmarkBar();
1732 } 1728 }
1733 1729
1734 void Browser::ToggleExtensionShelf() {
1735 UserMetrics::RecordAction(UserMetricsAction("ToggleExtensionShelf"),
1736 profile_);
1737 window_->ToggleExtensionShelf();
1738 }
1739
1740 void Browser::OpenBookmarkManager() { 1730 void Browser::OpenBookmarkManager() {
1741 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), profile_); 1731 UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), profile_);
1742 ShowBookmarkManagerTab(); 1732 ShowBookmarkManagerTab();
1743 } 1733 }
1744 1734
1745 void Browser::ShowAppMenu() { 1735 void Browser::ShowAppMenu() {
1746 UserMetrics::RecordAction(UserMetricsAction("ShowAppMenu"), profile_); 1736 UserMetrics::RecordAction(UserMetricsAction("ShowAppMenu"), profile_);
1747 window_->ShowAppMenu(); 1737 window_->ShowAppMenu();
1748 } 1738 }
1749 1739
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, ""); 1932 prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, "");
1943 prefs->RegisterBooleanPref(prefs::kDeleteBrowsingHistory, true); 1933 prefs->RegisterBooleanPref(prefs::kDeleteBrowsingHistory, true);
1944 prefs->RegisterBooleanPref(prefs::kDeleteDownloadHistory, true); 1934 prefs->RegisterBooleanPref(prefs::kDeleteDownloadHistory, true);
1945 prefs->RegisterBooleanPref(prefs::kDeleteCache, true); 1935 prefs->RegisterBooleanPref(prefs::kDeleteCache, true);
1946 prefs->RegisterBooleanPref(prefs::kDeleteCookies, true); 1936 prefs->RegisterBooleanPref(prefs::kDeleteCookies, true);
1947 prefs->RegisterBooleanPref(prefs::kDeletePasswords, false); 1937 prefs->RegisterBooleanPref(prefs::kDeletePasswords, false);
1948 prefs->RegisterBooleanPref(prefs::kDeleteFormData, true); 1938 prefs->RegisterBooleanPref(prefs::kDeleteFormData, true);
1949 prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0); 1939 prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0);
1950 prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true); 1940 prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true);
1951 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true); 1941 prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true);
1952 prefs->RegisterBooleanPref(prefs::kShowExtensionShelf, true);
1953 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); 1942 prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true);
1954 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); 1943 prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true);
1955 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); 1944 prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true);
1956 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false); 1945 prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false);
1957 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true); 1946 prefs->RegisterBooleanPref(prefs::kEnableTranslate, true);
1958 } 1947 }
1959 1948
1960 // static 1949 // static
1961 Browser* Browser::GetBrowserForController( 1950 Browser* Browser::GetBrowserForController(
1962 const NavigationController* controller, int* index_result) { 1951 const NavigationController* controller, int* index_result) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow( 2110 case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow(
2122 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); 2111 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
2123 break; 2112 break;
2124 case IDC_DEV_TOOLS_INSPECT: ToggleDevToolsWindow( 2113 case IDC_DEV_TOOLS_INSPECT: ToggleDevToolsWindow(
2125 DEVTOOLS_TOGGLE_ACTION_INSPECT); 2114 DEVTOOLS_TOGGLE_ACTION_INSPECT);
2126 break; 2115 break;
2127 case IDC_TASK_MANAGER: OpenTaskManager(); break; 2116 case IDC_TASK_MANAGER: OpenTaskManager(); break;
2128 case IDC_REPORT_BUG: OpenBugReportDialog(); break; 2117 case IDC_REPORT_BUG: OpenBugReportDialog(); break;
2129 2118
2130 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; 2119 case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break;
2131 case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break;
2132 2120
2133 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; 2121 case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break;
2134 case IDC_SHOW_APP_MENU: ShowAppMenu(); break; 2122 case IDC_SHOW_APP_MENU: ShowAppMenu(); break;
2135 case IDC_SHOW_HISTORY: ShowHistoryTab(); break; 2123 case IDC_SHOW_HISTORY: ShowHistoryTab(); break;
2136 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; 2124 case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break;
2137 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; 2125 case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break;
2138 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; 2126 case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break;
2139 #if defined(ENABLE_REMOTING) 2127 #if defined(ENABLE_REMOTING)
2140 case IDC_REMOTING_SETUP: OpenRemotingSetupDialog(); break; 2128 case IDC_REMOTING_SETUP: OpenRemotingSetupDialog(); break;
2141 #endif 2129 #endif
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 return !!(type() & TYPE_POPUP); 2673 return !!(type() & TYPE_POPUP);
2686 } 2674 }
2687 2675
2688 void Browser::ToolbarSizeChanged(TabContents* source, bool is_animating) { 2676 void Browser::ToolbarSizeChanged(TabContents* source, bool is_animating) {
2689 if (source == GetSelectedTabContents() || source == NULL) { 2677 if (source == GetSelectedTabContents() || source == NULL) {
2690 // This will refresh the shelf if needed. 2678 // This will refresh the shelf if needed.
2691 window_->SelectedTabToolbarSizeChanged(is_animating); 2679 window_->SelectedTabToolbarSizeChanged(is_animating);
2692 } 2680 }
2693 } 2681 }
2694 2682
2695 void Browser::ExtensionShelfSizeChanged() {
2696 window_->SelectedTabExtensionShelfSizeChanged();
2697 }
2698
2699 void Browser::URLStarredChanged(TabContents* source, bool starred) { 2683 void Browser::URLStarredChanged(TabContents* source, bool starred) {
2700 if (source == GetSelectedTabContents()) 2684 if (source == GetSelectedTabContents())
2701 window_->SetStarredState(starred); 2685 window_->SetStarredState(starred);
2702 } 2686 }
2703 2687
2704 void Browser::ContentsMouseEvent( 2688 void Browser::ContentsMouseEvent(
2705 TabContents* source, const gfx::Point& location, bool motion) { 2689 TabContents* source, const gfx::Point& location, bool motion) {
2706 if (!GetStatusBubble()) 2690 if (!GetStatusBubble())
2707 return; 2691 return;
2708 2692
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 3217
3234 // Show various bits of UI 3218 // Show various bits of UI
3235 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, true); 3219 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, true);
3236 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false); 3220 command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false);
3237 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, true); 3221 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, true);
3238 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE, true); 3222 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_CONSOLE, true);
3239 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_INSPECT, true); 3223 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS_INSPECT, true);
3240 command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true); 3224 command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true);
3241 command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true); 3225 command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
3242 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true); 3226 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true);
3243 command_updater_.UpdateCommandEnabled(IDC_SHOW_EXTENSION_SHELF, true);
3244 command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); 3227 command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
3245 command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true); 3228 command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true);
3246 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true); 3229 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true);
3247 3230
3248 #if defined(OS_CHROMEOS) 3231 #if defined(OS_CHROMEOS)
3249 command_updater_.UpdateCommandEnabled(IDC_SEARCH, true); 3232 command_updater_.UpdateCommandEnabled(IDC_SEARCH, true);
3250 command_updater_.UpdateCommandEnabled(IDC_SYSTEM_OPTIONS, true); 3233 command_updater_.UpdateCommandEnabled(IDC_SYSTEM_OPTIONS, true);
3251 command_updater_.UpdateCommandEnabled(IDC_INTERNET_OPTIONS, true); 3234 command_updater_.UpdateCommandEnabled(IDC_INTERNET_OPTIONS, true);
3252 #endif 3235 #endif
3253 3236
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3411 if (changed_flags & TabContents::INVALIDATE_TITLE && !source->is_loading()) { 3394 if (changed_flags & TabContents::INVALIDATE_TITLE && !source->is_loading()) {
3412 // To correctly calculate whether the title changed while not loading 3395 // To correctly calculate whether the title changed while not loading
3413 // we need to process the update synchronously. This state only matters for 3396 // we need to process the update synchronously. This state only matters for
3414 // the TabStripModel, so we notify the TabStripModel now and notify others 3397 // the TabStripModel, so we notify the TabStripModel now and notify others
3415 // asynchronously. 3398 // asynchronously.
3416 tabstrip_model_.UpdateTabContentsStateAt( 3399 tabstrip_model_.UpdateTabContentsStateAt(
3417 tabstrip_model_.GetIndexOfController(&source->controller()), 3400 tabstrip_model_.GetIndexOfController(&source->controller()),
3418 TabStripModelObserver::TITLE_NOT_LOADING); 3401 TabStripModelObserver::TITLE_NOT_LOADING);
3419 } 3402 }
3420 3403
3421 if (changed_flags & TabContents::INVALIDATE_BOOKMARK_BAR || 3404 if (changed_flags & TabContents::INVALIDATE_BOOKMARK_BAR) {
3422 changed_flags & TabContents::INVALIDATE_EXTENSION_SHELF) {
3423 window()->ShelfVisibilityChanged(); 3405 window()->ShelfVisibilityChanged();
3424 changed_flags &= ~(TabContents::INVALIDATE_BOOKMARK_BAR | 3406 changed_flags &= ~TabContents::INVALIDATE_BOOKMARK_BAR;
3425 TabContents::INVALIDATE_EXTENSION_SHELF);
3426 } 3407 }
3427 3408
3428 // If the only updates were synchronously handled above, we're done. 3409 // If the only updates were synchronously handled above, we're done.
3429 if (changed_flags == 0) 3410 if (changed_flags == 0)
3430 return; 3411 return;
3431 3412
3432 // Save the dirty bits. 3413 // Save the dirty bits.
3433 scheduled_updates_[source] |= changed_flags; 3414 scheduled_updates_[source] |= changed_flags;
3434 3415
3435 if (chrome_updater_factory_.empty()) { 3416 if (chrome_updater_factory_.empty()) {
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 } 4102 }
4122 4103
4123 bool Browser::IsPinned(TabContents* source) { 4104 bool Browser::IsPinned(TabContents* source) {
4124 int index = tabstrip_model_.GetIndexOfTabContents(source); 4105 int index = tabstrip_model_.GetIndexOfTabContents(source);
4125 if (index == TabStripModel::kNoTab) { 4106 if (index == TabStripModel::kNoTab) {
4126 NOTREACHED() << "IsPinned called for tab not in our strip"; 4107 NOTREACHED() << "IsPinned called for tab not in our strip";
4127 return false; 4108 return false;
4128 } 4109 }
4129 return tabstrip_model_.IsTabPinned(index); 4110 return tabstrip_model_.IsTabPinned(index);
4130 } 4111 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.h ('k') | chrome/browser/browser_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698