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

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

Powered by Google App Engine
This is Rietveld 408576698