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

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

Issue 9359022: Aura: Support hovering restore & close buttons for full screen apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added new test for tab restore Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return true; 314 return true;
315 } 315 }
316 316
317 } // namespace 317 } // namespace
318 318
319 //////////////////////////////////////////////////////////////////////////////// 319 ////////////////////////////////////////////////////////////////////////////////
320 // Browser, CreateParams: 320 // Browser, CreateParams:
321 321
322 Browser::CreateParams::CreateParams(Type type, Profile* profile) 322 Browser::CreateParams::CreateParams(Type type, Profile* profile)
323 : type(type), 323 : type(type),
324 profile(profile) { 324 profile(profile),
325 initial_show_state(ui::SHOW_STATE_DEFAULT),
326 is_session_restore(false) {
325 } 327 }
326 328
327 /////////////////////////////////////////////////////////////////////////////// 329 ///////////////////////////////////////////////////////////////////////////////
328 // Browser, Constructors, Creation, Showing: 330 // Browser, Constructors, Creation, Showing:
329 331
330 Browser::Browser(Type type, Profile* profile) 332 Browser::Browser(Type type, Profile* profile)
331 : type_(type), 333 : type_(type),
332 profile_(profile), 334 profile_(profile),
333 window_(NULL), 335 window_(NULL),
334 ALLOW_THIS_IN_INITIALIZER_LIST( 336 ALLOW_THIS_IN_INITIALIZER_LIST(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 481
480 // static 482 // static
481 Browser* Browser::Create(Profile* profile) { 483 Browser* Browser::Create(Profile* profile) {
482 Browser* browser = new Browser(TYPE_TABBED, profile); 484 Browser* browser = new Browser(TYPE_TABBED, profile);
483 browser->InitBrowserWindow(); 485 browser->InitBrowserWindow();
484 return browser; 486 return browser;
485 } 487 }
486 488
487 // static 489 // static
488 Browser* Browser::CreateWithParams(const CreateParams& params) { 490 Browser* Browser::CreateWithParams(const CreateParams& params) {
491 if (!params.app_name.empty())
492 RegisterAppPrefs(params.app_name, params.profile);
493
489 Browser* browser = new Browser(params.type, params.profile); 494 Browser* browser = new Browser(params.type, params.profile);
490 browser->app_name_ = params.app_name; 495 browser->app_name_ = params.app_name;
491 browser->set_override_bounds(params.initial_bounds); 496 browser->set_override_bounds(params.initial_bounds);
497 browser->set_show_state(params.initial_show_state);
498 browser->set_is_session_restore(params.is_session_restore);
499
492 browser->InitBrowserWindow(); 500 browser->InitBrowserWindow();
493 return browser; 501 return browser;
494 } 502 }
495 503
496 // static 504 // static
497 Browser* Browser::CreateForType(Type type, Profile* profile) { 505 Browser* Browser::CreateForType(Type type, Profile* profile) {
498 CreateParams params(type, profile); 506 CreateParams params(type, profile);
499 return CreateWithParams(params); 507 return CreateWithParams(params);
500 } 508 }
501 509
502 // static 510 // static
503 Browser* Browser::CreateForApp(Type type, 511 Browser* Browser::CreateForApp(Type type,
504 const std::string& app_name, 512 const std::string& app_name,
505 const gfx::Rect& window_bounds, 513 const gfx::Rect& window_bounds,
506 Profile* profile) { 514 Profile* profile) {
507 DCHECK(type != TYPE_TABBED); 515 DCHECK(type != TYPE_TABBED);
508 DCHECK(!app_name.empty()); 516 DCHECK(!app_name.empty());
509 517
510 RegisterAppPrefs(app_name, profile);
511
512 #if !defined(OS_CHROMEOS) || defined(USE_AURA) 518 #if !defined(OS_CHROMEOS) || defined(USE_AURA)
513 if (type == TYPE_PANEL && 519 if (type == TYPE_PANEL &&
514 !PanelManager::ShouldUsePanels( 520 !PanelManager::ShouldUsePanels(
515 web_app::GetExtensionIdFromApplicationName(app_name))) { 521 web_app::GetExtensionIdFromApplicationName(app_name))) {
516 type = TYPE_POPUP; 522 type = TYPE_POPUP;
517 } 523 }
518 #if defined(TOOLKIT_GTK) 524 #if defined(TOOLKIT_GTK)
519 // Panels are only supported on a white list of window managers for Linux. 525 // Panels are only supported on a white list of window managers for Linux.
520 if (type == TYPE_PANEL) { 526 if (type == TYPE_PANEL) {
521 ui::WindowManagerName wm_type = ui::GuessWindowManager(); 527 ui::WindowManagerName wm_type = ui::GuessWindowManager();
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 return name; 977 return name;
972 } 978 }
973 979
974 bool Browser::ShouldSaveWindowPlacement() const { 980 bool Browser::ShouldSaveWindowPlacement() const {
975 switch (type_) { 981 switch (type_) {
976 case TYPE_TABBED: 982 case TYPE_TABBED:
977 return true; 983 return true;
978 case TYPE_POPUP: 984 case TYPE_POPUP:
979 // Only save the window placement of popups if they are restored, 985 // Only save the window placement of popups if they are restored,
980 // or the window belongs to DevTools. 986 // or the window belongs to DevTools.
987 #if defined USE_AURA
988 if (is_app())
989 return true;
990 #endif
981 return browser_defaults::kRestorePopups || is_devtools(); 991 return browser_defaults::kRestorePopups || is_devtools();
982 case TYPE_PANEL: 992 case TYPE_PANEL:
983 // Do not save the window placement of panels. 993 // Do not save the window placement of panels.
984 return false; 994 return false;
985 default: 995 default:
986 return false; 996 return false;
987 } 997 }
988 } 998 }
989 999
990 void Browser::SaveWindowPlacement(const gfx::Rect& bounds, 1000 void Browser::SaveWindowPlacement(const gfx::Rect& bounds,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 int x, y; 1040 int x, y;
1031 if (ParseCommaSeparatedIntegers(str, &x, &y)) 1041 if (ParseCommaSeparatedIntegers(str, &x, &y))
1032 restored_bounds.set_origin(gfx::Point(x, y)); 1042 restored_bounds.set_origin(gfx::Point(x, y));
1033 } 1043 }
1034 1044
1035 return restored_bounds; 1045 return restored_bounds;
1036 } 1046 }
1037 1047
1038 ui::WindowShowState Browser::GetSavedWindowShowState() const { 1048 ui::WindowShowState Browser::GetSavedWindowShowState() const {
1039 // Only tabbed browsers use the command line or preference state. 1049 // Only tabbed browsers use the command line or preference state.
1040 if (!is_type_tabbed()) 1050 bool return_show_state = !is_type_tabbed();
sky 2012/02/24 20:56:04 nit: how about just show_state. Initially when I s
DaveMoore 2012/02/25 16:54:42 Done.
1051
1052 #if defined(USE_AURA)
1053 // Apps save state on aura.
1054 return_show_state &= !is_app();
1055 #endif
1056
1057 if (return_show_state)
1041 return show_state_; 1058 return show_state_;
1042 1059
1043 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) 1060 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized))
1044 return ui::SHOW_STATE_MAXIMIZED; 1061 return ui::SHOW_STATE_MAXIMIZED;
1045 1062
1046 if (show_state_ != ui::SHOW_STATE_DEFAULT) 1063 if (show_state_ != ui::SHOW_STATE_DEFAULT)
1047 return show_state_; 1064 return show_state_;
1048 1065
1049 const DictionaryValue* window_pref = 1066 const DictionaryValue* window_pref =
1050 profile()->GetPrefs()->GetDictionary(GetWindowPlacementKey().c_str()); 1067 profile()->GetPrefs()->GetDictionary(GetWindowPlacementKey().c_str());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1164
1148 // Don't use GetForProfileIfExisting here, we want to force creation of the 1165 // Don't use GetForProfileIfExisting here, we want to force creation of the
1149 // session service so that user can restore what was open. 1166 // session service so that user can restore what was open.
1150 SessionService* session_service = 1167 SessionService* session_service =
1151 SessionServiceFactory::GetForProfile(profile()); 1168 SessionServiceFactory::GetForProfile(profile());
1152 if (session_service) 1169 if (session_service)
1153 session_service->WindowClosing(session_id()); 1170 session_service->WindowClosing(session_id());
1154 1171
1155 TabRestoreService* tab_restore_service = 1172 TabRestoreService* tab_restore_service =
1156 TabRestoreServiceFactory::GetForProfile(profile()); 1173 TabRestoreServiceFactory::GetForProfile(profile());
1174
1175 #if defined(USE_AURA)
1176 if (tab_restore_service && is_app())
sky 2012/02/24 20:56:04 Move this into it's own method with the ifdef so t
1177 tab_restore_service->BrowserClosing(tab_restore_service_delegate());
1178 #endif
1179
1157 if (tab_restore_service && is_type_tabbed() && tab_count()) 1180 if (tab_restore_service && is_type_tabbed() && tab_count())
1158 tab_restore_service->BrowserClosing(tab_restore_service_delegate()); 1181 tab_restore_service->BrowserClosing(tab_restore_service_delegate());
1159 1182
1160 // TODO(sky): convert session/tab restore to use notification. 1183 // TODO(sky): convert session/tab restore to use notification.
1161 content::NotificationService::current()->Notify( 1184 content::NotificationService::current()->Notify(
1162 chrome::NOTIFICATION_BROWSER_CLOSING, 1185 chrome::NOTIFICATION_BROWSER_CLOSING,
1163 content::Source<Browser>(this), 1186 content::Source<Browser>(this),
1164 content::Details<bool>(&exiting)); 1187 content::Details<bool>(&exiting));
1165 1188
1166 CloseAllTabs(); 1189 CloseAllTabs();
(...skipping 4409 matching lines...) Expand 10 before | Expand all | Expand 10 after
5576 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; 5599 params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
5577 ShowSingletonTabOverwritingNTP(params); 5600 ShowSingletonTabOverwritingNTP(params);
5578 } else { 5601 } else {
5579 service->ShowLoginDialog(); 5602 service->ShowLoginDialog();
5580 } 5603 }
5581 } 5604 }
5582 5605
5583 void Browser::ToggleSpeechInput() { 5606 void Browser::ToggleSpeechInput() {
5584 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); 5607 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput();
5585 } 5608 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698