| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/dom_ui/options_managed_banner_handler.h" |
| 6 |
| 7 #include "base/utf_string_conversions.h" |
| 8 #include "base/values.h" |
| 9 #include "chrome/browser/dom_ui/dom_ui.h" |
| 10 #include "chrome/browser/profile.h" |
| 11 |
| 12 OptionsManagedBannerHandler::OptionsManagedBannerHandler( |
| 13 DOMUI* dom_ui, const string16& page_name, OptionsPage page) |
| 14 : ManagedPrefsBannerBase(dom_ui->GetProfile()->GetPrefs(), page), |
| 15 dom_ui_(dom_ui), page_name_(page_name), page_(page) { |
| 16 // Initialize the visibility state of the banner. |
| 17 SetupBannerVisibilty(); |
| 18 } |
| 19 |
| 20 void OptionsManagedBannerHandler::OnUpdateVisibility() { |
| 21 // A preference that may be managed has changed. Update our visibility |
| 22 // state. |
| 23 SetupBannerVisibilty(); |
| 24 } |
| 25 |
| 26 void OptionsManagedBannerHandler::SetupBannerVisibilty() { |
| 27 // Construct the banner visibility script name. |
| 28 string16 script = ASCIIToUTF16("options.") + page_name_ + |
| 29 ASCIIToUTF16(".getInstance().setManagedBannerVisibility"); |
| 30 |
| 31 // Get the visiblity value from the base class. |
| 32 FundamentalValue visibility(DetermineVisibility()); |
| 33 |
| 34 // Set the managed state in the javascript handler. |
| 35 dom_ui_->CallJavascriptFunction(UTF16ToWideHack(script), visibility); |
| 36 } |
| 37 |
| OLD | NEW |