summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-09 01:07:42 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-09 01:07:42 +0000
commit4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f (patch)
tree69a1e9f78b3a5fa8b909cfab336826b09c44235f /app
parent5085ee0b4bfbe4625e63ee6975bb95702e13e0aa (diff)
downloadchromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.zip
chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.gz
chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.bz2
This is the first pass at themes.
This CL is paired with http://codereview.chromium.org/67284 This CL (for commit purposes) includes http://codereview.chromium.org/67284 BUG=4463,11232,11233,11234,11235 Review URL: http://codereview.chromium.org/99030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/DEPS29
-rw-r--r--app/app.vcproj36
-rw-r--r--app/resource_bundle.cc46
-rw-r--r--app/resource_bundle.h16
-rw-r--r--app/theme_provider.h33
5 files changed, 93 insertions, 67 deletions
diff --git a/app/DEPS b/app/DEPS
index 8770ca2..cf364f4 100644
--- a/app/DEPS
+++ b/app/DEPS
@@ -1,19 +1,16 @@
-include_rules = [
+include_rules = [
# TODO(beng): Modify this link to be more specific about what resource
# headers are included once app gets its own strings.
- "+grit",
- "+net",
- # TODO(beng): Sever these links once we have extracted all deps from
- # chrome/common.
- "+chrome/common/chrome_paths.h",
- "+chrome/common/chrome_switches.h",
- "+chrome/common/gtk_util.h",
+ "+grit",
+ "+net",
+ # TODO(beng): Sever these links once we have extracted all deps from
+ # chrome/common.
+ "+chrome/common/chrome_paths.h",
+ "+chrome/common/chrome_switches.h",
+ "+chrome/common/gtk_util.h",
- # TODO(beng): l10n_util_unittest.cc:
- "+chrome/test/data/resource.h",
-
- # TODO(beng): resource_bundle.cc: Sever this link after glen fixes it.
- "+chrome/browser/extensions/extension.h",
-
- "+skia",
-]
+ # TODO(beng): l10n_util_unittest.cc:
+ "+chrome/test/data/resource.h",
+
+ "+skia",
+]
diff --git a/app/app.vcproj b/app/app.vcproj
index 507a28a..d940bf9 100644
--- a/app/app.vcproj
+++ b/app/app.vcproj
@@ -145,14 +145,14 @@
>
</File>
<File
- RelativePath=".\gfx\color_utils.cc"
- >
- </File>
- <File
- RelativePath=".\gfx\color_utils.h"
- >
- </File>
- <File
+ RelativePath=".\gfx\color_utils.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\gfx\color_utils.h"
+ >
+ </File>
+ <File
RelativePath=".\gfx\favicon_size.h"
>
</File>
@@ -176,14 +176,14 @@
RelativePath=".\gfx\path_win.cc"
>
</File>
- <File
- RelativePath=".\gfx\text_elider.cc"
- >
- </File>
- <File
- RelativePath=".\gfx\text_elider.h"
- >
- </File>
+ <File
+ RelativePath=".\gfx\text_elider.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\gfx\text_elider.h"
+ >
+ </File>
</Filter>
<File
RelativePath=".\animation.cc"
@@ -250,6 +250,10 @@
>
</File>
<File
+ RelativePath=".\theme_provider.h"
+ >
+ </File>
+ <File
RelativePath=".\throb_animation.cc"
>
</File>
diff --git a/app/resource_bundle.cc b/app/resource_bundle.cc
index c3d6923..85fd0b9 100644
--- a/app/resource_bundle.cc
+++ b/app/resource_bundle.cc
@@ -15,6 +15,22 @@
ResourceBundle* ResourceBundle::g_shared_instance_ = NULL;
/* static */
+// TODO(glen): Finish moving these into theme provider (dialogs still
+// depend on these colors).
+const SkColor ResourceBundle::frame_color =
+ SkColorSetRGB(77, 139, 217);
+const SkColor ResourceBundle::frame_color_inactive =
+ SkColorSetRGB(184, 209, 240);
+const SkColor ResourceBundle::frame_color_incognito =
+ SkColorSetRGB(83, 106, 139);
+const SkColor ResourceBundle::frame_color_incognito_inactive =
+ SkColorSetRGB(126, 139, 156);
+const SkColor ResourceBundle::toolbar_color =
+ SkColorSetRGB(210, 225, 246);
+const SkColor ResourceBundle::toolbar_separator_color =
+ SkColorSetRGB(182, 186, 192);
+
+/* static */
void ResourceBundle::InitSharedInstance(const std::wstring& pref_locale) {
DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice";
g_shared_instance_ = new ResourceBundle();
@@ -51,39 +67,11 @@ void ResourceBundle::FreeImages() {
skia_images_.clear();
}
-void ResourceBundle::SetThemeExtension(const Extension& e) {
- theme_extension_.reset(new Extension(e));
-}
-
/* static */
SkBitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id) {
std::vector<unsigned char> raw_data, png_data;
bool success = false;
- // First check to see if we have a registered theme extension and whether
- // it can handle this resource.
- // TODO(erikkay): It would be nice to use something less brittle than
- // resource_id here.
- if (g_shared_instance_->theme_extension_.get()) {
- FilePath path =
- g_shared_instance_->theme_extension_->GetThemeResourcePath(resource_id);
- if (!path.empty()) {
- net::FileStream file;
- int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
- if (file.Open(path, flags) == net::OK) {
- int64 avail = file.Available();
- if (avail > 0 && avail < INT_MAX) {
- size_t size = static_cast<size_t>(avail);
- raw_data.resize(size);
- char* data = reinterpret_cast<char*>(&(raw_data.front()));
- if (file.ReadUntilComplete(data, size) == avail) {
- success= true;
- } else {
- raw_data.resize(0);
- }
- }
- }
- }
- }
+
if (!success)
success = LoadResourceBytes(data_handle, resource_id, &raw_data);
if (!success)
diff --git a/app/resource_bundle.h b/app/resource_bundle.h
index e939edc..1ed44b0 100644
--- a/app/resource_bundle.h
+++ b/app/resource_bundle.h
@@ -18,7 +18,7 @@
#include "base/file_path.h"
#include "base/lock.h"
#include "base/scoped_ptr.h"
-#include "chrome/browser/extensions/extension.h"
+#include "base/string16.h"
#if defined(OS_LINUX) || defined(OS_MACOSX)
namespace base {
@@ -29,8 +29,8 @@ class DataPack;
typedef struct _GdkPixbuf GdkPixbuf;
#endif
class ChromeFont;
-class Extension;
class SkBitmap;
+typedef uint32 SkColor;
class StringPiece;
// ResourceBundle is a central facility to load images and other resources,
@@ -123,8 +123,14 @@ class ResourceBundle {
GdkPixbuf* GetPixbufNamed(int resource_id);
#endif
- // Sets an Extension object that can handle theme resource requests.
- void SetThemeExtension(const Extension& e);
+ // TODO(glen): Move these into theme provider (dialogs still depend on
+ // ResourceBundle).
+ static const SkColor frame_color;
+ static const SkColor frame_color_inactive;
+ static const SkColor frame_color_incognito;
+ static const SkColor frame_color_incognito_inactive;
+ static const SkColor toolbar_color;
+ static const SkColor toolbar_separator_color;
private:
// We define a DataHandle typedef to abstract across how data is stored
@@ -195,8 +201,6 @@ class ResourceBundle {
static ResourceBundle* g_shared_instance_;
- scoped_ptr<Extension> theme_extension_;
-
DISALLOW_EVIL_CONSTRUCTORS(ResourceBundle);
};
diff --git a/app/theme_provider.h b/app/theme_provider.h
new file mode 100644
index 0000000..ebc94c6
--- /dev/null
+++ b/app/theme_provider.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_THEME_PROVIDER_H_
+#define APP_THEME_PROVIDER_H_
+
+#include "skia/include/SkColor.h"
+
+class SkBitmap;
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// ThemeProvider
+//
+// ThemeProvider is an abstract class that defines the API that should be
+// implemented to provide bitmaps and color information for a given theme.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+class ThemeProvider {
+ public:
+ virtual ~ThemeProvider() { }
+
+ // Get the bitmap specified by |id|. An implementation of ThemeProvider should
+ // have its own source of ids (e.g. an enum, or external resource bundle).
+ virtual SkBitmap* GetBitmapNamed(int id) = 0;
+
+ // Get the color specified by |id|.
+ virtual SkColor GetColor(int id) = 0;
+};
+
+#endif // APP_THEME_PROVIDER_H_