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

Side by Side Diff: chrome/browser/ui/webui/options/options_managed_banner_handler.cc

Issue 7096013: Allow device policy code to be optionally included. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make changes requested by torne. Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/options/options_managed_banner_handler.h" 5 #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "content/browser/webui/web_ui.h" 10 #include "content/browser/webui/web_ui.h"
11 11
12 // static
13 OptionsManagedBannerHandler* OptionsManagedBannerHandler::Create(
14 WebUI* web_ui, const string16& page_name, OptionsPage page) {
15 return new OptionsManagedBannerHandler(web_ui, page_name, page);
16 }
17
12 OptionsManagedBannerHandler::OptionsManagedBannerHandler( 18 OptionsManagedBannerHandler::OptionsManagedBannerHandler(
13 WebUI* web_ui, const string16& page_name, OptionsPage page) 19 WebUI* web_ui, const string16& page_name, OptionsPage page)
14 : policy::ManagedPrefsBannerBase(web_ui->GetProfile()->GetPrefs(), page), 20 : policy::ManagedPrefsBannerBase(web_ui->GetProfile()->GetPrefs(), page),
15 web_ui_(web_ui), page_name_(page_name), page_(page) { 21 web_ui_(web_ui), page_name_(page_name), page_(page) {
16 // Initialize the visibility state of the banner. 22 // Initialize the visibility state of the banner.
17 SetupBannerVisibility(); 23 SetupBannerVisibility();
18 } 24 }
19 25
20 OptionsManagedBannerHandler::~OptionsManagedBannerHandler() {} 26 OptionsManagedBannerHandler::~OptionsManagedBannerHandler() {}
21 27
22 void OptionsManagedBannerHandler::OnUpdateVisibility() { 28 void OptionsManagedBannerHandler::OnUpdateVisibility() {
23 // A preference that may be managed has changed. Update our visibility 29 // A preference that may be managed has changed. Update our visibility
24 // state. 30 // state.
25 SetupBannerVisibility(); 31 SetupBannerVisibility();
26 } 32 }
27 33
28 void OptionsManagedBannerHandler::SetupBannerVisibility() { 34 void OptionsManagedBannerHandler::SetupBannerVisibility() {
29 // Construct the banner visibility script name. 35 // Construct the banner visibility script name.
30 std::string script = "options." + UTF16ToASCII(page_name_) + 36 std::string script = "options." + UTF16ToASCII(page_name_) +
31 ".getInstance().setManagedBannerVisibility"; 37 ".getInstance().setManagedBannerVisibility";
32 38
33 // Get the visiblity value from the base class. 39 // Get the visiblity value from the base class.
34 FundamentalValue visibility(DetermineVisibility()); 40 FundamentalValue visibility(DetermineVisibility());
35 41
36 // Set the managed state in the javascript handler. 42 // Set the managed state in the javascript handler.
37 web_ui_->CallJavascriptFunction(script, visibility); 43 web_ui_->CallJavascriptFunction(script, visibility);
38 } 44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698