summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 20:32:52 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 20:32:52 +0000
commitca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55 (patch)
tree1f71fdc61b39b4728dbf5d774f1306c0a34bb96b
parent8acfa0427d4a27763b8cf63a846e55b75e9073d9 (diff)
downloadchromium_src-ca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55.zip
chromium_src-ca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55.tar.gz
chromium_src-ca39c1c2d84c152e7365ab5f2e5fcb1bb6056b55.tar.bz2
Abstract fullscreen exit bubble logic to bring Linux's behaviour in line with
Windows. BUG=30743 TEST= Review URL: http://codereview.chromium.org/7549005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95480 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/themes/browser_theme_pack.cc16
-rw-r--r--chrome/browser/themes/browser_theme_pack.h4
-rwxr-xr-xtools/data_pack/data_pack.py13
-rwxr-xr-xtools/grit/grit/format/data_pack.py7
-rw-r--r--tools/grit/grit/format/data_pack_unittest.py8
-rw-r--r--ui/base/resource/data_pack.cc44
-rw-r--r--ui/base/resource/data_pack.h6
-rw-r--r--ui/base/resource/data_pack_unittest.cc2
-rw-r--r--ui/base/test/data/data_pack_unittest/sample.pakbin80 -> 72 bytes
9 files changed, 52 insertions, 48 deletions
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index 6b1f940..ad76008 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/themes/browser_theme_pack.h"
+#include <limits>
+
#include "base/stl_util.h"
#include "base/string_util.h"
#include "base/threading/thread_restrictions.h"
@@ -27,18 +29,18 @@ namespace {
// Version number of the current theme pack. We just throw out and rebuild
// theme packs that aren't int-equal to this.
-const int kThemePackVersion = 15;
+const int kThemePackVersion = 16;
// IDs that are in the DataPack won't clash with the positive integer
-// int32_t. kHeaderID should always have the maximum value because we want the
+// uint16. kHeaderID should always have the maximum value because we want the
// "header" to be written last. That way we can detect whether the pack was
// successfully written and ignore and regenerate if it was only partially
// written (i.e. chrome crashed on a different thread while writing the pack).
-const int kHeaderID = UINT_MAX - 1;
-const int kTintsID = UINT_MAX - 2;
-const int kColorsID = UINT_MAX - 3;
-const int kDisplayPropertiesID = UINT_MAX - 4;
-const int kSourceImagesID = UINT_MAX - 5;
+const int kHeaderID = std::numeric_limits<uint16>::max() - 1;
+const int kTintsID = std::numeric_limits<uint16>::max() - 2;
+const int kColorsID = std::numeric_limits<uint16>::max() - 3;
+const int kDisplayPropertiesID = std::numeric_limits<uint16>::max() - 4;
+const int kSourceImagesID = std::numeric_limits<uint16>::max() - 5;
// Static size of the tint/color/display property arrays that are mmapped.
const int kTintArraySize = 6;
diff --git a/chrome/browser/themes/browser_theme_pack.h b/chrome/browser/themes/browser_theme_pack.h
index c208751..fb748e9 100644
--- a/chrome/browser/themes/browser_theme_pack.h
+++ b/chrome/browser/themes/browser_theme_pack.h
@@ -103,8 +103,8 @@ class BrowserThemePack : public base::RefCountedThreadSafe<
// The raw PNG memory associated with a certain id.
typedef std::map<int, scoped_refptr<RefCountedMemory> > RawImages;
- // The type passed to base::DataPack::WritePack.
- typedef std::map<uint32, base::StringPiece> RawDataForWriting;
+ // The type passed to ui::DataPack::WritePack.
+ typedef std::map<uint16, base::StringPiece> RawDataForWriting;
// An association between an id and the FilePath that has the image data.
typedef std::map<int, FilePath> FilePathMap;
diff --git a/tools/data_pack/data_pack.py b/tools/data_pack/data_pack.py
index fde9483..571842e 100755
--- a/tools/data_pack/data_pack.py
+++ b/tools/data_pack/data_pack.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (c) 2008 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 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.
@@ -9,7 +9,7 @@ See base/pack_file* for details.
import struct
-FILE_FORMAT_VERSION = 1
+FILE_FORMAT_VERSION = 2
HEADER_LENGTH = 2 * 4 # Two uint32s. (file version and number of entries)
class WrongFileVersion(Exception):
@@ -28,9 +28,9 @@ def ReadDataPack(input_file):
resources = {}
# Read the index and data.
data = data[HEADER_LENGTH:]
- kIndexEntrySize = 3 * 4 # Each entry is 3 uint32s.
+ kIndexEntrySize = 2 + 2 * 4 # Each entry is 1 uint16 and 2 uint32s.
for _ in range(num_entries):
- id, offset, length = struct.unpack("<III", data[:kIndexEntrySize])
+ id, offset, length = struct.unpack("<HII", data[:kIndexEntrySize])
data = data[kIndexEntrySize:]
resources[id] = original_data[offset:offset + length]
@@ -44,12 +44,13 @@ def WriteDataPack(resources, output_file):
# Write file header.
file.write(struct.pack("<II", FILE_FORMAT_VERSION, len(ids)))
- index_length = len(ids) * 3 * 4 # Each entry is 3 uint32s.
+ # Each entry is 1 uint16 and 2 uint32s.
+ index_length = len(ids) * (2 + 2 * 4)
# Write index.
data_offset = HEADER_LENGTH + index_length
for id in ids:
- file.write(struct.pack("<III", id, data_offset, len(resources[id])))
+ file.write(struct.pack("<HII", id, data_offset, len(resources[id])))
data_offset += len(resources[id])
# Write data.
diff --git a/tools/grit/grit/format/data_pack.py b/tools/grit/grit/format/data_pack.py
index c8a46ad..112c13e 100755
--- a/tools/grit/grit/format/data_pack.py
+++ b/tools/grit/grit/format/data_pack.py
@@ -15,7 +15,7 @@ from grit.node import message
from grit.node import misc
-PACK_FILE_VERSION = 1
+PACK_FILE_VERSION = 2
class DataPack(interface.ItemFormatter):
@@ -60,12 +60,13 @@ class DataPack(interface.ItemFormatter):
ret.append(struct.pack("<II", PACK_FILE_VERSION, len(ids)))
HEADER_LENGTH = 2 * 4 # Two uint32s.
- index_length = len(ids) * 3 * 4 # Each entry is 3 uint32s.
+ # Each entry is 1 uint16 + 2 uint32s.
+ index_length = len(ids) * (2 + 2 * 4)
# Write index.
data_offset = HEADER_LENGTH + index_length
for id in ids:
- ret.append(struct.pack("<III", id, data_offset, len(resources[id])))
+ ret.append(struct.pack("<HII", id, data_offset, len(resources[id])))
data_offset += len(resources[id])
# Write data.
diff --git a/tools/grit/grit/format/data_pack_unittest.py b/tools/grit/grit/format/data_pack_unittest.py
index 353f8c1..77c4ba1 100644
--- a/tools/grit/grit/format/data_pack_unittest.py
+++ b/tools/grit/grit/format/data_pack_unittest.py
@@ -1,5 +1,5 @@
#!/usr/bin/python2.4
-# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+# Copyright (c) 2011 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.
@@ -15,9 +15,9 @@ from grit.format import data_pack
class FormatDataPackUnittest(unittest.TestCase):
def testWriteDataPack(self):
- expected = ('\x01\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x008\x00\x00'
- '\x00\x00\x00\x00\x00\x04\x00\x00\x008\x00\x00\x00\x0c\x00\x00\x00'
- '\x06\x00\x00\x00D\x00\x00\x00\x0c\x00\x00\x00\n\x00\x00\x00P\x00'
+ expected = ('\x02\x00\x00\x00\x04\x00\x00\x00\x01\x000\x00\x00'
+ '\x00\x00\x00\x00\x00\x04\x000\x00\x00\x00\x0c\x00\x00\x00'
+ '\x06\x00<\x00\x00\x00\x0c\x00\x00\x00\n\x00H\x00'
'\x00\x00\x00\x00\x00\x00this is id 4this is id 6')
input = { 1: "", 4: "this is id 4", 6: "this is id 6", 10: "" }
output = data_pack.DataPack.WriteDataPack(input)
diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc
index d6e4e7b..18fee46 100644
--- a/ui/base/resource/data_pack.cc
+++ b/ui/base/resource/data_pack.cc
@@ -17,20 +17,18 @@
namespace {
-// A word is four bytes.
-static const size_t kWord = 4;
-
-static const uint32 kFileFormatVersion = 1;
+static const uint32 kFileFormatVersion = 2;
// Length of file header: version and entry count.
static const size_t kHeaderLength = 2 * sizeof(uint32);
+#pragma pack(push,2)
struct DataPackEntry {
- uint32 resource_id;
+ uint16 resource_id;
uint32 file_offset;
uint32 length;
static int CompareById(const void* void_key, const void* void_entry) {
- uint32 key = *reinterpret_cast<const uint32*>(void_key);
+ uint16 key = *reinterpret_cast<const uint16*>(void_key);
const DataPackEntry* entry =
reinterpret_cast<const DataPackEntry*>(void_entry);
if (key < entry->resource_id) {
@@ -42,8 +40,9 @@ struct DataPackEntry {
}
}
};
+#pragma pack(pop)
-COMPILE_ASSERT(sizeof(DataPackEntry) == 12, size_of_header_must_be_twelve);
+COMPILE_ASSERT(sizeof(DataPackEntry) == 10, size_of_header_must_be_ten);
// We're crashing when trying to load a pak file on Windows. Add some error
// codes for logging.
@@ -119,7 +118,7 @@ bool DataPack::Load(const FilePath& path) {
return true;
}
-bool DataPack::GetStringPiece(uint32 resource_id,
+bool DataPack::GetStringPiece(uint16 resource_id,
base::StringPiece* data) const {
// It won't be hard to make this endian-agnostic, but it's not worth
// bothering to do right now.
@@ -143,7 +142,7 @@ bool DataPack::GetStringPiece(uint32 resource_id,
return true;
}
-RefCountedStaticMemory* DataPack::GetStaticMemory(uint32 resource_id) const {
+RefCountedStaticMemory* DataPack::GetStaticMemory(uint16 resource_id) const {
base::StringPiece piece;
if (!GetStringPiece(resource_id, &piece))
return NULL;
@@ -154,12 +153,12 @@ RefCountedStaticMemory* DataPack::GetStaticMemory(uint32 resource_id) const {
// static
bool DataPack::WritePack(const FilePath& path,
- const std::map<uint32, base::StringPiece>& resources) {
+ const std::map<uint16, base::StringPiece>& resources) {
FILE* file = file_util::OpenFile(path, "wb");
if (!file)
return false;
- if (fwrite(&kFileFormatVersion, 1, kWord, file) != kWord) {
+ if (fwrite(&kFileFormatVersion, sizeof(kFileFormatVersion), 1, file) != 1) {
LOG(ERROR) << "Failed to write file version";
file_util::CloseFile(file);
return false;
@@ -168,33 +167,34 @@ bool DataPack::WritePack(const FilePath& path,
// Note: the python version of this function explicitly sorted keys, but
// std::map is a sorted associative container, we shouldn't have to do that.
uint32 entry_count = resources.size();
- if (fwrite(&entry_count, 1, kWord, file) != kWord) {
+ if (fwrite(&entry_count, sizeof(entry_count), 1, file) != 1) {
LOG(ERROR) << "Failed to write entry count";
file_util::CloseFile(file);
return false;
}
- // Each entry is 3 uint32s.
- uint32 index_length = entry_count * 3 * kWord;
+ // Each entry is 1 uint16 + 2 uint32s.
+ uint32 index_length = entry_count * sizeof(DataPackEntry);
uint32 data_offset = kHeaderLength + index_length;
- for (std::map<uint32, base::StringPiece>::const_iterator it =
+ for (std::map<uint16, base::StringPiece>::const_iterator it =
resources.begin();
it != resources.end(); ++it) {
- if (fwrite(&it->first, 1, kWord, file) != kWord) {
- LOG(ERROR) << "Failed to write id for " << it->first;
+ uint16 resource_id = it->first;
+ if (fwrite(&resource_id, sizeof(resource_id), 1, file) != 1) {
+ LOG(ERROR) << "Failed to write id for " << resource_id;
file_util::CloseFile(file);
return false;
}
- if (fwrite(&data_offset, 1, kWord, file) != kWord) {
- LOG(ERROR) << "Failed to write offset for " << it->first;
+ if (fwrite(&data_offset, sizeof(data_offset), 1, file) != 1) {
+ LOG(ERROR) << "Failed to write offset for " << resource_id;
file_util::CloseFile(file);
return false;
}
uint32 len = it->second.length();
- if (fwrite(&len, 1, kWord, file) != kWord) {
- LOG(ERROR) << "Failed to write length for " << it->first;
+ if (fwrite(&len, sizeof(len), 1, file) != 1) {
+ LOG(ERROR) << "Failed to write length for " << resource_id;
file_util::CloseFile(file);
return false;
}
@@ -202,7 +202,7 @@ bool DataPack::WritePack(const FilePath& path,
data_offset += len;
}
- for (std::map<uint32, base::StringPiece>::const_iterator it =
+ for (std::map<uint16, base::StringPiece>::const_iterator it =
resources.begin();
it != resources.end(); ++it) {
if (fwrite(it->second.data(), it->second.length(), 1, file) != 1) {
diff --git a/ui/base/resource/data_pack.h b/ui/base/resource/data_pack.h
index 001ed0e..f8d2e19 100644
--- a/ui/base/resource/data_pack.h
+++ b/ui/base/resource/data_pack.h
@@ -40,16 +40,16 @@ class UI_API DataPack {
// Get resource by id |resource_id|, filling in |data|.
// The data is owned by the DataPack object and should not be modified.
// Returns false if the resource id isn't found.
- bool GetStringPiece(uint32 resource_id, base::StringPiece* data) const;
+ bool GetStringPiece(uint16 resource_id, base::StringPiece* data) const;
// Like GetStringPiece(), but returns a reference to memory. This interface
// is used for image data, while the StringPiece interface is usually used
// for localization strings.
- RefCountedStaticMemory* GetStaticMemory(uint32 resource_id) const;
+ RefCountedStaticMemory* GetStaticMemory(uint16 resource_id) const;
// Writes a pack file containing |resources| to |path|.
static bool WritePack(const FilePath& path,
- const std::map<uint32, base::StringPiece>& resources);
+ const std::map<uint16, base::StringPiece>& resources);
private:
// The memory-mapped data.
diff --git a/ui/base/resource/data_pack_unittest.cc b/ui/base/resource/data_pack_unittest.cc
index 9205fdf..0f48097 100644
--- a/ui/base/resource/data_pack_unittest.cc
+++ b/ui/base/resource/data_pack_unittest.cc
@@ -48,7 +48,7 @@ TEST(DataPackTest, Write) {
std::string four("four");
std::string fifteen("fifteen");
- std::map<uint32, base::StringPiece> resources;
+ std::map<uint16, base::StringPiece> resources;
resources.insert(std::make_pair(1, base::StringPiece(one)));
resources.insert(std::make_pair(2, base::StringPiece(two)));
resources.insert(std::make_pair(15, base::StringPiece(fifteen)));
diff --git a/ui/base/test/data/data_pack_unittest/sample.pak b/ui/base/test/data/data_pack_unittest/sample.pak
index fdbe2b5..b172097 100644
--- a/ui/base/test/data/data_pack_unittest/sample.pak
+++ b/ui/base/test/data/data_pack_unittest/sample.pak
Binary files differ