summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-21 20:50:39 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-21 20:50:39 +0000
commit933cc00eb856db684b9e64b7486ca20edbb2c3ea (patch)
treec7be5057c42ffb82e38d6fc421c0be524a2af7a1 /chrome
parentd232c09f2584c80b6fde6b987fac32c8de57bfd7 (diff)
downloadchromium_src-933cc00eb856db684b9e64b7486ca20edbb2c3ea.zip
chromium_src-933cc00eb856db684b9e64b7486ca20edbb2c3ea.tar.gz
chromium_src-933cc00eb856db684b9e64b7486ca20edbb2c3ea.tar.bz2
Port some files in chrome/common to Linux.
BUG=3649 Review URL: http://codereview.chromium.org/10255 Patch from Paweł Hajdan jr <phajdan.jr@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/common/common.scons4
-rw-r--r--chrome/common/common_glue.cc4
-rw-r--r--chrome/common/gfx/chrome_font.h3
-rw-r--r--chrome/common/gfx/text_elider.h1
-rw-r--r--chrome/common/pref_service.cc36
-rw-r--r--chrome/common/time_format.cc13
6 files changed, 25 insertions, 36 deletions
diff --git a/chrome/common/common.scons b/chrome/common/common.scons
index 549f57b..e7096f0 100644
--- a/chrome/common/common.scons
+++ b/chrome/common/common.scons
@@ -62,12 +62,14 @@ if env['PLATFORM'] in ('posix', 'win32'):
'notification_service.cc',
'pref_member.cc',
'pref_names.cc',
+ 'pref_service.cc',
'slide_animation.cc',
'sqlite_compiled_statement.cc',
'sqlite_utils.cc',
'task_queue.cc',
'throb_animation.cc',
'thumbnail_score.cc',
+ 'time_format.cc',
'visitedlink_common.cc',
])
@@ -99,13 +101,11 @@ if env['PLATFORM'] == 'win32':
'net/url_request_intercept_job.cc',
'os_exchange_data.cc',
'plugin_messages.cc',
- 'pref_service.cc',
'process_watcher.cc',
'render_messages.cc',
'resource_bundle.cc',
'resource_dispatcher.cc',
'security_filter_peer.cc',
- 'time_format.cc',
'win_safe_util.cc',
'win_util.cc',
'worker_thread_ticker.cc',
diff --git a/chrome/common/common_glue.cc b/chrome/common/common_glue.cc
index 30b1e4f..6c33f1e 100644
--- a/chrome/common/common_glue.cc
+++ b/chrome/common/common_glue.cc
@@ -6,7 +6,7 @@
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/resource_bundle.h"
+#include "chrome/common/l10n_util.h"
#include "chrome/plugin/npobject_util.h"
#include "googleurl/src/url_util.h"
#include "webkit/glue/webkit_glue.h"
@@ -39,7 +39,7 @@ std::wstring GetWebKitLocale() {
}
std::wstring GetLocalizedString(int message_id) {
- return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id);
+ return l10n_util::GetString(message_id);
}
} // namespace webkit_glue
diff --git a/chrome/common/gfx/chrome_font.h b/chrome/common/gfx/chrome_font.h
index 2cfd28b..ffbbdd3 100644
--- a/chrome/common/gfx/chrome_font.h
+++ b/chrome/common/gfx/chrome_font.h
@@ -11,6 +11,9 @@
#if defined(OS_WIN)
typedef struct HFONT__* HFONT;
+#else
+// TODO(port): Make it more real.
+typedef void* HFONT;
#endif
#include "base/basictypes.h"
diff --git a/chrome/common/gfx/text_elider.h b/chrome/common/gfx/text_elider.h
index 26872db..e13dab6 100644
--- a/chrome/common/gfx/text_elider.h
+++ b/chrome/common/gfx/text_elider.h
@@ -7,7 +7,6 @@
#include <unicode/coll.h>
#include <unicode/uchar.h>
-#include <windows.h>
#include "base/basictypes.h"
#include "chrome/common/gfx/chrome_font.h"
diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc
index 5e2f319..a942e32 100644
--- a/chrome/common/pref_service.cc
+++ b/chrome/common/pref_service.cc
@@ -4,6 +4,7 @@
#include "chrome/common/pref_service.h"
+#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -40,13 +41,10 @@ class SaveLaterTask : public Task {
int bytes_written = file_util::WriteFile(tmp_file_name, data_.c_str(),
static_cast<int>(data_.length()));
if (bytes_written != -1) {
- if (!MoveFileEx(tmp_file_name.c_str(), file_name_.c_str(),
- MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) {
+ if (!file_util::Move(tmp_file_name, file_name_)) {
// Rename failed. Try again on the off chance someone has locked either
// file and hope we're successful the second time through.
- BOOL move_result =
- MoveFileEx(tmp_file_name.c_str(), file_name_.c_str(),
- MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
+ bool move_result = file_util::Move(tmp_file_name, file_name_);
DCHECK(move_result);
}
}
@@ -56,7 +54,7 @@ class SaveLaterTask : public Task {
std::wstring file_name_;
std::string data_;
- DISALLOW_EVIL_CONSTRUCTORS(SaveLaterTask);
+ DISALLOW_COPY_AND_ASSIGN(SaveLaterTask);
};
// A helper function for RegisterLocalized*Pref that creates a Value* based on
@@ -75,23 +73,12 @@ Value* CreateLocaleDefaultValue(Value::ValueType type, int message_id) {
}
case Value::TYPE_INTEGER: {
- int num_int = 0;
- int parsed_values = swscanf_s(resource_string.c_str(), L"%d", &num_int);
- // This is a trusted value (comes from our locale dll), so it should
- // successfully parse.
- DCHECK(parsed_values == 1);
- return Value::CreateIntegerValue(num_int);
+ return Value::CreateIntegerValue(StringToInt(resource_string));
break;
}
case Value::TYPE_REAL: {
- double num_double = 0.0;
- int parsed_values = swscanf_s(resource_string.c_str(), L"%lf",
- &num_double);
- // This is a trusted value (comes from our locale dll), so it should
- // successfully parse.
- DCHECK(parsed_values == 1);
- return Value::CreateRealValue(num_double);
+ return Value::CreateRealValue(StringToDouble(resource_string));
break;
}
@@ -121,8 +108,7 @@ PrefService::PrefService(const std::wstring& pref_filename)
: persistent_(new DictionaryValue),
transient_(new DictionaryValue),
pref_filename_(pref_filename),
-#pragma warning(suppress: 4355) // Okay to pass "this" here.
- save_preferences_factory_(this) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(save_preferences_factory_(this)) {
LoadPersistentPrefs(pref_filename_);
}
@@ -434,7 +420,7 @@ void PrefService::AddPrefObserver(const wchar_t* path,
// Verify that this observer doesn't already exist.
NotificationObserverList::Iterator it(*observer_list);
NotificationObserver* existing_obs;
- while (existing_obs = it.GetNext()) {
+ while ((existing_obs = it.GetNext()) != NULL) {
DCHECK(existing_obs != obs) << path << " observer already registered";
if (existing_obs == obs)
return;
@@ -640,7 +626,7 @@ void PrefService::FireObservers(const wchar_t* path) {
NotificationObserverList::Iterator it(*(observer_iterator->second));
NotificationObserver* observer;
- while (observer = it.GetNext()) {
+ while ((observer = it.GetNext()) != NULL) {
observer->Observe(NOTIFY_PREF_CHANGED,
Source<PrefService>(this),
Details<std::wstring>(&path_str));
@@ -653,10 +639,10 @@ void PrefService::FireObservers(const wchar_t* path) {
PrefService::Preference::Preference(DictionaryValue* root_pref,
const wchar_t* name,
Value* default_value)
- : root_pref_(root_pref),
+ : type_(Value::TYPE_NULL),
name_(name),
default_value_(default_value),
- type_(Value::TYPE_NULL) {
+ root_pref_(root_pref) {
DCHECK(name);
if (default_value) {
diff --git a/chrome/common/time_format.cc b/chrome/common/time_format.cc
index 029aec0..70fe12c 100644
--- a/chrome/common/time_format.cc
+++ b/chrome/common/time_format.cc
@@ -40,8 +40,8 @@ class TimeRemainingFormat {
STLDeleteContainerPointers(long_formatter_.begin(),
long_formatter_.end());
}
- friend Singleton<TimeRemainingFormat>;
- friend DefaultSingletonTraits<TimeRemainingFormat>;
+ friend class Singleton<TimeRemainingFormat>;
+ friend struct DefaultSingletonTraits<TimeRemainingFormat>;
std::vector<PluralFormat*> long_formatter_;
std::vector<PluralFormat*> short_formatter_;
@@ -116,7 +116,7 @@ void TimeRemainingFormat::BuildFormats(
}
for (int i = 0; i < 4; ++i) {
UnicodeString pattern;
- for (int j = 0; j < arraysize(kKeywords); ++j) {
+ for (size_t j = 0; j < arraysize(kKeywords); ++j) {
int msg_id = short_version ? kTimeMsgIds[i][j] : kTimeLeftMsgIds[i][j];
if (msg_id == kInvalidMsgId) continue;
std::string sub_pattern = WideToUTF8(l10n_util::GetString(msg_id));
@@ -213,11 +213,12 @@ static std::wstring TimeRemainingImpl(const TimeDelta& delta,
// With the fallback added, this should never fail.
DCHECK(U_SUCCESS(error));
int capacity = time_string.length() + 1;
- std::wstring formatted;
- time_string.extract(static_cast<UChar*>(WriteInto(&formatted, capacity)),
+ string16 result_utf16;
+ time_string.extract(static_cast<UChar*>(
+ WriteInto(&result_utf16, capacity)),
capacity, error);
DCHECK(U_SUCCESS(error));
- return formatted;
+ return UTF16ToWide(result_utf16);
}
// static