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

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

Issue 178863002: Implement settings in a widnow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ash/system_tray_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "chrome/browser/ui/browser.h" 81 #include "chrome/browser/ui/browser.h"
82 #include "chrome/browser/ui/browser_finder.h" 82 #include "chrome/browser/ui/browser_finder.h"
83 #include "chrome/browser/ui/chrome_pages.h" 83 #include "chrome/browser/ui/chrome_pages.h"
84 #include "chrome/browser/ui/host_desktop.h" 84 #include "chrome/browser/ui/host_desktop.h"
85 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 85 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
86 #include "chrome/browser/ui/singleton_tabs.h" 86 #include "chrome/browser/ui/singleton_tabs.h"
87 #include "chrome/browser/ui/tabs/tab_strip_model.h" 87 #include "chrome/browser/ui/tabs/tab_strip_model.h"
88 #include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h" 88 #include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h"
89 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 89 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
90 #include "chrome/browser/upgrade_detector.h" 90 #include "chrome/browser/upgrade_detector.h"
91 #include "chrome/common/chrome_switches.h"
91 #include "chrome/common/pref_names.h" 92 #include "chrome/common/pref_names.h"
92 #include "chrome/common/url_constants.h" 93 #include "chrome/common/url_constants.h"
93 #include "chromeos/dbus/dbus_thread_manager.h" 94 #include "chromeos/dbus/dbus_thread_manager.h"
94 #include "chromeos/dbus/session_manager_client.h" 95 #include "chromeos/dbus/session_manager_client.h"
95 #include "chromeos/ime/extension_ime_util.h" 96 #include "chromeos/ime/extension_ime_util.h"
96 #include "chromeos/ime/input_method_manager.h" 97 #include "chromeos/ime/input_method_manager.h"
97 #include "chromeos/ime/xkeyboard.h" 98 #include "chromeos/ime/xkeyboard.h"
98 #include "chromeos/login/login_state.h" 99 #include "chromeos/login/login_state.h"
99 #include "components/policy/core/common/cloud/cloud_policy_store.h" 100 #include "components/policy/core/common/cloud/cloud_policy_store.h"
100 #include "content/public/browser/notification_observer.h" 101 #include "content/public/browser/notification_observer.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 211
211 void BluetoothSetDiscoveringError() { 212 void BluetoothSetDiscoveringError() {
212 LOG(ERROR) << "BluetoothSetDiscovering failed."; 213 LOG(ERROR) << "BluetoothSetDiscovering failed.";
213 } 214 }
214 215
215 void BluetoothDeviceConnectError( 216 void BluetoothDeviceConnectError(
216 device::BluetoothDevice::ConnectErrorCode error_code) { 217 device::BluetoothDevice::ConnectErrorCode error_code) {
217 // TODO(sad): Do something? 218 // TODO(sad): Do something?
218 } 219 }
219 220
220 // Shows the settings sub page in the last active browser. If there is no such 221 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) {
221 // browser, creates a new browser with the settings sub page. 222 chrome::ShowSettingsSubPageForProfile(
222 void ShowSettingsSubPageForAppropriateBrowser(const std::string& sub_page, 223 ProfileManager::GetActiveUserProfile(), sub_page);
223 Profile* profile) { 224 }
224 chrome::ScopedTabbedBrowserDisplayer displayer(profile, 225
225 chrome::HOST_DESKTOP_TYPE_ASH); 226 void ShowSettingsSubPageForPrimaryUser(const std::string& sub_page) {
226 chrome::ShowSettingsSubPage(displayer.browser(), sub_page); 227 chrome::ShowSettingsSubPageForProfile(
228 ProfileManager::GetPrimaryUserProfile(), sub_page);
227 } 229 }
228 230
229 void ShowNetworkSettingsPage(const std::string& service_path) { 231 void ShowNetworkSettingsPage(const std::string& service_path) {
230 std::string page = chrome::kInternetOptionsSubPage; 232 std::string page = chrome::kInternetOptionsSubPage;
231 page += "?servicePath=" + net::EscapeUrlEncodedData(service_path, true); 233 page += "?servicePath=" + net::EscapeUrlEncodedData(service_path, true);
232 content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog")); 234 content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog"));
233 ShowSettingsSubPageForAppropriateBrowser( 235 ShowSettingsSubPageForPrimaryUser(page);
234 page, ProfileManager::GetPrimaryUserProfile());
235 } 236 }
236 237
237 void OnAcceptMultiprofilesIntro(bool no_show_again) { 238 void OnAcceptMultiprofilesIntro(bool no_show_again) {
238 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); 239 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
239 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); 240 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again);
240 UserAddingScreen::Get()->Start(); 241 UserAddingScreen::Get()->Start();
241 } 242 }
242 243
243 } // namespace 244 } // namespace
244 245
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 bool SystemTrayDelegateChromeOS::IsOobeCompleted() const { 420 bool SystemTrayDelegateChromeOS::IsOobeCompleted() const {
420 if (!base::SysInfo::IsRunningOnChromeOS() && 421 if (!base::SysInfo::IsRunningOnChromeOS() &&
421 LoginState::Get()->IsUserLoggedIn()) 422 LoginState::Get()->IsUserLoggedIn())
422 return true; 423 return true;
423 return StartupUtils::IsOobeCompleted(); 424 return StartupUtils::IsOobeCompleted();
424 } 425 }
425 426
426 void SystemTrayDelegateChromeOS::ChangeProfilePicture() { 427 void SystemTrayDelegateChromeOS::ChangeProfilePicture() {
427 content::RecordAction( 428 content::RecordAction(
428 base::UserMetricsAction("OpenChangeProfilePictureDialog")); 429 base::UserMetricsAction("OpenChangeProfilePictureDialog"));
429 ShowSettingsSubPageForAppropriateBrowser( 430 ShowSettingsSubPageForActiveUser(chrome::kChangeProfilePictureSubPage);
430 chrome::kChangeProfilePictureSubPage,
431 ProfileManager::GetActiveUserProfile());
432 } 431 }
433 432
434 const std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const { 433 const std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const {
435 return enterprise_domain_; 434 return enterprise_domain_;
436 } 435 }
437 436
438 const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const { 437 const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
439 if (GetEnterpriseDomain().empty()) 438 if (GetEnterpriseDomain().empty())
440 return base::string16(); 439 return base::string16();
441 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE, 440 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE,
(...skipping 27 matching lines...) Expand all
469 468
470 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const { 469 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const {
471 return UpgradeDetector::GetInstance()->notify_upgrade(); 470 return UpgradeDetector::GetInstance()->notify_upgrade();
472 } 471 }
473 472
474 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const { 473 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const {
475 return clock_type_; 474 return clock_type_;
476 } 475 }
477 476
478 void SystemTrayDelegateChromeOS::ShowSettings() { 477 void SystemTrayDelegateChromeOS::ShowSettings() {
479 chrome::ScopedTabbedBrowserDisplayer displayer( 478 ShowSettingsSubPageForActiveUser("");
480 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
481 chrome::ShowSettings(displayer.browser());
482 } 479 }
483 480
484 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { 481 bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
485 return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings(); 482 return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings();
486 } 483 }
487 484
488 void SystemTrayDelegateChromeOS::ShowDateSettings() { 485 void SystemTrayDelegateChromeOS::ShowDateSettings() {
489 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); 486 content::RecordAction(base::UserMetricsAction("ShowDateOptions"));
490 std::string sub_page = 487 std::string sub_page =
491 std::string(chrome::kSearchSubPage) + "#" + 488 std::string(chrome::kSearchSubPage) + "#" +
492 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); 489 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
493 // Everybody can change the time zone (even though it is a device setting). 490 // Everybody can change the time zone (even though it is a device setting).
494 ShowSettingsSubPageForAppropriateBrowser( 491 ShowSettingsSubPageForActiveUser(sub_page);
495 sub_page, ProfileManager::GetActiveUserProfile());
496 } 492 }
497 493
498 void SystemTrayDelegateChromeOS::ShowNetworkSettings( 494 void SystemTrayDelegateChromeOS::ShowNetworkSettings(
499 const std::string& service_path) { 495 const std::string& service_path) {
500 if (!LoginState::Get()->IsUserLoggedIn()) 496 if (!LoginState::Get()->IsUserLoggedIn())
501 return; 497 return;
502 ShowNetworkSettingsPage(service_path); 498 ShowNetworkSettingsPage(service_path);
503 } 499 }
504 500
505 void SystemTrayDelegateChromeOS::ShowBluetoothSettings() { 501 void SystemTrayDelegateChromeOS::ShowBluetoothSettings() {
506 // TODO(sad): Make this work. 502 // TODO(sad): Make this work.
507 } 503 }
508 504
509 void SystemTrayDelegateChromeOS::ShowDisplaySettings() { 505 void SystemTrayDelegateChromeOS::ShowDisplaySettings() {
510 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); 506 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions"));
511 ShowSettingsSubPageForAppropriateBrowser( 507 ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName);
512 kDisplaySettingsSubPageName, ProfileManager::GetActiveUserProfile());
513 } 508 }
514 509
515 void SystemTrayDelegateChromeOS::ShowChromeSlow() { 510 void SystemTrayDelegateChromeOS::ShowChromeSlow() {
516 chrome::ScopedTabbedBrowserDisplayer displayer( 511 chrome::ScopedTabbedBrowserDisplayer displayer(
517 ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 512 ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
518 chrome::ShowSlow(displayer.browser()); 513 chrome::ShowSlow(displayer.browser());
519 } 514 }
520 515
521 bool SystemTrayDelegateChromeOS::ShouldShowDisplayNotification() { 516 bool SystemTrayDelegateChromeOS::ShouldShowDisplayNotification() {
522 // Packaged app is not counted as 'last active', so if a browser opening the 517 // Packaged app is not counted as 'last active', so if a browser opening the
523 // display settings is in background of a packaged app, it will return true. 518 // display settings is in background of a packaged app, it will return true.
524 // TODO(mukai): fix this. 519 // TODO(mukai): fix this.
525 Browser* active_browser = 520 Browser* active_browser =
526 chrome::FindLastActiveWithHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH); 521 chrome::FindLastActiveWithHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH);
527 if (!active_browser) 522 if (!active_browser)
528 return true; 523 return true;
529 524
530 content::WebContents* active_contents = 525 content::WebContents* active_contents =
531 active_browser->tab_strip_model()->GetActiveWebContents(); 526 active_browser->tab_strip_model()->GetActiveWebContents();
532 if (!active_contents) 527 if (!active_contents)
533 return true; 528 return true;
534 529
535 GURL visible_url = active_contents->GetLastCommittedURL(); 530 GURL visible_url = active_contents->GetLastCommittedURL();
536 std::string display_settings_url = 531 GURL display_settings_url =
537 std::string(chrome::kChromeUISettingsURL) + kDisplaySettingsSubPageName; 532 chrome::GetSettingsUrl(kDisplaySettingsSubPageName);
538 std::string display_overscan_url = std::string(chrome::kChromeUISettingsURL) + 533 GURL display_overscan_url =
539 kDisplayOverscanSettingsSubPageName; 534 chrome::GetSettingsUrl(kDisplayOverscanSettingsSubPageName);
540 return (visible_url.spec() != display_settings_url) && 535 return (visible_url != display_settings_url &&
541 (visible_url.spec() != display_overscan_url); 536 visible_url != display_overscan_url);
542 } 537 }
543 538
544 void SystemTrayDelegateChromeOS::ShowDriveSettings() { 539 void SystemTrayDelegateChromeOS::ShowDriveSettings() {
545 // TODO(tengs): Open the drive-specific settings page once we put it in. 540 // TODO(tengs): Open the drive-specific settings page once we put it in.
546 // For now just show Google Drive main page. 541 // For now just show Google Drive main page.
547 chrome::ScopedTabbedBrowserDisplayer displayer( 542 chrome::ScopedTabbedBrowserDisplayer displayer(
548 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 543 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
549 chrome::ShowSingletonTabOverwritingNTP( 544 chrome::ShowSingletonTabOverwritingNTP(
550 displayer.browser(), 545 displayer.browser(),
551 chrome::GetSingletonTabNavigateParams(displayer.browser(), 546 chrome::GetSingletonTabNavigateParams(displayer.browser(),
552 GURL(kDriveSettingsPageURL))); 547 GURL(kDriveSettingsPageURL)));
553 } 548 }
554 549
555 void SystemTrayDelegateChromeOS::ShowIMESettings() { 550 void SystemTrayDelegateChromeOS::ShowIMESettings() {
556 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); 551 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog"));
557 ShowSettingsSubPageForAppropriateBrowser( 552 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage);
558 chrome::kLanguageOptionsSubPage, ProfileManager::GetActiveUserProfile());
559 } 553 }
560 554
561 void SystemTrayDelegateChromeOS::ShowHelp() { 555 void SystemTrayDelegateChromeOS::ShowHelp() {
562 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), 556 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(),
563 chrome::HOST_DESKTOP_TYPE_ASH, 557 chrome::HOST_DESKTOP_TYPE_ASH,
564 chrome::HELP_SOURCE_MENU); 558 chrome::HELP_SOURCE_MENU);
565 } 559 }
566 560
567 void SystemTrayDelegateChromeOS::ShowAccessibilityHelp() { 561 void SystemTrayDelegateChromeOS::ShowAccessibilityHelp() {
568 chrome::ScopedTabbedBrowserDisplayer displayer( 562 chrome::ScopedTabbedBrowserDisplayer displayer(
569 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 563 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
570 accessibility::ShowAccessibilityHelp(displayer.browser()); 564 accessibility::ShowAccessibilityHelp(displayer.browser());
571 } 565 }
572 566
573 void SystemTrayDelegateChromeOS::ShowAccessibilitySettings() { 567 void SystemTrayDelegateChromeOS::ShowAccessibilitySettings() {
574 content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings")); 568 content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings"));
575 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + 569 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
576 l10n_util::GetStringUTF8( 570 l10n_util::GetStringUTF8(
577 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY); 571 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY);
578 ShowSettingsSubPageForAppropriateBrowser( 572 ShowSettingsSubPageForActiveUser(sub_page);
579 sub_page, ProfileManager::GetActiveUserProfile());
580 } 573 }
581 574
582 void SystemTrayDelegateChromeOS::ShowPublicAccountInfo() { 575 void SystemTrayDelegateChromeOS::ShowPublicAccountInfo() {
583 chrome::ScopedTabbedBrowserDisplayer displayer( 576 chrome::ScopedTabbedBrowserDisplayer displayer(
584 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 577 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
585 chrome::ShowPolicy(displayer.browser()); 578 chrome::ShowPolicy(displayer.browser());
586 } 579 }
587 580
588 void SystemTrayDelegateChromeOS::ShowLocallyManagedUserInfo() { 581 void SystemTrayDelegateChromeOS::ShowLocallyManagedUserInfo() {
589 // TODO(antrim): find out what should we show in this case. 582 // TODO(antrim): find out what should we show in this case.
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 const std::string& network_id, 808 const std::string& network_id,
816 gfx::NativeWindow parent_window) { 809 gfx::NativeWindow parent_window) {
817 return enrollment::CreateDialog(network_id, parent_window); 810 return enrollment::CreateDialog(network_id, parent_window);
818 } 811 }
819 812
820 void SystemTrayDelegateChromeOS::ManageBluetoothDevices() { 813 void SystemTrayDelegateChromeOS::ManageBluetoothDevices() {
821 content::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage")); 814 content::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage"));
822 std::string sub_page = 815 std::string sub_page =
823 std::string(chrome::kSearchSubPage) + "#" + 816 std::string(chrome::kSearchSubPage) + "#" +
824 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH); 817 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH);
825 ShowSettingsSubPageForAppropriateBrowser( 818 ShowSettingsSubPageForPrimaryUser(sub_page);
826 sub_page, ProfileManager::GetPrimaryUserProfile());
827 } 819 }
828 820
829 void SystemTrayDelegateChromeOS::ToggleBluetooth() { 821 void SystemTrayDelegateChromeOS::ToggleBluetooth() {
830 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(), 822 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(),
831 base::Bind(&base::DoNothing), 823 base::Bind(&base::DoNothing),
832 base::Bind(&BluetoothPowerFailure)); 824 base::Bind(&BluetoothPowerFailure));
833 } 825 }
834 826
835 void SystemTrayDelegateChromeOS::ShowMobileSimDialog() { 827 void SystemTrayDelegateChromeOS::ShowMobileSimDialog() {
836 SimDialogDelegate::ShowDialog(GetNativeWindow(), 828 SimDialogDelegate::ShowDialog(GetNativeWindow(),
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 accessibility_subscription_.reset(); 1313 accessibility_subscription_.reset();
1322 else 1314 else
1323 OnAccessibilityModeChanged(details.notify); 1315 OnAccessibilityModeChanged(details.notify);
1324 } 1316 }
1325 1317
1326 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1318 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1327 return new SystemTrayDelegateChromeOS(); 1319 return new SystemTrayDelegateChromeOS();
1328 } 1320 }
1329 1321
1330 } // namespace chromeos 1322 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698