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

Side by Side Diff: chrome/browser/ui/webui/flags_ui.cc

Issue 6880341: Merge 83556 - Change about:flags page to not allow anyone but the owner modify it. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/742/src/
Patch Set: Created 9 years, 7 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
« no previous file with comments | « chrome/browser/resources/flags_warning.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/flags_ui.h" 5 #include "chrome/browser/ui/webui/flags_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/about_flags.h" 11 #include "chrome/browser/about_flags.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
17 #include "chrome/common/jstemplate_builder.h" 17 #include "chrome/common/jstemplate_builder.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
20 #include "content/browser/browser_thread.h" 20 #include "content/browser/browser_thread.h"
21 #include "content/browser/tab_contents/tab_contents.h" 21 #include "content/browser/tab_contents/tab_contents.h"
22 #include "grit/browser_resources.h" 22 #include "grit/browser_resources.h"
23 #include "grit/chromium_strings.h" 23 #include "grit/chromium_strings.h"
24 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
25 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 28
29 #if defined(OS_CHROMEOS)
30 #include "chrome/browser/chromeos/user_cros_settings_provider.h"
31 #include "chrome/browser/chromeos/login/user_manager.h"
32 #endif
33
29 namespace { 34 namespace {
30 35
31 /////////////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////////////
32 // 37 //
33 // FlagsUIHTMLSource 38 // FlagsUIHTMLSource
34 // 39 //
35 /////////////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////////////
36 41
37 class FlagsUIHTMLSource : public ChromeURLDataManager::DataSource { 42 class FlagsUIHTMLSource : public ChromeURLDataManager::DataSource {
38 public: 43 public:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 IDS_PRODUCT_NAME 83 IDS_PRODUCT_NAME
79 #endif 84 #endif
80 ))); 85 )));
81 localized_strings.SetString("flagsRestartButton", 86 localized_strings.SetString("flagsRestartButton",
82 l10n_util::GetStringUTF16(IDS_FLAGS_RELAUNCH_BUTTON)); 87 l10n_util::GetStringUTF16(IDS_FLAGS_RELAUNCH_BUTTON));
83 localized_strings.SetString("disable", 88 localized_strings.SetString("disable",
84 l10n_util::GetStringUTF16(IDS_FLAGS_DISABLE)); 89 l10n_util::GetStringUTF16(IDS_FLAGS_DISABLE));
85 localized_strings.SetString("enable", 90 localized_strings.SetString("enable",
86 l10n_util::GetStringUTF16(IDS_FLAGS_ENABLE)); 91 l10n_util::GetStringUTF16(IDS_FLAGS_ENABLE));
87 92
93 base::StringPiece html =
94 ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_FLAGS_HTML);
95 #if defined (OS_CHROMEOS)
96 if (!chromeos::UserManager::Get()->current_user_is_owner()) {
97 html = ResourceBundle::GetSharedInstance().GetRawDataResource(
98 IDR_FLAGS_HTML_WARNING);
99
100 // Set the strings to show which user can actually change the flags
101 localized_strings.SetString("ownerOnly", l10n_util::GetStringUTF16(
102 IDS_OPTIONS_ACCOUNTS_OWNER_ONLY));
103 localized_strings.SetString("ownerUserId", UTF8ToUTF16(
104 chromeos::UserCrosSettingsProvider::cached_owner()));
105 }
106 #endif
107 static const base::StringPiece flags_html(html);
88 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings); 108 ChromeURLDataManager::DataSource::SetFontAndTextDirection(&localized_strings);
89 109
90 static const base::StringPiece flags_html(
91 ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_FLAGS_HTML));
92 std::string full_html(flags_html.data(), flags_html.size()); 110 std::string full_html(flags_html.data(), flags_html.size());
93 jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html); 111 jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html);
94 jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html); 112 jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html);
95 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html); 113 jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html);
96 jstemplate_builder::AppendJsTemplateSourceHtml(&full_html); 114 jstemplate_builder::AppendJsTemplateSourceHtml(&full_html);
97 115
98 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); 116 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
99 html_bytes->data.resize(full_html.size()); 117 html_bytes->data.resize(full_html.size());
100 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin()); 118 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
101 119
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // static 219 // static
202 RefCountedMemory* FlagsUI::GetFaviconResourceBytes() { 220 RefCountedMemory* FlagsUI::GetFaviconResourceBytes() {
203 return ResourceBundle::GetSharedInstance(). 221 return ResourceBundle::GetSharedInstance().
204 LoadDataResourceBytes(IDR_FLAGS); 222 LoadDataResourceBytes(IDR_FLAGS);
205 } 223 }
206 224
207 // static 225 // static
208 void FlagsUI::RegisterPrefs(PrefService* prefs) { 226 void FlagsUI::RegisterPrefs(PrefService* prefs) {
209 prefs->RegisterListPref(prefs::kEnabledLabsExperiments); 227 prefs->RegisterListPref(prefs::kEnabledLabsExperiments);
210 } 228 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/flags_warning.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698