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 #ifndef CHROME_BROWSER_SYNC_GLUE_THEME_UTIL_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_THEME_UTIL_H_ 7 #pragma once 8 9 class Extension; 10 class Profile; 11 12 namespace sync_pb { 13 class ThemeSpecifics; 14 } // sync_pb 15 16 namespace browser_sync { 17 18 extern const char kCurrentThemeClientTag[]; 19 20 // Returns true iff two ThemeSpecifics indicate the same theme. 21 bool AreThemeSpecificsEqual(const sync_pb::ThemeSpecifics& a, 22 const sync_pb::ThemeSpecifics& b); 23 24 // Exposed only for testing. 25 bool AreThemeSpecificsEqualHelper( 26 const sync_pb::ThemeSpecifics& a, 27 const sync_pb::ThemeSpecifics& b, 28 bool is_system_theme_distinct_from_default_theme); 29 30 // Sets the current theme from the information in the given 31 // ThemeSpecifics. 32 void SetCurrentThemeFromThemeSpecifics( 33 const sync_pb::ThemeSpecifics& theme_specifics, 34 Profile* profile); 35 36 // Sets all fields of the given ThemeSpecifics according to the 37 // current theme. 38 void GetThemeSpecificsFromCurrentTheme( 39 Profile* profile, 40 sync_pb::ThemeSpecifics* theme_specifics); 41 42 // Exposed only for testing. 43 void GetThemeSpecificsFromCurrentThemeHelper( 44 const Extension* current_theme, 45 bool is_system_theme_distinct_from_default_theme, 46 bool use_system_theme_by_default, 47 sync_pb::ThemeSpecifics* theme_specifics); 48 49 // Like SetChrrentThemeFromThemeSpecifics() except does nothing if the 50 // current theme is equivalent to that described by theme_specifics. 51 void SetCurrentThemeFromThemeSpecificsIfNecessary( 52 const sync_pb::ThemeSpecifics& theme_specifics, Profile* profile); 53 54 // Like SetCurrentThemeFromThemeSpecifics() except that in the case where 55 // |theme_specifics| uses the default theme and |profile| does not, the local 56 // data "wins" against the server's and |theme_specifics| is updated with the 57 // custom theme. Returns true iff |theme_specifics| is updated. 58 bool UpdateThemeSpecificsOrSetCurrentThemeIfNecessary( 59 Profile* profile, sync_pb::ThemeSpecifics* theme_specifics); 60 61 } // namespace browser_sync 62 63 #endif // CHROME_BROWSER_SYNC_GLUE_THEME_UTIL_H_ 64