| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/flags_ui.h" | 5 #include "ios/chrome/browser/ui/webui/flags_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/bind_helpers.h" |
| 11 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 12 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
| 13 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "chrome/browser/about_flags.h" | |
| 17 #include "chrome/browser/browser_process.h" | |
| 18 #include "chrome/browser/lifetime/application_lifetime.h" | |
| 19 #include "chrome/browser/profiles/profile.h" | |
| 20 #include "chrome/common/channel_info.h" | |
| 21 #include "chrome/common/pref_names.h" | |
| 22 #include "chrome/common/url_constants.h" | |
| 23 #include "components/flags_ui/flags_ui_constants.h" | 17 #include "components/flags_ui/flags_ui_constants.h" |
| 24 #include "components/flags_ui/flags_ui_pref_names.h" | 18 #include "components/flags_ui/flags_ui_pref_names.h" |
| 25 #include "components/flags_ui/pref_service_flags_storage.h" | 19 #include "components/flags_ui/pref_service_flags_storage.h" |
| 26 #include "components/version_info/version_info.h" | 20 #include "components/version_info/version_info.h" |
| 27 #include "content/public/browser/web_contents.h" | |
| 28 #include "content/public/browser/web_ui.h" | |
| 29 #include "content/public/browser/web_ui_data_source.h" | |
| 30 #include "content/public/browser/web_ui_message_handler.h" | |
| 31 #include "grit/components_chromium_strings.h" | 21 #include "grit/components_chromium_strings.h" |
| 32 #include "grit/components_google_chrome_strings.h" | 22 #include "grit/components_google_chrome_strings.h" |
| 33 #include "grit/components_resources.h" | 23 #include "grit/components_resources.h" |
| 34 #include "grit/components_scaled_resources.h" | 24 #include "grit/components_scaled_resources.h" |
| 35 #include "grit/components_strings.h" | 25 #include "grit/components_strings.h" |
| 26 #include "ios/chrome/browser/about_flags.h" |
| 27 #include "ios/chrome/browser/application_context.h" |
| 28 #include "ios/chrome/browser/chrome_url_constants.h" |
| 29 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" |
| 30 #include "ios/public/provider/web/web_ui_ios.h" |
| 31 #include "ios/public/provider/web/web_ui_ios_message_handler.h" |
| 32 #include "ios/web/public/web_ui_ios_data_source.h" |
| 33 #include "ios/web/public/web_ui_ios_data_source.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 38 | 36 |
| 39 #if defined(OS_CHROMEOS) | |
| 40 #include "base/sys_info.h" | |
| 41 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | |
| 42 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | |
| 43 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 44 #include "chrome/browser/chromeos/settings/owner_flags_storage.h" | |
| 45 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 46 #include "chromeos/dbus/session_manager_client.h" | |
| 47 #include "components/pref_registry/pref_registry_syncable.h" | |
| 48 #include "components/user_manager/user_manager.h" | |
| 49 #endif | |
| 50 | |
| 51 using content::WebContents; | |
| 52 using content::WebUIMessageHandler; | |
| 53 | |
| 54 namespace { | 37 namespace { |
| 55 | 38 |
| 56 content::WebUIDataSource* CreateFlagsUIHTMLSource() { | 39 web::WebUIIOSDataSource* CreateFlagsUIHTMLSource( |
| 57 content::WebUIDataSource* source = | 40 BaseFlagsUI::FlagsUIKind flags_ui_kind) { |
| 58 content::WebUIDataSource::Create(chrome::kChromeUIFlagsHost); | 41 web::WebUIIOSDataSource* source = web::WebUIIOSDataSource::Create( |
| 42 flags_ui_kind == BaseFlagsUI::FLAGS_UI_APPLE ? kChromeUIAppleFlagsHost |
| 43 : kChromeUIFlagsHost); |
| 59 | 44 |
| 60 source->AddLocalizedString(flags_ui::kFlagsLongTitle, | 45 if (flags_ui_kind == BaseFlagsUI::FLAGS_UI_APPLE) { |
| 61 IDS_FLAGS_UI_LONG_TITLE); | 46 source->AddLocalizedString(flags_ui::kFlagsTableTitle, |
| 62 source->AddLocalizedString(flags_ui::kFlagsTableTitle, | 47 IDS_FLAGS_UI_ALTERNATIVES_UI_TABLE_TITLE); |
| 63 IDS_FLAGS_UI_TABLE_TITLE); | 48 source->AddLocalizedString( |
| 49 flags_ui::kFlagsNoExperimentsAvailable, |
| 50 IDS_FLAGS_UI_ALTERNATIVES_UI_NO_EXPERIMENTS_AVAILABLE); |
| 51 } else { |
| 52 source->AddLocalizedString(flags_ui::kFlagsLongTitle, |
| 53 IDS_FLAGS_UI_LONG_TITLE); |
| 54 source->AddLocalizedString(flags_ui::kFlagsTableTitle, |
| 55 IDS_FLAGS_UI_TABLE_TITLE); |
| 56 } |
| 64 source->AddLocalizedString(flags_ui::kFlagsWarningHeader, | 57 source->AddLocalizedString(flags_ui::kFlagsWarningHeader, |
| 65 IDS_FLAGS_UI_WARNING_HEADER); | 58 IDS_FLAGS_UI_WARNING_HEADER); |
| 66 source->AddLocalizedString(flags_ui::kFlagsBlurb, IDS_FLAGS_UI_WARNING_TEXT); | 59 source->AddLocalizedString(flags_ui::kFlagsBlurb, IDS_FLAGS_UI_WARNING_TEXT); |
| 67 source->AddLocalizedString(flags_ui::kChannelPromoBeta, | |
| 68 IDS_FLAGS_UI_PROMOTE_BETA_CHANNEL); | |
| 69 source->AddLocalizedString(flags_ui::kChannelPromoDev, | |
| 70 IDS_FLAGS_UI_PROMOTE_DEV_CHANNEL); | |
| 71 source->AddLocalizedString(flags_ui::kFlagsUnsupportedTableTitle, | 60 source->AddLocalizedString(flags_ui::kFlagsUnsupportedTableTitle, |
| 72 IDS_FLAGS_UI_UNSUPPORTED_TABLE_TITLE); | 61 IDS_FLAGS_UI_UNSUPPORTED_TABLE_TITLE); |
| 73 source->AddLocalizedString(flags_ui::kFlagsNotSupported, | 62 source->AddLocalizedString(flags_ui::kFlagsNotSupported, |
| 74 IDS_FLAGS_UI_NOT_AVAILABLE); | 63 IDS_FLAGS_UI_NOT_AVAILABLE); |
| 75 source->AddLocalizedString(flags_ui::kFlagsRestartNotice, | 64 source->AddLocalizedString(flags_ui::kFlagsRestartNotice, |
| 76 IDS_FLAGS_UI_RELAUNCH_NOTICE); | 65 IDS_FLAGS_UI_RELAUNCH_NOTICE); |
| 77 source->AddLocalizedString(flags_ui::kFlagsRestartButton, | 66 source->AddLocalizedString(flags_ui::kFlagsRestartButton, |
| 78 IDS_FLAGS_UI_RELAUNCH_BUTTON); | 67 IDS_FLAGS_UI_RELAUNCH_BUTTON); |
| 79 source->AddLocalizedString(flags_ui::kResetAllButton, | 68 source->AddLocalizedString(flags_ui::kResetAllButton, |
| 80 IDS_FLAGS_UI_RESET_ALL_BUTTON); | 69 IDS_FLAGS_UI_RESET_ALL_BUTTON); |
| 81 source->AddLocalizedString(flags_ui::kDisable, IDS_FLAGS_UI_DISABLE); | 70 source->AddLocalizedString(flags_ui::kDisable, IDS_FLAGS_UI_DISABLE); |
| 82 source->AddLocalizedString(flags_ui::kEnable, IDS_FLAGS_UI_ENABLE); | 71 source->AddLocalizedString(flags_ui::kEnable, IDS_FLAGS_UI_ENABLE); |
| 83 | 72 |
| 84 #if defined(OS_CHROMEOS) | |
| 85 if (!user_manager::UserManager::Get()->IsCurrentUserOwner() && | |
| 86 base::SysInfo::IsRunningOnChromeOS()) { | |
| 87 // Set the strings to show which user can actually change the flags. | |
| 88 std::string owner; | |
| 89 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | |
| 90 source->AddString(flags_ui::kOwnerWarning, | |
| 91 l10n_util::GetStringFUTF16(IDS_FLAGS_UI_SYSTEM_OWNER_ONLY, | |
| 92 base::UTF8ToUTF16(owner))); | |
| 93 } else { | |
| 94 // The warning will be only shown on ChromeOS, when the current user is not | |
| 95 // the owner. | |
| 96 source->AddString(flags_ui::kOwnerWarning, base::string16()); | |
| 97 } | |
| 98 #endif | |
| 99 | |
| 100 source->SetJsonPath("strings.js"); | 73 source->SetJsonPath("strings.js"); |
| 101 source->AddResourcePath(flags_ui::kFlagsJS, IDR_FLAGS_UI_FLAGS_JS); | 74 source->AddResourcePath(flags_ui::kFlagsJS, IDR_FLAGS_UI_FLAGS_JS); |
| 102 source->SetDefaultResource(IDR_FLAGS_UI_FLAGS_HTML); | 75 source->SetDefaultResource(flags_ui_kind == BaseFlagsUI::FLAGS_UI_APPLE |
| 76 ? IDR_APPLE_FLAGS_HTML |
| 77 : IDR_FLAGS_UI_FLAGS_HTML); |
| 103 return source; | 78 return source; |
| 104 } | 79 } |
| 105 | 80 |
| 106 //////////////////////////////////////////////////////////////////////////////// | 81 //////////////////////////////////////////////////////////////////////////////// |
| 107 // | 82 // |
| 108 // FlagsDOMHandler | 83 // FlagsDOMHandler |
| 109 // | 84 // |
| 110 //////////////////////////////////////////////////////////////////////////////// | 85 //////////////////////////////////////////////////////////////////////////////// |
| 111 | 86 |
| 112 // The handler for Javascript messages for the about:flags page. | 87 // The handler for Javascript messages for the about:flags page. |
| 113 class FlagsDOMHandler : public WebUIMessageHandler { | 88 class FlagsDOMHandler : public web::WebUIIOSMessageHandler { |
| 114 public: | 89 public: |
| 115 FlagsDOMHandler() : access_(flags_ui::kGeneralAccessFlagsOnly), | 90 FlagsDOMHandler() |
| 116 experimental_features_requested_(false) { | 91 : access_(flags_ui::kGeneralAccessFlagsOnly), |
| 117 } | 92 experimental_features_requested_(false) {} |
| 118 ~FlagsDOMHandler() override {} | 93 ~FlagsDOMHandler() override {} |
| 119 | 94 |
| 120 // Initializes the DOM handler with the provided flags storage and flags | 95 // Initializes the DOM handler with the provided flags storage and flags |
| 121 // access. If there were flags experiments requested from javascript before | 96 // access. If there were flags experiments requested from javascript before |
| 122 // this was called, it calls |HandleRequestExperimentalFeatures| again. | 97 // this was called, it calls |HandleRequestExperimentalFeatures| again. |
| 123 void Init(flags_ui::FlagsStorage* flags_storage, | 98 void Init(flags_ui::FlagsStorage* flags_storage, flags_ui::FlagAccess access); |
| 124 flags_ui::FlagAccess access); | |
| 125 | 99 |
| 126 // WebUIMessageHandler implementation. | 100 // WebUIMessageHandler implementation. |
| 127 void RegisterMessages() override; | 101 void RegisterMessages() override; |
| 128 | 102 |
| 129 // Callback for the "requestExperimentFeatures" message. | 103 // Callback for the "requestExperimentFeatures" message. |
| 130 void HandleRequestExperimentalFeatures(const base::ListValue* args); | 104 void HandleRequestExperimentalFeatures(const base::ListValue* args); |
| 131 | 105 |
| 132 // Callback for the "enableExperimentalFeature" message. | 106 // Callback for the "enableExperimentalFeature" message. |
| 133 void HandleEnableExperimentalFeatureMessage(const base::ListValue* args); | 107 void HandleEnableExperimentalFeatureMessage(const base::ListValue* args); |
| 134 | 108 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 experimental_features_requested_ = true; | 153 experimental_features_requested_ = true; |
| 180 // Bail out if the handler hasn't been initialized yet. The request will be | 154 // Bail out if the handler hasn't been initialized yet. The request will be |
| 181 // handled after the initialization. | 155 // handled after the initialization. |
| 182 if (!flags_storage_) | 156 if (!flags_storage_) |
| 183 return; | 157 return; |
| 184 | 158 |
| 185 base::DictionaryValue results; | 159 base::DictionaryValue results; |
| 186 | 160 |
| 187 scoped_ptr<base::ListValue> supported_features(new base::ListValue); | 161 scoped_ptr<base::ListValue> supported_features(new base::ListValue); |
| 188 scoped_ptr<base::ListValue> unsupported_features(new base::ListValue); | 162 scoped_ptr<base::ListValue> unsupported_features(new base::ListValue); |
| 189 about_flags::GetFlagFeatureEntries(flags_storage_.get(), | 163 GetFlagFeatureEntries(flags_storage_.get(), access_, supported_features.get(), |
| 190 access_, | 164 unsupported_features.get()); |
| 191 supported_features.get(), | |
| 192 unsupported_features.get()); | |
| 193 results.Set(flags_ui::kSupportedFeatures, supported_features.release()); | 165 results.Set(flags_ui::kSupportedFeatures, supported_features.release()); |
| 194 results.Set(flags_ui::kUnsupportedFeatures, unsupported_features.release()); | 166 results.Set(flags_ui::kUnsupportedFeatures, unsupported_features.release()); |
| 195 results.SetBoolean(flags_ui::kNeedsRestart, | 167 // Cannot restart the browser on iOS. |
| 196 about_flags::IsRestartNeededToCommitChanges()); | 168 results.SetBoolean(flags_ui::kNeedsRestart, false); |
| 197 results.SetBoolean(flags_ui::kShowOwnerWarning, | 169 results.SetBoolean(flags_ui::kShowOwnerWarning, |
| 198 access_ == flags_ui::kGeneralAccessFlagsOnly); | 170 access_ == flags_ui::kGeneralAccessFlagsOnly); |
| 199 | 171 |
| 200 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) | |
| 201 version_info::Channel channel = chrome::GetChannel(); | |
| 202 results.SetBoolean(flags_ui::kShowBetaChannelPromotion, | |
| 203 channel == version_info::Channel::STABLE); | |
| 204 results.SetBoolean(flags_ui::kShowDevChannelPromotion, | |
| 205 channel == version_info::Channel::BETA); | |
| 206 #else | |
| 207 results.SetBoolean(flags_ui::kShowBetaChannelPromotion, false); | 172 results.SetBoolean(flags_ui::kShowBetaChannelPromotion, false); |
| 208 results.SetBoolean(flags_ui::kShowDevChannelPromotion, false); | 173 results.SetBoolean(flags_ui::kShowDevChannelPromotion, false); |
| 209 #endif | |
| 210 web_ui()->CallJavascriptFunction(flags_ui::kReturnExperimentalFeatures, | 174 web_ui()->CallJavascriptFunction(flags_ui::kReturnExperimentalFeatures, |
| 211 results); | 175 results); |
| 212 } | 176 } |
| 213 | 177 |
| 214 void FlagsDOMHandler::HandleEnableExperimentalFeatureMessage( | 178 void FlagsDOMHandler::HandleEnableExperimentalFeatureMessage( |
| 215 const base::ListValue* args) { | 179 const base::ListValue* args) { |
| 216 DCHECK(flags_storage_); | 180 DCHECK(flags_storage_); |
| 217 DCHECK_EQ(2u, args->GetSize()); | 181 DCHECK_EQ(2u, args->GetSize()); |
| 218 if (args->GetSize() != 2) | 182 if (args->GetSize() != 2) |
| 219 return; | 183 return; |
| 220 | 184 |
| 221 std::string entry_internal_name; | 185 std::string entry_internal_name; |
| 222 std::string enable_str; | 186 std::string enable_str; |
| 223 if (!args->GetString(0, &entry_internal_name) || | 187 if (!args->GetString(0, &entry_internal_name) || |
| 224 !args->GetString(1, &enable_str)) | 188 !args->GetString(1, &enable_str)) |
| 225 return; | 189 return; |
| 226 | 190 |
| 227 about_flags::SetFeatureEntryEnabled(flags_storage_.get(), entry_internal_name, | 191 SetFeatureEntryEnabled(flags_storage_.get(), entry_internal_name, |
| 228 enable_str == "true"); | 192 enable_str == "true"); |
| 229 } | 193 } |
| 230 | 194 |
| 231 void FlagsDOMHandler::HandleRestartBrowser(const base::ListValue* args) { | 195 void FlagsDOMHandler::HandleRestartBrowser(const base::ListValue* args) { |
| 232 DCHECK(flags_storage_); | 196 NOTREACHED(); |
| 233 #if defined(OS_CHROMEOS) | |
| 234 // On ChromeOS be less intrusive and restart inside the user session after | |
| 235 // we apply the newly selected flags. | |
| 236 base::CommandLine user_flags(base::CommandLine::NO_PROGRAM); | |
| 237 about_flags::ConvertFlagsToSwitches(flags_storage_.get(), | |
| 238 &user_flags, | |
| 239 flags_ui::kAddSentinels); | |
| 240 base::CommandLine::StringVector flags; | |
| 241 // argv[0] is the program name |base::CommandLine::NO_PROGRAM|. | |
| 242 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); | |
| 243 VLOG(1) << "Restarting to apply per-session flags..."; | |
| 244 chromeos::DBusThreadManager::Get() | |
| 245 ->GetSessionManagerClient() | |
| 246 ->SetFlagsForUser( | |
| 247 user_manager::UserManager::Get()->GetActiveUser()->email(), flags); | |
| 248 #endif | |
| 249 chrome::AttemptRestart(); | |
| 250 } | 197 } |
| 251 | 198 |
| 252 void FlagsDOMHandler::HandleResetAllFlags(const base::ListValue* args) { | 199 void FlagsDOMHandler::HandleResetAllFlags(const base::ListValue* args) { |
| 253 DCHECK(flags_storage_); | 200 DCHECK(flags_storage_); |
| 254 about_flags::ResetAllFlags(flags_storage_.get()); | 201 ResetAllFlags(flags_storage_.get()); |
| 255 } | 202 } |
| 256 | 203 |
| 204 } // namespace |
| 257 | 205 |
| 258 #if defined(OS_CHROMEOS) | 206 /////////////////////////////////////////////////////////////////////////////// |
| 259 // On ChromeOS verifying if the owner is signed in is async operation and only | 207 // |
| 260 // after finishing it the UI can be properly populated. This function is the | 208 // BaseFlagsUI |
| 261 // callback for whether the owner is signed in. It will respectively pick the | 209 // |
| 262 // proper PrefService for the flags interface. | 210 /////////////////////////////////////////////////////////////////////////////// |
| 263 void FinishInitialization(base::WeakPtr<FlagsUI> flags_ui, | |
| 264 Profile* profile, | |
| 265 FlagsDOMHandler* dom_handler, | |
| 266 bool current_user_is_owner) { | |
| 267 // If the flags_ui has gone away, there's nothing to do. | |
| 268 if (!flags_ui) | |
| 269 return; | |
| 270 | 211 |
| 271 // On Chrome OS the owner can set system wide flags and other users can only | 212 BaseFlagsUI::BaseFlagsUI(web::WebUIIOS* web_ui, FlagsUIKind flags_ui_kind) |
| 272 // set flags for their own session. | 213 : web::WebUIIOSController(web_ui), weak_factory_(this) { |
| 273 // Note that |dom_handler| is owned by the web ui that owns |flags_ui|, so | 214 Initialize(web_ui, flags_ui_kind); |
| 274 // it is still alive if |flags_ui| is. | |
| 275 if (current_user_is_owner) { | |
| 276 chromeos::OwnerSettingsServiceChromeOS* service = | |
| 277 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( | |
| 278 profile); | |
| 279 dom_handler->Init(new chromeos::about_flags::OwnerFlagsStorage( | |
| 280 profile->GetPrefs(), service), | |
| 281 flags_ui::kOwnerAccessToFlags); | |
| 282 } else { | |
| 283 dom_handler->Init( | |
| 284 new flags_ui::PrefServiceFlagsStorage(profile->GetPrefs()), | |
| 285 flags_ui::kGeneralAccessFlagsOnly); | |
| 286 } | |
| 287 } | 215 } |
| 288 #endif | |
| 289 | 216 |
| 290 } // namespace | 217 void BaseFlagsUI::Initialize(web::WebUIIOS* web_ui, FlagsUIKind flags_ui_kind) { |
| 218 FlagsDOMHandler* handler = new FlagsDOMHandler(); |
| 219 web_ui->AddMessageHandler(handler); |
| 220 |
| 221 flags_ui::FlagAccess flag_access = flags_ui::kOwnerAccessToFlags; |
| 222 if (flags_ui_kind == FLAGS_UI_APPLE) |
| 223 flag_access = flags_ui::kAppleReviewAccessToFlags; |
| 224 handler->Init(new flags_ui::PrefServiceFlagsStorage( |
| 225 GetApplicationContext()->GetLocalState()), |
| 226 flag_access); |
| 227 |
| 228 // Set up the about:flags source. |
| 229 web::WebUIIOSDataSource::Add(ios::ChromeBrowserState::FromWebUIIOS(web_ui), |
| 230 CreateFlagsUIHTMLSource(flags_ui_kind)); |
| 231 } |
| 232 |
| 233 BaseFlagsUI::~BaseFlagsUI() {} |
| 234 |
| 235 // static |
| 236 base::RefCountedMemory* BaseFlagsUI::GetFaviconResourceBytes( |
| 237 ui::ScaleFactor scale_factor) { |
| 238 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
| 239 IDR_FLAGS_FAVICON, scale_factor); |
| 240 } |
| 291 | 241 |
| 292 /////////////////////////////////////////////////////////////////////////////// | 242 /////////////////////////////////////////////////////////////////////////////// |
| 293 // | 243 // |
| 294 // FlagsUI | 244 // FlagsUI |
| 295 // | 245 // |
| 296 /////////////////////////////////////////////////////////////////////////////// | 246 /////////////////////////////////////////////////////////////////////////////// |
| 297 | 247 |
| 298 FlagsUI::FlagsUI(content::WebUI* web_ui) | 248 FlagsUI::FlagsUI(web::WebUIIOS* web_ui) |
| 299 : WebUIController(web_ui), | 249 : BaseFlagsUI(web_ui, BaseFlagsUI::FLAGS_UI_GENERIC) {} |
| 300 weak_factory_(this) { | |
| 301 Profile* profile = Profile::FromWebUI(web_ui); | |
| 302 | 250 |
| 303 FlagsDOMHandler* handler = new FlagsDOMHandler(); | 251 FlagsUI::~FlagsUI() {} |
| 304 web_ui->AddMessageHandler(handler); | |
| 305 | 252 |
| 306 #if defined(OS_CHROMEOS) | 253 /////////////////////////////////////////////////////////////////////////////// |
| 307 if (base::SysInfo::IsRunningOnChromeOS() && | 254 // |
| 308 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( | 255 // AppleFlagsUI |
| 309 profile)) { | 256 // |
| 310 chromeos::OwnerSettingsServiceChromeOS* service = | 257 /////////////////////////////////////////////////////////////////////////////// |
| 311 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext( | |
| 312 profile); | |
| 313 service->IsOwnerAsync(base::Bind( | |
| 314 &FinishInitialization, weak_factory_.GetWeakPtr(), profile, handler)); | |
| 315 } else { | |
| 316 FinishInitialization(weak_factory_.GetWeakPtr(), profile, handler, | |
| 317 false /* current_user_is_owner */); | |
| 318 } | |
| 319 #else | |
| 320 handler->Init( | |
| 321 new flags_ui::PrefServiceFlagsStorage(g_browser_process->local_state()), | |
| 322 flags_ui::kOwnerAccessToFlags); | |
| 323 #endif | |
| 324 | 258 |
| 325 // Set up the about:flags source. | 259 AppleFlagsUI::AppleFlagsUI(web::WebUIIOS* web_ui) |
| 326 content::WebUIDataSource::Add(profile, CreateFlagsUIHTMLSource()); | 260 : BaseFlagsUI(web_ui, BaseFlagsUI::FLAGS_UI_APPLE) {} |
| 327 } | |
| 328 | 261 |
| 329 FlagsUI::~FlagsUI() { | 262 AppleFlagsUI::~AppleFlagsUI() {} |
| 330 } | |
| 331 | |
| 332 // static | |
| 333 base::RefCountedMemory* FlagsUI::GetFaviconResourceBytes( | |
| 334 ui::ScaleFactor scale_factor) { | |
| 335 return ResourceBundle::GetSharedInstance(). | |
| 336 LoadDataResourceBytesForScale(IDR_FLAGS_FAVICON, scale_factor); | |
| 337 } | |
| OLD | NEW |