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/webui/options2/browser_options_handler2.cc

Issue 9432003: Disable multi-profile UI in managed mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add notreached() 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/webui/options2/browser_options_handler2.h" 5 #include "chrome/browser/ui/webui/options2/browser_options_handler2.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 entry->SetString("url", match.destination_url.spec()); 645 entry->SetString("url", match.destination_url.spec());
646 suggestions.Append(entry); 646 suggestions.Append(entry);
647 } 647 }
648 648
649 web_ui()->CallJavascriptFunction( 649 web_ui()->CallJavascriptFunction(
650 "BrowserOptions.updateAutocompleteSuggestions", suggestions); 650 "BrowserOptions.updateAutocompleteSuggestions", suggestions);
651 } 651 }
652 652
653 void BrowserOptionsHandler::SendProfilesInfo() { 653 void BrowserOptionsHandler::SendProfilesInfo() {
654 // Set profile creation text and button if multi-profiles switch is on. 654 // Set profile creation text and button if multi-profiles switch is on.
655 scoped_ptr<Value> visible(Value::CreateBooleanValue(multiprofile_)); 655 bool profiles_section_visible = multiprofile_ &&
656 !g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode);
657
658 scoped_ptr<Value> visible(
659 Value::CreateBooleanValue(profiles_section_visible));
656 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible", 660 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible",
657 *visible); 661 *visible);
658 662
659 if (!multiprofile_) 663 if (!profiles_section_visible)
660 return; 664 return;
661 665
662 ProfileInfoCache& cache = 666 ProfileInfoCache& cache =
663 g_browser_process->profile_manager()->GetProfileInfoCache(); 667 g_browser_process->profile_manager()->GetProfileInfoCache();
664 ListValue profile_info_list; 668 ListValue profile_info_list;
665 FilePath current_profile_path = 669 FilePath current_profile_path =
666 web_ui()->GetWebContents()->GetBrowserContext()->GetPath(); 670 web_ui()->GetWebContents()->GetBrowserContext()->GetPath();
667 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { 671 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) {
668 DictionaryValue* profile_value = new DictionaryValue(); 672 DictionaryValue* profile_value = new DictionaryValue();
669 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); 673 FilePath profile_path = cache.GetPathOfProfileAtIndex(i);
(...skipping 16 matching lines...) Expand all
686 } 690 }
687 691
688 profile_info_list.Append(profile_value); 692 profile_info_list.Append(profile_value);
689 } 693 }
690 694
691 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", 695 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo",
692 profile_info_list); 696 profile_info_list);
693 } 697 }
694 698
695 void BrowserOptionsHandler::CreateProfile(const ListValue* args) { 699 void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
700 if (!g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)) {
Joao da Silva 2012/02/23 12:05:14 Is this really a !InManagedMode?
Bernhard Bauer 2012/02/23 12:14:36 Yeah, that's backwards :-D
701 NOTREACHED();
702 return;
703 }
696 ProfileManager::CreateMultiProfileAsync(); 704 ProfileManager::CreateMultiProfileAsync();
697 } 705 }
698 706
699 void BrowserOptionsHandler::ObserveThemeChanged() { 707 void BrowserOptionsHandler::ObserveThemeChanged() {
700 Profile* profile = Profile::FromWebUI(web_ui()); 708 Profile* profile = Profile::FromWebUI(web_ui());
701 #if defined(TOOLKIT_GTK) 709 #if defined(TOOLKIT_GTK)
702 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); 710 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile);
703 bool is_gtk_theme = theme_service->UsingNativeTheme(); 711 bool is_gtk_theme = theme_service->UsingNativeTheme();
704 base::FundamentalValue gtk_enabled(!is_gtk_theme); 712 base::FundamentalValue gtk_enabled(!is_gtk_theme);
705 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled", 713 web_ui()->CallJavascriptFunction("BrowserOptions.setGtkThemeButtonEnabled",
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 sync_status->SetBoolean("hasUnrecoverableError", 788 sync_status->SetBoolean("hasUnrecoverableError",
781 service->unrecoverable_error_detected()); 789 service->unrecoverable_error_detected());
782 sync_status->SetBoolean("autoLoginVisible", 790 sync_status->SetBoolean("autoLoginVisible",
783 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin) && 791 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin) &&
784 service->AreCredentialsAvailable()); 792 service->AreCredentialsAvailable());
785 793
786 return sync_status; 794 return sync_status;
787 } 795 }
788 796
789 } // namespace options2 797 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698