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

Side by Side Diff: chrome/browser/themes/theme_service.cc

Issue 9477018: retry r123804 - ntp theme fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/themes/theme_service.h" 5 #include "chrome/browser/themes/theme_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_split.h" 8 #include "base/string_split.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 11 matching lines...) Expand all
22 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
23 23
24 #if defined(OS_WIN) && !defined(USE_AURA) 24 #if defined(OS_WIN) && !defined(USE_AURA)
25 #include "ui/views/widget/native_widget_win.h" 25 #include "ui/views/widget/native_widget_win.h"
26 #endif 26 #endif
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 using content::UserMetricsAction; 29 using content::UserMetricsAction;
30 30
31 // Strings used in alignment properties. 31 // Strings used in alignment properties.
32 const char* ThemeService::kAlignmentCenter = "center";
32 const char* ThemeService::kAlignmentTop = "top"; 33 const char* ThemeService::kAlignmentTop = "top";
33 const char* ThemeService::kAlignmentBottom = "bottom"; 34 const char* ThemeService::kAlignmentBottom = "bottom";
34 const char* ThemeService::kAlignmentLeft = "left"; 35 const char* ThemeService::kAlignmentLeft = "left";
35 const char* ThemeService::kAlignmentRight = "right"; 36 const char* ThemeService::kAlignmentRight = "right";
36 37
37 // Strings used in background tiling repetition properties. 38 // Strings used in background tiling repetition properties.
38 const char* ThemeService::kTilingNoRepeat = "no-repeat"; 39 const char* ThemeService::kTilingNoRepeat = "no-repeat";
39 const char* ThemeService::kTilingRepeatX = "repeat-x"; 40 const char* ThemeService::kTilingRepeatX = "repeat-x";
40 const char* ThemeService::kTilingRepeatY = "repeat-y"; 41 const char* ThemeService::kTilingRepeatY = "repeat-y";
41 const char* ThemeService::kTilingRepeat = "repeat"; 42 const char* ThemeService::kTilingRepeat = "repeat";
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return UsingDefaultTheme(); 371 return UsingDefaultTheme();
371 } 372 }
372 373
373 std::string ThemeService::GetThemeID() const { 374 std::string ThemeService::GetThemeID() const {
374 return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID); 375 return profile_->GetPrefs()->GetString(prefs::kCurrentThemeID);
375 } 376 }
376 377
377 // static 378 // static
378 std::string ThemeService::AlignmentToString(int alignment) { 379 std::string ThemeService::AlignmentToString(int alignment) {
379 // Convert from an AlignmentProperty back into a string. 380 // Convert from an AlignmentProperty back into a string.
380 std::string vertical_string; 381 std::string vertical_string(kAlignmentCenter);
381 std::string horizontal_string; 382 std::string horizontal_string(kAlignmentCenter);
382 383
383 if (alignment & ThemeService::ALIGN_TOP) 384 if (alignment & ThemeService::ALIGN_TOP)
384 vertical_string = kAlignmentTop; 385 vertical_string = kAlignmentTop;
385 else if (alignment & ThemeService::ALIGN_BOTTOM) 386 else if (alignment & ThemeService::ALIGN_BOTTOM)
386 vertical_string = kAlignmentBottom; 387 vertical_string = kAlignmentBottom;
387 388
388 if (alignment & ThemeService::ALIGN_LEFT) 389 if (alignment & ThemeService::ALIGN_LEFT)
389 horizontal_string = kAlignmentLeft; 390 horizontal_string = kAlignmentLeft;
390 else if (alignment & ThemeService::ALIGN_RIGHT) 391 else if (alignment & ThemeService::ALIGN_RIGHT)
391 horizontal_string = kAlignmentRight; 392 horizontal_string = kAlignmentRight;
392 393
393 if (vertical_string.empty()) 394 return horizontal_string + " " + vertical_string;
394 return horizontal_string;
395 if (horizontal_string.empty())
396 return vertical_string;
397 return vertical_string + " " + horizontal_string;
398 } 395 }
399 396
400 // static 397 // static
401 int ThemeService::StringToAlignment(const std::string& alignment) { 398 int ThemeService::StringToAlignment(const std::string& alignment) {
402 std::vector<std::string> split; 399 std::vector<std::string> split;
403 base::SplitStringAlongWhitespace(alignment, &split); 400 base::SplitStringAlongWhitespace(alignment, &split);
404 401
405 int alignment_mask = 0; 402 int alignment_mask = 0;
406 for (std::vector<std::string>::iterator component(split.begin()); 403 for (std::vector<std::string>::iterator component(split.begin());
407 component != split.end(); ++component) { 404 component != split.end(); ++component) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 void ThemeService::OnInfobarDisplayed() { 669 void ThemeService::OnInfobarDisplayed() {
673 number_of_infobars_++; 670 number_of_infobars_++;
674 } 671 }
675 672
676 void ThemeService::OnInfobarDestroyed() { 673 void ThemeService::OnInfobarDestroyed() {
677 number_of_infobars_--; 674 number_of_infobars_--;
678 675
679 if (number_of_infobars_ == 0) 676 if (number_of_infobars_ == 0)
680 RemoveUnusedThemes(); 677 RemoveUnusedThemes();
681 } 678 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698