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

Side by Side Diff: chrome/browser/views/options/advanced_contents_view.cc

Issue 3200007: Added prefs ui for enabling/disabling background mode on windows. (Closed)
Patch Set: Updated per review feedback Created 10 years, 4 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
« no previous file with comments | « chrome/browser/options_util.cc ('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) 2010 The Chromium Authors. All rights reserved. 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 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/views/options/advanced_contents_view.h" 5 #include "chrome/browser/views/options/advanced_contents_view.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <cryptuiapi.h> 9 #include <cryptuiapi.h>
10 #pragma comment(lib, "cryptui.lib") 10 #pragma comment(lib, "cryptui.lib")
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 // Init member pref so we can update the controls if prefs change. 1269 // Init member pref so we can update the controls if prefs change.
1270 enable_translate_.Init(prefs::kEnableTranslate, profile()->GetPrefs(), this); 1270 enable_translate_.Init(prefs::kEnableTranslate, profile()->GetPrefs(), this);
1271 } 1271 }
1272 1272
1273 void TranslateSection::NotifyPrefChanged(const std::string* pref_name) { 1273 void TranslateSection::NotifyPrefChanged(const std::string* pref_name) {
1274 if (!pref_name || *pref_name == prefs::kEnableTranslate) 1274 if (!pref_name || *pref_name == prefs::kEnableTranslate)
1275 enable_translate_checkbox_->SetChecked(enable_translate_.GetValue()); 1275 enable_translate_checkbox_->SetChecked(enable_translate_.GetValue());
1276 } 1276 }
1277 1277
1278 //////////////////////////////////////////////////////////////////////////////// 1278 ////////////////////////////////////////////////////////////////////////////////
1279 // ChromeAppsSection
1280
1281 class ChromeAppsSection : public AdvancedSection,
1282 public views::ButtonListener,
1283 public views::LinkController {
1284 public:
1285 explicit ChromeAppsSection(Profile* profile);
1286 virtual ~ChromeAppsSection() {}
1287
1288 // Overridden from views::ButtonListener:
1289 virtual void ButtonPressed(views::Button* sender, const views::Event& event);
1290 // Overridden from views::LinkController:
1291 virtual void LinkActivated(views::Link* source, int event_flags);
1292
1293 protected:
1294 // OptionsPageView overrides:
1295 virtual void InitControlLayout();
1296 virtual void NotifyPrefChanged(const std::string* pref_name);
1297
1298 private:
1299 // Controls for this section:
1300 views::Checkbox* enable_background_mode_checkbox_;
1301 views::Link* learn_more_link_;
1302
1303 // Preferences for this section:
1304 BooleanPrefMember enable_background_mode_;
1305
1306 DISALLOW_COPY_AND_ASSIGN(ChromeAppsSection);
1307 };
1308
1309 ChromeAppsSection::ChromeAppsSection(Profile* profile)
1310 : enable_background_mode_checkbox_(NULL),
1311 learn_more_link_(NULL),
1312 AdvancedSection(profile, l10n_util::GetString(
1313 IDS_OPTIONS_ADVANCED_SECTION_TITLE_CHROME_APPS)) {
1314 }
1315
1316 void ChromeAppsSection::ButtonPressed(
1317 views::Button* sender, const views::Event& event) {
1318 DCHECK(sender == enable_background_mode_checkbox_);
1319 bool enabled = enable_background_mode_checkbox_->checked();
1320 UserMetricsRecordAction(enabled ?
1321 UserMetricsAction("Options_BackgroundMode_Enable") :
1322 UserMetricsAction("Options_BackgroundMode_Disable"),
1323 profile()->GetPrefs());
1324 enable_background_mode_.SetValue(enabled);
1325 }
1326
1327 void ChromeAppsSection::LinkActivated(views::Link* source, int event_flags) {
1328 DCHECK(source == learn_more_link_);
1329 Browser::Create(profile())->OpenURL(
1330 GURL(l10n_util::GetString(IDS_LEARN_MORE_BACKGROUND_MODE_URL)), GURL(),
1331 NEW_WINDOW, PageTransition::LINK);
1332 }
1333
1334 void ChromeAppsSection::InitControlLayout() {
1335 AdvancedSection::InitControlLayout();
1336
1337 GridLayout* layout = new GridLayout(contents_);
1338 contents_->SetLayoutManager(layout);
1339
1340 AddIndentedColumnSet(layout, 0);
1341
1342 enable_background_mode_checkbox_ = new views::Checkbox(
1343 l10n_util::GetString(IDS_OPTIONS_CHROME_APPS_ENABLE_BACKGROUND_MODE));
1344 enable_background_mode_checkbox_->set_listener(this);
1345 AddWrappingCheckboxRow(layout, enable_background_mode_checkbox_, 0, true);
1346
1347 // Init member pref so we can update the controls if prefs change.
1348 enable_background_mode_.Init(prefs::kBackgroundModeEnabled,
1349 profile()->GetPrefs(), this);
1350
1351 // Add our link to the help center page for this feature.
1352 learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
1353 learn_more_link_->SetController(this);
1354 AddLeadingControl(layout, learn_more_link_, 0, false);
1355 }
1356
1357 void ChromeAppsSection::NotifyPrefChanged(const std::string* pref_name) {
1358 if (!pref_name || *pref_name == prefs::kBackgroundModeEnabled) {
1359 enable_background_mode_checkbox_->SetChecked(
1360 enable_background_mode_.GetValue());
1361 }
1362 }
1363
1364 ////////////////////////////////////////////////////////////////////////////////
1279 // AdvancedContentsView 1365 // AdvancedContentsView
1280 1366
1281 class AdvancedContentsView : public OptionsPageView { 1367 class AdvancedContentsView : public OptionsPageView {
1282 public: 1368 public:
1283 explicit AdvancedContentsView(Profile* profile); 1369 explicit AdvancedContentsView(Profile* profile);
1284 virtual ~AdvancedContentsView(); 1370 virtual ~AdvancedContentsView();
1285 1371
1286 // views::View overrides: 1372 // views::View overrides:
1287 virtual int GetLineScrollIncrement(views::ScrollView* scroll_view, 1373 virtual int GetLineScrollIncrement(views::ScrollView* scroll_view,
1288 bool is_horizontal, bool is_positive); 1374 bool is_horizontal, bool is_positive);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 layout->StartRow(0, single_column_view_set_id); 1451 layout->StartRow(0, single_column_view_set_id);
1366 layout->AddView(new NetworkSection(profile())); 1452 layout->AddView(new NetworkSection(profile()));
1367 layout->StartRow(0, single_column_view_set_id); 1453 layout->StartRow(0, single_column_view_set_id);
1368 layout->AddView(new TranslateSection(profile())); 1454 layout->AddView(new TranslateSection(profile()));
1369 layout->StartRow(0, single_column_view_set_id); 1455 layout->StartRow(0, single_column_view_set_id);
1370 layout->AddView(new DownloadSection(profile())); 1456 layout->AddView(new DownloadSection(profile()));
1371 layout->StartRow(0, single_column_view_set_id); 1457 layout->StartRow(0, single_column_view_set_id);
1372 layout->AddView(new WebContentSection(profile())); 1458 layout->AddView(new WebContentSection(profile()));
1373 layout->StartRow(0, single_column_view_set_id); 1459 layout->StartRow(0, single_column_view_set_id);
1374 layout->AddView(new SecuritySection(profile())); 1460 layout->AddView(new SecuritySection(profile()));
1461 layout->StartRow(0, single_column_view_set_id);
1462 layout->AddView(new ChromeAppsSection(profile()));
1375 } 1463 }
1376 1464
1377 //////////////////////////////////////////////////////////////////////////////// 1465 ////////////////////////////////////////////////////////////////////////////////
1378 // AdvancedContentsView, private: 1466 // AdvancedContentsView, private:
1379 1467
1380 void AdvancedContentsView::InitClass() { 1468 void AdvancedContentsView::InitClass() {
1381 static bool initialized = false; 1469 static bool initialized = false;
1382 if (!initialized) { 1470 if (!initialized) {
1383 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1471 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1384 line_height_ = rb.GetFont(ResourceBundle::BaseFont).GetHeight(); 1472 line_height_ = rb.GetFont(ResourceBundle::BaseFont).GetHeight();
(...skipping 19 matching lines...) Expand all
1404 // AdvancedScrollViewContainer, views::View overrides: 1492 // AdvancedScrollViewContainer, views::View overrides:
1405 1493
1406 void AdvancedScrollViewContainer::Layout() { 1494 void AdvancedScrollViewContainer::Layout() {
1407 gfx::Rect lb = GetLocalBounds(false); 1495 gfx::Rect lb = GetLocalBounds(false);
1408 1496
1409 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize( 1497 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize(
1410 gfx::NativeTheme::LIST); 1498 gfx::NativeTheme::LIST);
1411 lb.Inset(border.width(), border.height()); 1499 lb.Inset(border.width(), border.height());
1412 scroll_view_->SetBounds(lb); 1500 scroll_view_->SetBounds(lb);
1413 } 1501 }
OLDNEW
« no previous file with comments | « chrome/browser/options_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698