diff options
42 files changed, 789 insertions, 257 deletions
diff --git a/base/base.gypi b/base/base.gypi index d590df0..ff05d2a 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -235,6 +235,7 @@ 'sys_string_conversions_linux.cc', 'sys_string_conversions_mac.mm', 'sys_string_conversions_win.cc', + 'task.cc', 'task.h', 'template_util.h', 'thread.cc', @@ -277,6 +278,7 @@ 'waitable_event_win.cc', 'watchdog.cc', 'watchdog.h', + 'weak_ptr.cc', 'weak_ptr.h', 'win_util.cc', 'win_util.h', diff --git a/base/command_line.cc b/base/command_line.cc index 2c6ef0b..2a7824d 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -55,6 +55,9 @@ static void Lowercase(std::string* parameter) { } #endif +CommandLine::~CommandLine() { +} + #if defined(OS_WIN) CommandLine::CommandLine(ArgumentsOnly args_only) { } @@ -437,3 +440,7 @@ void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) { } #endif + +// private +CommandLine::CommandLine() { +} diff --git a/base/command_line.h b/base/command_line.h index b2b4185..c68711a 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -35,6 +35,7 @@ class CommandLine { // A constructor for CommandLines that are used only to carry arguments. enum ArgumentsOnly { ARGUMENTS_ONLY }; explicit CommandLine(ArgumentsOnly args_only); + ~CommandLine(); #if defined(OS_WIN) // The type of native command line arguments. @@ -203,7 +204,7 @@ class CommandLine { private: friend class InProcessBrowserTest; - CommandLine() {} + CommandLine(); // Used by InProcessBrowserTest. static CommandLine* ForCurrentProcessMutable() { diff --git a/base/env_var.cc b/base/env_var.cc index 8d32c02..bcdadb9 100644 --- a/base/env_var.cc +++ b/base/env_var.cc @@ -85,6 +85,12 @@ class EnvVarGetterImpl : public base::EnvVarGetter { namespace base { +EnvVarGetter::~EnvVarGetter() {} + +bool EnvVarGetter::HasEnv(const char* variable_name) { + return GetEnv(variable_name, NULL); +} + // static EnvVarGetter* EnvVarGetter::Create() { return new EnvVarGetterImpl(); diff --git a/base/env_var.h b/base/env_var.h index 6888353..3cc2399 100644 --- a/base/env_var.h +++ b/base/env_var.h @@ -14,15 +14,14 @@ namespace base { // These are used to derive mocks for unittests. class EnvVarGetter { public: - virtual ~EnvVarGetter() {} + virtual ~EnvVarGetter(); + // Gets an environment variable's value and stores it in |result|. // Returns false if the key is unset. virtual bool GetEnv(const char* variable_name, std::string* result) = 0; // Syntactic sugar for GetEnv(variable_name, NULL); - virtual bool HasEnv(const char* variable_name) { - return GetEnv(variable_name, NULL); - } + virtual bool HasEnv(const char* variable_name); virtual void SetEnv(const char* variable_name, const std::string& new_value) = 0; diff --git a/base/message_loop.cc b/base/message_loop.cc index 218ff26..1d86f79 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -100,6 +100,17 @@ static LPTOP_LEVEL_EXCEPTION_FILTER GetTopSEHFilter() { //------------------------------------------------------------------------------ +MessageLoop::TaskObserver::TaskObserver() { +} + +MessageLoop::TaskObserver::~TaskObserver() { +} + +MessageLoop::DestructionObserver::~DestructionObserver() { +} + +//------------------------------------------------------------------------------ + // static MessageLoop* MessageLoop::current() { // TODO(darin): sadly, we cannot enable this yet since people call us even diff --git a/base/message_loop.h b/base/message_loop.h index 35b2651..62da3dd 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -66,7 +66,7 @@ class MessageLoop : public base::MessagePump::Delegate { // NOTE: A TaskObserver implementation should be extremely fast! class TaskObserver { public: - TaskObserver() {} + TaskObserver(); // This method is called before processing a task. virtual void WillProcessTask(base::TimeTicks birth_time) = 0; @@ -75,7 +75,7 @@ class MessageLoop : public base::MessagePump::Delegate { virtual void DidProcessTask() = 0; protected: - virtual ~TaskObserver() {} + virtual ~TaskObserver(); }; static void EnableHistogrammer(bool enable_histogrammer); @@ -90,7 +90,7 @@ class MessageLoop : public base::MessagePump::Delegate { // class DestructionObserver { public: - virtual ~DestructionObserver() {} + virtual ~DestructionObserver(); virtual void WillDestroyCurrentMessageLoop() = 0; }; diff --git a/base/task.cc b/base/task.cc new file mode 100644 index 0000000..d33f3e1 --- /dev/null +++ b/base/task.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2010 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. + +#include "base/task.h" + +Task::Task() { +} + +Task::~Task() { +} + +CancelableTask::CancelableTask() { +} + +CancelableTask::~CancelableTask() { +} diff --git a/base/task.h b/base/task.h index 1425546..64b10f3 100644 --- a/base/task.h +++ b/base/task.h @@ -18,8 +18,8 @@ class Task : public tracked_objects::Tracked { public: - Task() {} - virtual ~Task() {} + Task(); + virtual ~Task(); // Tasks are automatically deleted after Run is called. virtual void Run() = 0; @@ -27,6 +27,9 @@ class Task : public tracked_objects::Tracked { class CancelableTask : public Task { public: + CancelableTask(); + virtual ~CancelableTask(); + // Not all tasks support cancellation. virtual void Cancel() = 0; }; diff --git a/base/tracked.cc b/base/tracked.cc index fdac6d3..a9d6ad7 100644 --- a/base/tracked.cc +++ b/base/tracked.cc @@ -12,6 +12,20 @@ using base::TimeTicks; namespace tracked_objects { //------------------------------------------------------------------------------ + +Location::Location(const char* function_name, const char* file_name, + int line_number) + : function_name_(function_name), + file_name_(file_name), + line_number_(line_number) { +} + +Location::Location() + : function_name_("Unknown"), + file_name_("Unknown"), + line_number_(-1) { +} + void Location::Write(bool display_filename, bool display_function_name, std::string* output) const { StringAppendF(output, "%s[%d] ", diff --git a/base/tracked.h b/base/tracked.h index 3622d1c..af904c1 100644 --- a/base/tracked.h +++ b/base/tracked.h @@ -39,16 +39,10 @@ class Location { // Constructor should be called with a long-lived char*, such as __FILE__. // It assumes the provided value will persist as a global constant, and it // will not make a copy of it. - Location(const char* function_name, const char* file_name, int line_number) - : function_name_(function_name), - file_name_(file_name), - line_number_(line_number) { } + Location(const char* function_name, const char* file_name, int line_number); // Provide a default constructor for easy of debugging. - Location() - : function_name_("Unknown"), - file_name_("Unknown"), - line_number_(-1) { } + Location(); // Comparison operator for insertion into a std::map<> hash tables. // All we need is *some* (any) hashing distinction. Strings should already diff --git a/base/values.cc b/base/values.cc index 507646c..58a91f1 100644 --- a/base/values.cc +++ b/base/values.cc @@ -142,8 +142,23 @@ bool Value::Equals(const Value* other) const { return other->IsType(TYPE_NULL); } +Value::Value(ValueType type) : type_(type) { +} + ///////////////////// FundamentalValue //////////////////// +FundamentalValue::FundamentalValue(bool in_value) + : Value(TYPE_BOOLEAN), boolean_value_(in_value) { +} + +FundamentalValue::FundamentalValue(int in_value) + : Value(TYPE_INTEGER), integer_value_(in_value) { +} + +FundamentalValue::FundamentalValue(double in_value) + : Value(TYPE_REAL), real_value_(in_value) { +} + FundamentalValue::~FundamentalValue() { } @@ -307,6 +322,10 @@ bool BinaryValue::Equals(const Value* other) const { ///////////////////// DictionaryValue //////////////////// +DictionaryValue::DictionaryValue() + : Value(TYPE_DICTIONARY) { +} + DictionaryValue::~DictionaryValue() { Clear(); } @@ -696,6 +715,9 @@ void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) { ///////////////////// ListValue //////////////////// +ListValue::ListValue() : Value(TYPE_LIST) { +} + ListValue::~ListValue() { Clear(); } @@ -898,3 +920,6 @@ bool ListValue::Equals(const Value* other) const { return true; } + +ValueSerializer::~ValueSerializer() { +} diff --git a/base/values.h b/base/values.h index 5c0ea33..ea8a3ca 100644 --- a/base/values.h +++ b/base/values.h @@ -104,7 +104,7 @@ class Value { protected: // This isn't safe for end-users (they should use the Create*Value() // static methods above), but it's useful for subclasses. - explicit Value(ValueType type) : type_(type) {} + explicit Value(ValueType type); private: Value(); @@ -117,12 +117,9 @@ class Value { // FundamentalValue represents the simple fundamental types of values. class FundamentalValue : public Value { public: - explicit FundamentalValue(bool in_value) - : Value(TYPE_BOOLEAN), boolean_value_(in_value) {} - explicit FundamentalValue(int in_value) - : Value(TYPE_INTEGER), integer_value_(in_value) {} - explicit FundamentalValue(double in_value) - : Value(TYPE_REAL), real_value_(in_value) {} + explicit FundamentalValue(bool in_value); + explicit FundamentalValue(int in_value); + explicit FundamentalValue(double in_value); ~FundamentalValue(); // Subclassed methods @@ -206,7 +203,7 @@ class BinaryValue: public Value { class DictionaryValue : public Value { public: - DictionaryValue() : Value(TYPE_DICTIONARY) {} + DictionaryValue(); ~DictionaryValue(); // Subclassed methods @@ -352,7 +349,7 @@ class DictionaryValue : public Value { // This type of Value represents a list of other Value values. class ListValue : public Value { public: - ListValue() : Value(TYPE_LIST) {} + ListValue(); ~ListValue(); // Subclassed methods @@ -435,7 +432,7 @@ class ListValue : public Value { // deserialize Value objects. class ValueSerializer { public: - virtual ~ValueSerializer() {} + virtual ~ValueSerializer(); virtual bool Serialize(const Value& root) = 0; diff --git a/base/weak_ptr.cc b/base/weak_ptr.cc new file mode 100644 index 0000000..2c8f5aa --- /dev/null +++ b/base/weak_ptr.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2010 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. + +#include "base/weak_ptr.h" + +namespace base { +namespace internal { + +WeakReference::Flag::Flag(Flag** handle) : handle_(handle) { +} + +WeakReference::Flag::~Flag() { + if (handle_) + *handle_ = NULL; +} + +void WeakReference::Flag::AddRef() { + DCHECK(CalledOnValidThread()); + RefCounted<Flag>::AddRef(); +} + +void WeakReference::Flag::Release() { + DCHECK(CalledOnValidThread()); + RefCounted<Flag>::Release(); +} + +WeakReference::WeakReference() { +} + +WeakReference::WeakReference(Flag* flag) : flag_(flag) { +} + +bool WeakReference::is_valid() const { + return flag_ && flag_->is_valid(); +} + +WeakReferenceOwner::WeakReferenceOwner() : flag_(NULL) { +} + +WeakReferenceOwner::~WeakReferenceOwner() { + Invalidate(); +} + +WeakReference WeakReferenceOwner::GetRef() const { + if (!flag_) + flag_ = new WeakReference::Flag(&flag_); + return WeakReference(flag_); +} + +void WeakReferenceOwner::Invalidate() { + if (flag_) { + flag_->Invalidate(); + flag_ = NULL; + } +} + +WeakPtrBase::WeakPtrBase() { +} + +WeakPtrBase::WeakPtrBase(const WeakReference& ref) : ref_(ref) { +} + +} // namespace internal +} // namespace base diff --git a/base/weak_ptr.h b/base/weak_ptr.h index 1bc963e..85a26d16 100644 --- a/base/weak_ptr.h +++ b/base/weak_ptr.h @@ -65,24 +65,11 @@ class WeakReference { public: class Flag : public RefCounted<Flag>, public NonThreadSafe { public: - Flag(Flag** handle) : handle_(handle) { - } - - ~Flag() { - if (handle_) - *handle_ = NULL; - } - - void AddRef() { - DCHECK(CalledOnValidThread()); - RefCounted<Flag>::AddRef(); - } - - void Release() { - DCHECK(CalledOnValidThread()); - RefCounted<Flag>::Release(); - } + Flag(Flag** handle); + ~Flag(); + void AddRef(); + void Release(); void Invalidate() { handle_ = NULL; } bool is_valid() const { return handle_ != NULL; } @@ -90,10 +77,10 @@ class WeakReference { Flag** handle_; }; - WeakReference() {} - WeakReference(Flag* flag) : flag_(flag) {} + WeakReference(); + WeakReference(Flag* flag); - bool is_valid() const { return flag_ && flag_->is_valid(); } + bool is_valid() const; private: scoped_refptr<Flag> flag_; @@ -101,29 +88,16 @@ class WeakReference { class WeakReferenceOwner { public: - WeakReferenceOwner() : flag_(NULL) { - } - - ~WeakReferenceOwner() { - Invalidate(); - } + WeakReferenceOwner(); + ~WeakReferenceOwner(); - WeakReference GetRef() const { - if (!flag_) - flag_ = new WeakReference::Flag(&flag_); - return WeakReference(flag_); - } + WeakReference GetRef() const; bool HasRefs() const { return flag_ != NULL; } - void Invalidate() { - if (flag_) { - flag_->Invalidate(); - flag_ = NULL; - } - } + void Invalidate(); private: mutable WeakReference::Flag* flag_; @@ -135,12 +109,10 @@ class WeakReferenceOwner { // base class gives us a way to access ref_ in a protected fashion. class WeakPtrBase { public: - WeakPtrBase() { - } + WeakPtrBase(); protected: - WeakPtrBase(const WeakReference& ref) : ref_(ref) { - } + WeakPtrBase(const WeakReference& ref); WeakReference ref_; }; diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index a8a9e4e..d24e209 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -36,6 +36,13 @@ using base::TimeDelta; // AutocompleteInput ---------------------------------------------------------- +AutocompleteInput::AutocompleteInput() + : type_(INVALID), + prevent_inline_autocomplete_(false), + prefer_keyword_(false), + synchronous_only_(false) { +} + AutocompleteInput::AutocompleteInput(const std::wstring& text, const std::wstring& desired_tld, bool prevent_inline_autocomplete, @@ -68,6 +75,9 @@ AutocompleteInput::AutocompleteInput(const std::wstring& text, text_.erase(0, 1); } +AutocompleteInput::~AutocompleteInput() { +} + // static std::string AutocompleteInput::TypeToString(Type type) { switch (type) { @@ -407,6 +417,9 @@ AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider, starred(false) { } +AutocompleteMatch::~AutocompleteMatch() { +} + // static std::string AutocompleteMatch::TypeToString(Type type) { const char* strings[NUM_TYPES] = { @@ -561,8 +574,16 @@ void AutocompleteMatch::ValidateClassifications( // static const size_t AutocompleteProvider::kMaxMatches = 3; -AutocompleteProvider::~AutocompleteProvider() { - Stop(); +AutocompleteProvider::ACProviderListener::~ACProviderListener() { +} + +AutocompleteProvider::AutocompleteProvider(ACProviderListener* listener, + Profile* profile, + const char* name) + : profile_(profile), + listener_(listener), + done_(true), + name_(name) { } void AutocompleteProvider::SetProfile(Profile* profile) { @@ -571,6 +592,17 @@ void AutocompleteProvider::SetProfile(Profile* profile) { profile_ = profile; } +void AutocompleteProvider::Stop() { + done_ = true; +} + +void AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) { +} + +AutocompleteProvider::~AutocompleteProvider() { + Stop(); +} + // static bool AutocompleteProvider::HasHTTPScheme(const std::wstring& input) { std::string utf8_input(WideToUTF8(input)); diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h index 9cfb1b4..9ddec43 100644 --- a/chrome/browser/autocomplete/autocomplete.h +++ b/chrome/browser/autocomplete/autocomplete.h @@ -173,18 +173,13 @@ class AutocompleteInput { FORCED_QUERY, // Input forced to be a query by an initial '?' }; - AutocompleteInput() - : type_(INVALID), - prevent_inline_autocomplete_(false), - prefer_keyword_(false), - synchronous_only_(false) { - } - + AutocompleteInput(); AutocompleteInput(const std::wstring& text, const std::wstring& desired_tld, bool prevent_inline_autocomplete, bool prefer_keyword, bool synchronous_only); + ~AutocompleteInput(); // Converts |type| to a string representation. Used in logging. static std::string TypeToString(Type type); @@ -347,6 +342,7 @@ struct AutocompleteMatch { int relevance, bool deletable, Type type); + ~AutocompleteMatch(); // Converts |type| to a string representation. Used in logging. static std::string TypeToString(Type type); @@ -491,17 +487,12 @@ class AutocompleteProvider virtual void OnProviderUpdate(bool updated_matches) = 0; protected: - virtual ~ACProviderListener() {} + virtual ~ACProviderListener(); }; AutocompleteProvider(ACProviderListener* listener, Profile* profile, - const char* name) - : profile_(profile), - listener_(listener), - done_(true), - name_(name) { - } + const char* name); // Invoked when the profile changes. // NOTE: Do not access any previous Profile* at this point as it may have @@ -530,9 +521,7 @@ class AutocompleteProvider // Called when a provider must not make any more callbacks for the current // query. This will be called regardless of whether the provider is already // done. - virtual void Stop() { - done_ = true; - } + virtual void Stop(); // Returns the set of matches for the current query. const ACMatches& matches() const { return matches_; } @@ -548,7 +537,7 @@ class AutocompleteProvider // called for matches the provider marks as deletable. This should only be // called when no query is running. // NOTE: Remember to call OnProviderUpdate() if matches_ is updated. - virtual void DeleteMatch(const AutocompleteMatch& match) {} + virtual void DeleteMatch(const AutocompleteMatch& match); // A suggested upper bound for how many matches a provider should return. // TODO(pkasting): http://b/1111299 , http://b/933133 This should go away once diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 32a4fec..03c8bff 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -30,6 +30,30 @@ #include "third_party/skia/include/core/SkBitmap.h" /////////////////////////////////////////////////////////////////////////////// +// AutocompleteEditController + +AutocompleteEditController::~AutocompleteEditController() { +} + +/////////////////////////////////////////////////////////////////////////////// +// AutocompleteEditModel::State + +AutocompleteEditModel::State::State(bool user_input_in_progress, + const std::wstring& user_text, + const std::wstring& keyword, + bool is_keyword_hint, + KeywordUIState keyword_ui_state) + : user_input_in_progress(user_input_in_progress), + user_text(user_text), + keyword(keyword), + is_keyword_hint(is_keyword_hint), + keyword_ui_state(keyword_ui_state) { +} + +AutocompleteEditModel::State::~State() { +} + +/////////////////////////////////////////////////////////////////////////////// // AutocompleteEditModel AutocompleteEditModel::AutocompleteEditModel( @@ -52,6 +76,9 @@ AutocompleteEditModel::AutocompleteEditModel( profile_(profile) { } +AutocompleteEditModel::~AutocompleteEditModel() { +} + void AutocompleteEditModel::SetPopupModel(AutocompletePopupModel* popup_model) { popup_ = popup_model; registrar_.Add(this, diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h index 5df61b4..1b9d03a 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.h +++ b/chrome/browser/autocomplete/autocomplete_edit.h @@ -61,7 +61,7 @@ class AutocompleteEditController { virtual std::wstring GetTitle() const = 0; protected: - virtual ~AutocompleteEditController() {} + virtual ~AutocompleteEditController(); }; class AutocompleteEditModel : public NotificationObserver { @@ -84,13 +84,8 @@ class AutocompleteEditModel : public NotificationObserver { const std::wstring& user_text, const std::wstring& keyword, bool is_keyword_hint, - KeywordUIState keyword_ui_state) - : user_input_in_progress(user_input_in_progress), - user_text(user_text), - keyword(keyword), - is_keyword_hint(is_keyword_hint), - keyword_ui_state(keyword_ui_state) { - } + KeywordUIState keyword_ui_state); + ~State(); bool user_input_in_progress; const std::wstring user_text; @@ -102,7 +97,7 @@ class AutocompleteEditModel : public NotificationObserver { AutocompleteEditModel(AutocompleteEditView* view, AutocompleteEditController* controller, Profile* profile); - ~AutocompleteEditModel() {} + ~AutocompleteEditModel(); void SetPopupModel(AutocompletePopupModel* popup_model); diff --git a/chrome/browser/automation/automation_resource_routing_delegate.cc b/chrome/browser/automation/automation_resource_routing_delegate.cc new file mode 100644 index 0000000..954b05e --- /dev/null +++ b/chrome/browser/automation/automation_resource_routing_delegate.cc @@ -0,0 +1,19 @@ +// Copyright (c) 2010 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. + +#include "chrome/browser/automation/automation_resource_routing_delegate.h" + +void AutomationResourceRoutingDelegate::RegisterRenderViewHost( + RenderViewHost* render_view_host) { +} + +void AutomationResourceRoutingDelegate::UnregisterRenderViewHost( + RenderViewHost* render_view_host) { +} + +AutomationResourceRoutingDelegate::AutomationResourceRoutingDelegate() { +} + +AutomationResourceRoutingDelegate::~AutomationResourceRoutingDelegate() { +} diff --git a/chrome/browser/automation/automation_resource_routing_delegate.h b/chrome/browser/automation/automation_resource_routing_delegate.h index 63c95de..2438e4d 100644 --- a/chrome/browser/automation/automation_resource_routing_delegate.h +++ b/chrome/browser/automation/automation_resource_routing_delegate.h @@ -15,14 +15,14 @@ class AutomationResourceRoutingDelegate { public: // Call to register |render_view_host| for resource routing automation // by the delegate. - virtual void RegisterRenderViewHost(RenderViewHost* render_view_host) {} + virtual void RegisterRenderViewHost(RenderViewHost* render_view_host); // Call to unregister |render_view_host| from resource routing automation. - virtual void UnregisterRenderViewHost(RenderViewHost* render_view_host) {} + virtual void UnregisterRenderViewHost(RenderViewHost* render_view_host); protected: - AutomationResourceRoutingDelegate() {} - virtual ~AutomationResourceRoutingDelegate() {} + AutomationResourceRoutingDelegate(); + virtual ~AutomationResourceRoutingDelegate(); private: DISALLOW_COPY_AND_ASSIGN(AutomationResourceRoutingDelegate); diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index d04cb5d..c4a25df 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2910,6 +2910,10 @@ void Browser::OnDidGetApplicationInfo(TabContents* tab_contents, pending_web_app_action_ = NONE; } +Browser* Browser::GetBrowser() { + return this; +} + /////////////////////////////////////////////////////////////////////////////// // Browser, SelectFileDialog::Listener implementation: diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 67ba3dd..6825a2c 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -730,7 +730,7 @@ class Browser : public TabStripModelDelegate, virtual bool ShouldAddNavigationsToHistory() const; virtual void OnDidGetApplicationInfo(TabContents* tab_contents, int32 page_id); - virtual Browser* GetBrowser() { return this; } + virtual Browser* GetBrowser(); // Overridden from SelectFileDialog::Listener: virtual void FileSelected(const FilePath& path, int index, void* params); diff --git a/chrome/browser/command_updater.cc b/chrome/browser/command_updater.cc index efb0724..b55b09b 100644 --- a/chrome/browser/command_updater.cc +++ b/chrome/browser/command_updater.cc @@ -10,6 +10,9 @@ #include "base/observer_list.h" #include "base/stl_util-inl.h" +CommandUpdater::CommandUpdaterDelegate::~CommandUpdaterDelegate() { +} + class CommandUpdater::Command { public: bool enabled; @@ -42,6 +45,9 @@ void CommandUpdater::ExecuteCommand(int id) { delegate_->ExecuteCommand(id); } +CommandUpdater::CommandObserver::~CommandObserver() { +} + void CommandUpdater::UpdateCommandEnabled(int id, bool enabled) { Command* command = GetCommand(id, true); if (command->enabled == enabled) diff --git a/chrome/browser/command_updater.h b/chrome/browser/command_updater.h index e6e9557..bd30e84 100644 --- a/chrome/browser/command_updater.h +++ b/chrome/browser/command_updater.h @@ -26,7 +26,7 @@ class CommandUpdater { virtual void ExecuteCommand(int id) = 0; protected: - virtual ~CommandUpdaterDelegate() {} + virtual ~CommandUpdaterDelegate(); }; // Create a CommandUpdater with a CommandUpdaterDelegate to handle execution @@ -55,7 +55,7 @@ class CommandUpdater { virtual void EnabledStateChangedForCommand(int id, bool enabled) = 0; protected: - virtual ~CommandObserver() {} + virtual ~CommandObserver(); }; // Adds an observer to the state of a particular command. If the command does diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc index 437867f..6f5b100 100644 --- a/chrome/browser/extensions/extension_function.cc +++ b/chrome/browser/extensions/extension_function.cc @@ -10,12 +10,30 @@ #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" +ExtensionFunction::ExtensionFunction() + : request_id_(-1), name_(""), has_callback_(false) { +} + +ExtensionFunction::~ExtensionFunction() { +} + Extension* ExtensionFunction::GetExtension() { ExtensionsService* service = profile_->GetExtensionsService(); DCHECK(service); return service->GetExtensionById(extension_id_, false); } +Browser* ExtensionFunction::GetCurrentBrowser() { + return dispatcher()->GetCurrentBrowser(include_incognito_); +} + +AsyncExtensionFunction::AsyncExtensionFunction() + : args_(NULL), bad_message_(false) { +} + +AsyncExtensionFunction::~AsyncExtensionFunction() { +} + void AsyncExtensionFunction::SetArgs(const ListValue* args) { DCHECK(!args_.get()); // Should only be called once. args_.reset(static_cast<ListValue*>(args->DeepCopy())); @@ -29,6 +47,15 @@ const std::string AsyncExtensionFunction::GetResult() { return json; } +const std::string AsyncExtensionFunction::GetError() { + return error_; +} + +void AsyncExtensionFunction::Run() { + if (!RunImpl()) + SendResponse(false); +} + void AsyncExtensionFunction::SendResponse(bool success) { if (!dispatcher()) return; @@ -43,3 +70,13 @@ bool AsyncExtensionFunction::HasOptionalArgument(size_t index) { Value* value; return args_->Get(index, &value) && !value->IsType(Value::TYPE_NULL); } + +SyncExtensionFunction::SyncExtensionFunction() { +} + +SyncExtensionFunction::~SyncExtensionFunction() { +} + +void SyncExtensionFunction::Run() { + SendResponse(RunImpl()); +} diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h index 27bd37c..a13845c 100644 --- a/chrome/browser/extensions/extension_function.h +++ b/chrome/browser/extensions/extension_function.h @@ -37,7 +37,7 @@ class QuotaLimitHeuristic; // knows how to dispatch to. class ExtensionFunction : public base::RefCountedThreadSafe<ExtensionFunction> { public: - ExtensionFunction() : request_id_(-1), name_(""), has_callback_(false) {} + ExtensionFunction(); // Specifies the name of the function. void set_name(const std::string& name) { name_ = name; } @@ -97,7 +97,7 @@ class ExtensionFunction : public base::RefCountedThreadSafe<ExtensionFunction> { protected: friend class base::RefCountedThreadSafe<ExtensionFunction>; - virtual ~ExtensionFunction() {} + virtual ~ExtensionFunction(); // Gets the extension that called this function. This can return NULL for // async functions, for example if the extension is unloaded while the @@ -120,9 +120,7 @@ class ExtensionFunction : public base::RefCountedThreadSafe<ExtensionFunction> { // This method can return NULL if there is no matching browser, which can // happen if only incognito windows are open, or early in startup or shutdown // shutdown when there are no active windows. - Browser* GetCurrentBrowser() { - return dispatcher()->GetCurrentBrowser(include_incognito_); - } + Browser* GetCurrentBrowser(); // The peer to the dispatcher that will service this extension function call. scoped_refptr<ExtensionFunctionDispatcher::Peer> peer_; @@ -160,22 +158,19 @@ class ExtensionFunction : public base::RefCountedThreadSafe<ExtensionFunction> { // parsing JSON (and instead uses custom serialization of Value objects). class AsyncExtensionFunction : public ExtensionFunction { public: - AsyncExtensionFunction() : args_(NULL), bad_message_(false) {} + AsyncExtensionFunction(); virtual void SetArgs(const ListValue* args); virtual const std::string GetResult(); - virtual const std::string GetError() { return error_; } - virtual void Run() { - if (!RunImpl()) - SendResponse(false); - } + virtual const std::string GetError(); + virtual void Run(); // Derived classes should implement this method to do their work and return // success/failure. virtual bool RunImpl() = 0; protected: - virtual ~AsyncExtensionFunction() {} + virtual ~AsyncExtensionFunction(); void SendResponse(bool success); @@ -210,18 +205,16 @@ class AsyncExtensionFunction : public ExtensionFunction { // need to interact with things on the browser UI thread. class SyncExtensionFunction : public AsyncExtensionFunction { public: - SyncExtensionFunction() {} + SyncExtensionFunction(); // Derived classes should implement this method to do their work and return // success/failure. virtual bool RunImpl() = 0; - virtual void Run() { - SendResponse(RunImpl()); - } + virtual void Run(); protected: - virtual ~SyncExtensionFunction() {} + virtual ~SyncExtensionFunction(); private: DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction); diff --git a/chrome/browser/pref_member.cc b/chrome/browser/pref_member.cc index ea41df8..9502022 100644 --- a/chrome/browser/pref_member.cc +++ b/chrome/browser/pref_member.cc @@ -61,6 +61,12 @@ void PrefMemberBase::VerifyValuePrefName() { } // namespace subtle +BooleanPrefMember::BooleanPrefMember() : PrefMember<bool>() { +} + +BooleanPrefMember::~BooleanPrefMember() { +} + void BooleanPrefMember::UpdateValueFromPref() { value_ = prefs()->GetBoolean(pref_name().c_str()); } @@ -69,6 +75,12 @@ void BooleanPrefMember::UpdatePref(const bool& value) { prefs()->SetBoolean(pref_name().c_str(), value); } +IntegerPrefMember::IntegerPrefMember() : PrefMember<int>() { +} + +IntegerPrefMember::~IntegerPrefMember() { +} + void IntegerPrefMember::UpdateValueFromPref() { value_ = prefs()->GetInteger(pref_name().c_str()); } @@ -77,6 +89,12 @@ void IntegerPrefMember::UpdatePref(const int& value) { prefs()->SetInteger(pref_name().c_str(), value); } +RealPrefMember::RealPrefMember() : PrefMember<double>() { +} + +RealPrefMember::~RealPrefMember() { +} + void RealPrefMember::UpdateValueFromPref() { value_ = prefs()->GetReal(pref_name().c_str()); } @@ -85,6 +103,12 @@ void RealPrefMember::UpdatePref(const double& value) { prefs()->SetReal(pref_name().c_str(), value); } +StringPrefMember::StringPrefMember() : PrefMember<std::string>() { +} + +StringPrefMember::~StringPrefMember() { +} + void StringPrefMember::UpdateValueFromPref() { value_ = prefs()->GetString(pref_name().c_str()); } @@ -93,6 +117,12 @@ void StringPrefMember::UpdatePref(const std::string& value) { prefs()->SetString(pref_name().c_str(), value); } +FilePathPrefMember::FilePathPrefMember() : PrefMember<FilePath>() { +} + +FilePathPrefMember::~FilePathPrefMember() { +} + void FilePathPrefMember::UpdateValueFromPref() { value_ = prefs()->GetFilePath(pref_name().c_str()); } diff --git a/chrome/browser/pref_member.h b/chrome/browser/pref_member.h index 2de76ab..1d84b6a 100644 --- a/chrome/browser/pref_member.h +++ b/chrome/browser/pref_member.h @@ -141,8 +141,8 @@ class PrefMember : public subtle::PrefMemberBase { class BooleanPrefMember : public PrefMember<bool> { public: - BooleanPrefMember() : PrefMember<bool>() { } - virtual ~BooleanPrefMember() { } + BooleanPrefMember(); + virtual ~BooleanPrefMember(); protected: virtual void UpdateValueFromPref(); @@ -154,8 +154,8 @@ class BooleanPrefMember : public PrefMember<bool> { class IntegerPrefMember : public PrefMember<int> { public: - IntegerPrefMember() : PrefMember<int>() { } - virtual ~IntegerPrefMember() { } + IntegerPrefMember(); + virtual ~IntegerPrefMember(); protected: virtual void UpdateValueFromPref(); @@ -167,8 +167,8 @@ class IntegerPrefMember : public PrefMember<int> { class RealPrefMember : public PrefMember<double> { public: - RealPrefMember() : PrefMember<double>() { } - virtual ~RealPrefMember() { } + RealPrefMember(); + virtual ~RealPrefMember(); protected: virtual void UpdateValueFromPref(); @@ -180,8 +180,8 @@ class RealPrefMember : public PrefMember<double> { class StringPrefMember : public PrefMember<std::string> { public: - StringPrefMember() : PrefMember<std::string>() { } - virtual ~StringPrefMember() { } + StringPrefMember(); + virtual ~StringPrefMember(); protected: virtual void UpdateValueFromPref(); @@ -193,8 +193,8 @@ class StringPrefMember : public PrefMember<std::string> { class FilePathPrefMember : public PrefMember<FilePath> { public: - FilePathPrefMember() : PrefMember<FilePath>() { } - virtual ~FilePathPrefMember() { } + FilePathPrefMember(); + virtual ~FilePathPrefMember(); protected: virtual void UpdateValueFromPref(); diff --git a/chrome/browser/sessions/tab_restore_service.cc b/chrome/browser/sessions/tab_restore_service.cc index 46f1859..720f3ae 100644 --- a/chrome/browser/sessions/tab_restore_service.cc +++ b/chrome/browser/sessions/tab_restore_service.cc @@ -24,6 +24,10 @@ using base::Time; +// TimeFactory----------------------------------------------------------------- + +TabRestoreService::TimeFactory::~TimeFactory() {} + // Entry ---------------------------------------------------------------------- // ID of the next Entry. @@ -39,6 +43,8 @@ TabRestoreService::Entry::Entry(Type type) type(type), from_last_session(false) {} +TabRestoreService::Entry::~Entry() {} + // TabRestoreService ---------------------------------------------------------- // static @@ -151,9 +157,15 @@ TabRestoreService::Tab::Tab() pinned(false) { } +TabRestoreService::Tab::~Tab() { +} + TabRestoreService::Window::Window() : Entry(WINDOW), selected_tab_index(-1) { } +TabRestoreService::Window::~Window() { +} + TabRestoreService::TabRestoreService(Profile* profile, TabRestoreService::TimeFactory* time_factory) : BaseSessionService(BaseSessionService::TAB_RESTORE, profile, @@ -260,6 +272,10 @@ void TabRestoreService::ClearEntries() { NotifyTabsChanged(); } +const TabRestoreService::Entries& TabRestoreService::entries() const { + return entries_; +} + void TabRestoreService::RestoreMostRecentEntry(Browser* browser) { if (entries_.empty()) return; diff --git a/chrome/browser/sessions/tab_restore_service.h b/chrome/browser/sessions/tab_restore_service.h index bab699a..6b98d15 100644 --- a/chrome/browser/sessions/tab_restore_service.h +++ b/chrome/browser/sessions/tab_restore_service.h @@ -48,7 +48,7 @@ class TabRestoreService : public BaseSessionService { // Interface used to allow the test to provide a custom time. class TimeFactory { public: - virtual ~TimeFactory() {} + virtual ~TimeFactory(); virtual base::Time TimeNow() = 0; }; @@ -61,7 +61,7 @@ class TabRestoreService : public BaseSessionService { struct Entry { Entry(); explicit Entry(Type type); - virtual ~Entry() {} + virtual ~Entry(); // Unique id for this entry. The id is guaranteed to be unique for a // session. @@ -82,6 +82,7 @@ class TabRestoreService : public BaseSessionService { // Represents a previously open tab. struct Tab : public Entry { Tab(); + virtual ~Tab(); bool has_browser() const { return browser_id > 0; } @@ -108,6 +109,7 @@ class TabRestoreService : public BaseSessionService { // Represents a previously open window. struct Window : public Entry { Window(); + virtual ~Window(); // The tabs that comprised the window, in order. std::vector<Tab> tabs; @@ -147,7 +149,7 @@ class TabRestoreService : public BaseSessionService { // Returns the entries, ordered with most recently closed entries at the // front. - virtual const Entries& entries() const { return entries_; } + virtual const Entries& entries() const; // Restores the most recently closed entry. Does nothing if there are no // entries to restore. If the most recently restored entry is a tab, it is diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index d3f2729..66306ae 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -2855,6 +2855,16 @@ void TabContents::BeforeUnloadFiredFromRenderManager( delegate()->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); } +void TabContents::DidStartLoadingFromRenderManager( + RenderViewHost* render_view_host) { + DidStartLoading(); +} + +void TabContents::RenderViewGoneFromRenderManager( + RenderViewHost* render_view_host) { + RenderViewGone(render_view_host); +} + void TabContents::UpdateRenderViewSizeForRenderManager() { // TODO(brettw) this is a hack. See TabContentsView::SizeContents. gfx::Size size = view_->GetContainerSize(); @@ -2866,6 +2876,14 @@ void TabContents::UpdateRenderViewSizeForRenderManager() { view_->SizeContents(size); } +void TabContents::NotifySwappedFromRenderManager() { + NotifySwapped(); +} + +NavigationController& TabContents::GetControllerForRenderManager() { + return controller(); +} + DOMUI* TabContents::CreateDOMUIForRenderManager(const GURL& url) { return DOMUIFactory::CreateDOMUIForURL(this, url); } @@ -3063,6 +3081,14 @@ void TabContents::SetSuppressMessageBoxes(bool suppress_message_boxes) { set_suppress_javascript_messages(suppress_message_boxes); } +TabContents* TabContents::AsTabContents() { + return this; +} + +ExtensionHost* TabContents::AsExtensionHost() { + return NULL; +} + void TabContents::set_encoding(const std::string& encoding) { encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); } diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 304a6d2..e01772f 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -680,8 +680,8 @@ class TabContents : public PageNavigator, bool success, const std::wstring& prompt); virtual void SetSuppressMessageBoxes(bool suppress_message_boxes); - virtual TabContents* AsTabContents() { return this; } - virtual ExtensionHost* AsExtensionHost() { return NULL; } + virtual TabContents* AsTabContents(); + virtual ExtensionHost* AsExtensionHost(); // The BookmarkDragDelegate is used to forward bookmark drag and drop events // to extensions. @@ -983,20 +983,12 @@ class TabContents : public PageNavigator, bool proceed, bool* proceed_to_fire_unload); virtual void DidStartLoadingFromRenderManager( - RenderViewHost* render_view_host) { - DidStartLoading(); - } + RenderViewHost* render_view_host); virtual void RenderViewGoneFromRenderManager( - RenderViewHost* render_view_host) { - RenderViewGone(render_view_host); - } + RenderViewHost* render_view_host); virtual void UpdateRenderViewSizeForRenderManager(); - virtual void NotifySwappedFromRenderManager() { - NotifySwapped(); - } - virtual NavigationController& GetControllerForRenderManager() { - return controller(); - } + virtual void NotifySwappedFromRenderManager(); + virtual NavigationController& GetControllerForRenderManager(); virtual DOMUI* CreateDOMUIForRenderManager(const GURL& url); virtual NavigationEntry* GetLastCommittedNavigationEntryForRenderManager(); diff --git a/chrome/browser/tab_contents/tab_contents_delegate.cc b/chrome/browser/tab_contents/tab_contents_delegate.cc new file mode 100644 index 0000000..539c221 --- /dev/null +++ b/chrome/browser/tab_contents/tab_contents_delegate.cc @@ -0,0 +1,159 @@ +// Copyright (c) 2010 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. + +#include "chrome/browser/tab_contents/tab_contents_delegate.h" + +void TabContentsDelegate::DetachContents(TabContents* source) { +} + +TabContents* TabContentsDelegate::GetConstrainingContents(TabContents* source) { + return source; +} + +void TabContentsDelegate::ContentsMouseEvent( + TabContents* source, const gfx::Point& location, bool motion) { +} + +void TabContentsDelegate::ContentsZoomChange(bool zoom_in) { } + +void TabContentsDelegate::OnContentSettingsChange(TabContents* source) { } + +bool TabContentsDelegate::IsApplication() const { return false; } + +void TabContentsDelegate::ConvertContentsToApplication(TabContents* source) { } + +bool TabContentsDelegate::CanBlur() const { return true; } + +bool TabContentsDelegate::CanReloadContents(TabContents* source) const { + return true; +} + +gfx::Rect TabContentsDelegate::GetRootWindowResizerRect() const { + return gfx::Rect(); +} + +void TabContentsDelegate::ShowHtmlDialog(HtmlDialogUIDelegate* delegate, + gfx::NativeWindow parent_window) { +} + +void TabContentsDelegate::BeforeUnloadFired(TabContents* tab, + bool proceed, + bool* proceed_to_fire_unload) { + *proceed_to_fire_unload = true; +} + +void TabContentsDelegate::ForwardMessageToExternalHost( + const std::string& message, + const std::string& origin, + const std::string& target) { +} + +bool TabContentsDelegate::IsExternalTabContainer() const { return false; } + +void TabContentsDelegate::SetFocusToLocationBar(bool select_all) {} + +void TabContentsDelegate::RenderWidgetShowing() {} + +ExtensionFunctionDispatcher* +TabContentsDelegate::CreateExtensionFunctionDispatcher( + RenderViewHost* render_view_host, + const std::string& extension_id) { + return NULL; +} + +bool TabContentsDelegate::TakeFocus(bool reverse) { + return false; +} + +void TabContentsDelegate::SetTabContentBlocked( + TabContents* contents, bool blocked) { +} + +void TabContentsDelegate::TabContentsFocused(TabContents* tab_content) { +} + +int TabContentsDelegate::GetExtraRenderViewHeight() const { + return 0; +} + +bool TabContentsDelegate::CanDownload(int request_id) { + return true; +} + +void TabContentsDelegate::OnStartDownload(DownloadItem* download) { +} + +bool TabContentsDelegate::HandleContextMenu(const ContextMenuParams& params) { + return false; +} + +bool TabContentsDelegate::ExecuteContextMenuCommand(int command) { + return false; +} + +void TabContentsDelegate::ConfirmAddSearchProvider( + const TemplateURL* template_url, + Profile* profile) { +} + +void TabContentsDelegate::ShowPageInfo(Profile* profile, + const GURL& url, + const NavigationEntry::SSLStatus& ssl, + bool show_history) { +} + +bool TabContentsDelegate::PreHandleKeyboardEvent( + const NativeWebKeyboardEvent& event, + bool* is_keyboard_shortcut) { + return false; +} + +void TabContentsDelegate::HandleKeyboardEvent( + const NativeWebKeyboardEvent& event) { +} + +void TabContentsDelegate::ShowRepostFormWarningDialog( + TabContents* tab_contents) { +} + +void TabContentsDelegate::ShowContentSettingsWindow( + ContentSettingsType content_type) { +} + +bool TabContentsDelegate::OnGoToEntryOffset(int offset) { + return true; +} + +bool TabContentsDelegate::ShouldAddNavigationsToHistory() const { + return true; +} + +void TabContentsDelegate::OnDidGetApplicationInfo(TabContents* tab_contents, + int32 page_id) { +} + +Browser* TabContentsDelegate::GetBrowser() { + return NULL; +} + +gfx::NativeWindow TabContentsDelegate::GetFrameNativeWindow() { + return NULL; +} + +void TabContentsDelegate::TabContentsCreated(TabContents* new_contents) { +} + +bool TabContentsDelegate::infobars_enabled() { + return true; +} + +bool TabContentsDelegate::ShouldEnablePreferredSizeNotifications() { + return false; +} + +void TabContentsDelegate::UpdatePreferredSize(const gfx::Size& pref_size) { +} + +TabContentsDelegate::~TabContentsDelegate() { +} diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index 9f80870..f7eb5e7 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -83,16 +83,14 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate { // Causes the delegate to detach |source| and clean up any internal data // pointing to it. After this call ownership of |source| passes to the // caller, and it is safe to call "source->set_delegate(someone_else);". - virtual void DetachContents(TabContents* source) { } + virtual void DetachContents(TabContents* source); // Called to determine if the TabContents is contained in a popup window. virtual bool IsPopup(TabContents* source) = 0; // If |source| is constrained, returns the tab containing it. Otherwise // returns |source|. - virtual TabContents* GetConstrainingContents(TabContents* source) { - return source; - } + virtual TabContents* GetConstrainingContents(TabContents* source); // Notification that some of our content has changed size as // part of an animation. @@ -108,43 +106,43 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate { // coordinates of the mouse pointer and whether it was a normal motion event // (otherwise, the pointer left the contents area). virtual void ContentsMouseEvent( - TabContents* source, const gfx::Point& location, bool motion) { } + TabContents* source, const gfx::Point& location, bool motion); // Request the delegate to change the zoom level of the current tab. - virtual void ContentsZoomChange(bool zoom_in) { } + virtual void ContentsZoomChange(bool zoom_in); // Notifies the delegate that something has changed about what content the // TabContents is blocking. Interested parties should call // TabContents::IsContentBlocked() to see if something they care about has // changed. - virtual void OnContentSettingsChange(TabContents* source) { } + virtual void OnContentSettingsChange(TabContents* source); // Check whether this contents is inside a window dedicated to running a web // application. - virtual bool IsApplication() const { return false; } + virtual bool IsApplication() const; // Detach the given tab and convert it to a "webapp" view. The tab must be // a TabContents with a valid WebApp set. - virtual void ConvertContentsToApplication(TabContents* source) { } + virtual void ConvertContentsToApplication(TabContents* source); // Whether this tab can be blurred through a javascript obj.blur() // call. ConstrainedWindows shouldn't be able to be blurred. - virtual bool CanBlur() const { return true; } + virtual bool CanBlur() const; // Whether the specified tab can be reloaded. // Reloading can be disabled e. g. for the DevTools window. - virtual bool CanReloadContents(TabContents* source) const { return true; } + virtual bool CanReloadContents(TabContents* source) const; // Return the rect where to display the resize corner, if any, otherwise // an empty rect. - virtual gfx::Rect GetRootWindowResizerRect() const { return gfx::Rect(); } + virtual gfx::Rect GetRootWindowResizerRect() const; // Show a dialog with HTML content. |delegate| contains a pointer to the // delegate who knows how to display the dialog (which file URL and JSON // string input to use during initialization). |parent_window| is the window // that should be parent of the dialog, or NULL for the default. virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, - gfx::NativeWindow parent_window) { } + gfx::NativeWindow parent_window); // Tells us that we've finished firing this tab's beforeunload event. // The proceed bool tells us whether the user chose to proceed closing the @@ -153,82 +151,65 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate { // unload events until all the beforeunload events have fired. virtual void BeforeUnloadFired(TabContents* tab, bool proceed, - bool* proceed_to_fire_unload) { - *proceed_to_fire_unload = true; - } + bool* proceed_to_fire_unload); // Send IPC to external host. Default implementation is do nothing. virtual void ForwardMessageToExternalHost(const std::string& message, const std::string& origin, - const std::string& target) { - } + const std::string& target); // If the delegate is hosting tabs externally. - virtual bool IsExternalTabContainer() const { return false; } + virtual bool IsExternalTabContainer() const; // Sets focus to the location bar or some other place that is appropriate. // This is called when the tab wants to encourage user input, like for the // new tab page. - virtual void SetFocusToLocationBar(bool select_all) {} + virtual void SetFocusToLocationBar(bool select_all); // Called when a popup select is about to be displayed. The delegate can use // this to disable inactive rendering for the frame in the window the select // is opened within if necessary. - virtual void RenderWidgetShowing() {} + virtual void RenderWidgetShowing(); // This is used when the contents is an extension that needs to route // api calls through to the Browser process. virtual ExtensionFunctionDispatcher* CreateExtensionFunctionDispatcher( RenderViewHost* render_view_host, - const std::string& extension_id) { - return NULL; - } + const std::string& extension_id); // This is called when webkit tells us that it is done tabbing through // controls on the page. Provides a way for TabContentsDelegates to handle // this. Returns true if the delegate successfully handled it. - virtual bool TakeFocus(bool reverse) { - return false; - } + virtual bool TakeFocus(bool reverse); // Changes the blocked state of the tab at |index|. TabContents are // considered blocked while displaying a tab modal dialog. During that time // renderer host will ignore any UI interaction within TabContent outside of // the currently displaying dialog. - virtual void SetTabContentBlocked(TabContents* contents, bool blocked) { } + virtual void SetTabContentBlocked(TabContents* contents, bool blocked); // Notification that |tab_contents| has gained focus. - virtual void TabContentsFocused(TabContents* tab_content) { } + virtual void TabContentsFocused(TabContents* tab_content); // Return much extra vertical space should be allotted to the // render view widget during various animations (e.g. infobar closing). // This is used to make painting look smoother. - virtual int GetExtraRenderViewHeight() const { - return 0; - } + virtual int GetExtraRenderViewHeight() const; - virtual bool CanDownload(int request_id) { - return true; - } + virtual bool CanDownload(int request_id); - virtual void OnStartDownload(DownloadItem* download) { - } + virtual void OnStartDownload(DownloadItem* download); // Returns true if the context menu operation was handled by the delegate. - virtual bool HandleContextMenu(const ContextMenuParams& params) { - return false; - } + virtual bool HandleContextMenu(const ContextMenuParams& params); // Returns true if the context menu command was handled - virtual bool ExecuteContextMenuCommand(int command) { - return false; - } + virtual bool ExecuteContextMenuCommand(int command); // Shows a confirmation UI that the specified |template_url| is to be added as // a search engine. virtual void ConfirmAddSearchProvider(const TemplateURL* template_url, - Profile* profile) { - } + Profile* profile); // Shows the page info using the specified information. // |url| is the url of the page/frame the info applies to, |ssl| is the SSL @@ -237,67 +218,61 @@ class TabContentsDelegate : public AutomationResourceRoutingDelegate { virtual void ShowPageInfo(Profile* profile, const GURL& url, const NavigationEntry::SSLStatus& ssl, - bool show_history) { - } + bool show_history); // Allows delegates to handle keyboard events before sending to the renderer. // Returns true if the |event| was handled. Otherwise, if the |event| would be // handled in HandleKeyboardEvent() method as a normal keyboard shortcut, // |*is_keyboard_shortcut| should be set to true. virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, - bool* is_keyboard_shortcut) { - return false; - } + bool* is_keyboard_shortcut); // Allows delegates to handle unhandled keyboard messages coming back from // the renderer. - virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event); // Shows the repost form confirmation dialog box. - virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) {} + virtual void ShowRepostFormWarningDialog(TabContents* tab_contents); // Shows the Content Settings dialog for a given content type. - virtual void ShowContentSettingsWindow(ContentSettingsType content_type) {} + virtual void ShowContentSettingsWindow(ContentSettingsType content_type); // Allows delegate to override navigation to the history entries. // Returns true to allow TabContents to continue with the default processing. - virtual bool OnGoToEntryOffset(int offset) { - return true; - } + virtual bool OnGoToEntryOffset(int offset); // Returns whether this tab contents should add navigations to history. - virtual bool ShouldAddNavigationsToHistory() const { return true; } + virtual bool ShouldAddNavigationsToHistory() const; // Notification when web app info data is available virtual void OnDidGetApplicationInfo(TabContents* tab_contents, - int32 page_id) { - } + int32 page_id); // Returns the browser in which the tab contents is being displayed. - virtual Browser* GetBrowser() { return NULL; } + virtual Browser* GetBrowser(); // Returns the native window framing the view containing the tab contents. - virtual gfx::NativeWindow GetFrameNativeWindow() { return NULL; } + virtual gfx::NativeWindow GetFrameNativeWindow(); // Notifies the delegate about the creation of a new TabContents. This // typically happens when popups are created. - virtual void TabContentsCreated(TabContents* new_contents) {} + virtual void TabContentsCreated(TabContents* new_contents); // Returns whether infobars are enabled. Overrideable by child classes. - virtual bool infobars_enabled() { return true; } + virtual bool infobars_enabled(); // Whether the renderer should report its preferred size when it changes by // calling UpdatePreferredSize(). // Note that this is set when the RenderViewHost is created and cannot be // changed after that. - virtual bool ShouldEnablePreferredSizeNotifications() { return false; } + virtual bool ShouldEnablePreferredSizeNotifications(); // Notification that the preferred size of the contents has changed. // Only called if ShouldEnablePreferredSizeNotifications() returns true. - virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} + virtual void UpdatePreferredSize(const gfx::Size& pref_size); protected: - ~TabContentsDelegate() {} + ~TabContentsDelegate(); }; #endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_DELEGATE_H_ diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index ef4677b..711e00e 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -46,6 +46,66 @@ bool ShouldForgetOpenersForTransition(PageTransition::Type transition) { } // namespace /////////////////////////////////////////////////////////////////////////////// +// TabStripModelObserver, public: + +void TabStripModelObserver::TabInsertedAt(TabContents* contents, + int index, + bool foreground) { +} + +void TabStripModelObserver::TabClosingAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabDetachedAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabDeselectedAt(TabContents* contents, int index) { +} + +void TabStripModelObserver::TabSelectedAt(TabContents* old_contents, + TabContents* new_contents, + int index, + bool user_gesture) { +} + +void TabStripModelObserver::TabMoved(TabContents* contents, + int from_index, + int to_index) { +} + +void TabStripModelObserver::TabChangedAt(TabContents* contents, int index, + TabChangeType change_type) { +} + +void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, + TabContents* new_contents, + int index) { +} + +void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabMiniStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabBlockedStateChanged(TabContents* contents, + int index) { +} + +void TabStripModelObserver::TabStripEmpty() {} + +void TabStripModelObserver::TabStripModelDeleted() {} + +/////////////////////////////////////////////////////////////////////////////// +// TabStripModelDelegate, public: + +bool TabStripModelDelegate::CanCloseTab() const { + return true; +} + +/////////////////////////////////////////////////////////////////////////////// // TabStripModel, public: TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile) diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 4c1ad28..c00dbff 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -59,21 +59,21 @@ class TabStripModelObserver { // (selected). virtual void TabInsertedAt(TabContents* contents, int index, - bool foreground) {} + bool foreground); // The specified TabContents at |index| is being closed (and eventually // destroyed). - virtual void TabClosingAt(TabContents* contents, int index) {} + virtual void TabClosingAt(TabContents* contents, int index); // The specified TabContents at |index| is being detached, perhaps to be // inserted in another TabStripModel. The implementer should take whatever // action is necessary to deal with the TabContents no longer being present. - virtual void TabDetachedAt(TabContents* contents, int index) {} + virtual void TabDetachedAt(TabContents* contents, int index); // The selected TabContents is about to change from |old_contents| at |index|. // This gives observers a chance to prepare for an impending switch before it // happens. - virtual void TabDeselectedAt(TabContents* contents, int index) {} + virtual void TabDeselectedAt(TabContents* contents, int index); // The selected TabContents changed from |old_contents| to |new_contents| at // |index|. |user_gesture| specifies whether or not this was done by a user @@ -82,12 +82,12 @@ class TabStripModelObserver { virtual void TabSelectedAt(TabContents* old_contents, TabContents* new_contents, int index, - bool user_gesture) {} + bool user_gesture); // The specified TabContents at |from_index| was moved to |to_index|. virtual void TabMoved(TabContents* contents, int from_index, - int to_index) {} + int to_index); // The specified TabContents at |index| changed in some way. |contents| may // be an entirely different object and the old value is no longer available @@ -95,40 +95,40 @@ class TabStripModelObserver { // // See TabChangeType for a description of |change_type|. virtual void TabChangedAt(TabContents* contents, int index, - TabChangeType change_type) {} + TabChangeType change_type); // The tab contents was replaced at the specified index. This is invoked when // a tab becomes phantom. See description of phantom tabs in class description // of TabStripModel for details. virtual void TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, int index) {} + TabContents* new_contents, int index); // Invoked when the pinned state of a tab changes. This is not invoked if the // tab ends up moving as a result of the mini state changing. // See note in TabMiniStateChanged as to how this relates to // TabMiniStateChanged. - virtual void TabPinnedStateChanged(TabContents* contents, int index) {} + virtual void TabPinnedStateChanged(TabContents* contents, int index); // Invoked if the mini state of a tab changes. This is not invoked if the // tab ends up moving as a result of the mini state changing. // NOTE: this is sent when the pinned state of a non-app tab changes and is // sent in addition to TabPinnedStateChanged. UI code typically need not care // about TabPinnedStateChanged, but instead this. - virtual void TabMiniStateChanged(TabContents* contents, int index) {} + virtual void TabMiniStateChanged(TabContents* contents, int index); // Invoked when the blocked state of a tab changes. // NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal // window. - virtual void TabBlockedStateChanged(TabContents* contents, int index) {} + virtual void TabBlockedStateChanged(TabContents* contents, int index); // The TabStripModel now no longer has any phantom tabs. The implementer may // use this as a trigger to try and close the window containing the // TabStripModel, for example... - virtual void TabStripEmpty() {} + virtual void TabStripEmpty(); // Sent when the tabstrip model is about to be deleted and any reference held // must be dropped. - virtual void TabStripModelDeleted() {} + virtual void TabStripModelDeleted(); }; /////////////////////////////////////////////////////////////////////////////// @@ -229,9 +229,7 @@ class TabStripModelDelegate { virtual void BookmarkAllTabs() = 0; // Returns true if any of the tabs can be closed. - virtual bool CanCloseTab() const { - return true; - } + virtual bool CanCloseTab() const; // Returns true if the vertical tabstrip presentation should be used. virtual bool UseVerticalTabs() const = 0; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index c53d6be..e5438f3 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -206,6 +206,8 @@ 'browser/automation/automation_provider_observers.h', 'browser/automation/automation_resource_message_filter.cc', 'browser/automation/automation_resource_message_filter.h', + 'browser/automation/automation_resource_routing_delegate.cc', + 'browser/automation/automation_resource_routing_delegate.h', 'browser/automation/automation_resource_tracker.cc', 'browser/automation/automation_resource_tracker.h', 'browser/automation/automation_tab_tracker.h', @@ -2359,6 +2361,7 @@ 'browser/tab_contents/security_style.h', 'browser/tab_contents/tab_contents.cc', 'browser/tab_contents/tab_contents.h', + 'browser/tab_contents/tab_contents_delegate.cc', 'browser/tab_contents/tab_contents_delegate.h', 'browser/tab_contents/tab_contents_view.cc', 'browser/tab_contents/tab_contents_view.h', diff --git a/net/base/filter.cc b/net/base/filter.cc index 4a7b8a6..c72e00e 100644 --- a/net/base/filter.cc +++ b/net/base/filter.cc @@ -36,6 +36,9 @@ const char kTextHtml[] = "text/html"; } // namespace +FilterContext::~FilterContext() { +} + Filter* Filter::Factory(const std::vector<FilterType>& filter_types, const FilterContext& filter_context) { DCHECK_GT(filter_context.GetInputStreamBufferSize(), 0); diff --git a/net/base/filter.h b/net/base/filter.h index cf32d2f..acc0e7e 100644 --- a/net/base/filter.h +++ b/net/base/filter.h @@ -62,7 +62,7 @@ class FilterContext { SDCH_EXPERIMENT_HOLDBACK, }; - virtual ~FilterContext() {} + virtual ~FilterContext(); // What mime type was specified in the header for this data? // Only makes senses for some types of contexts, and returns false diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc index 4e737ba..7ce60c3 100644 --- a/net/url_request/url_request_job.cc +++ b/net/url_request/url_request_job.cc @@ -54,6 +54,13 @@ URLRequestJob::~URLRequestJob() { g_url_request_job_tracker.RemoveJob(this); } +void URLRequestJob::SetUpload(net::UploadData* upload) { +} + +void URLRequestJob::SetExtraRequestHeaders( + const net::HttpRequestHeaders& headers) { +} + void URLRequestJob::Kill() { // Make sure the request is notified that we are done. We assume that the // request took care of setting its error status before calling Kill. @@ -65,10 +72,6 @@ void URLRequestJob::DetachRequest() { request_ = NULL; } -bool URLRequestJob::IsDownload() const { - return (load_flags_ & net::LOAD_IS_DOWNLOAD) != 0; -} - void URLRequestJob::SetupFilter() { std::vector<Filter::FilterType> encoding_types; if (GetContentEncodings(&encoding_types)) { @@ -92,6 +95,14 @@ bool URLRequestJob::IsRedirectResponse(GURL* location, return true; } +bool URLRequestJob::IsSafeRedirect(const GURL& location) { + return true; +} + +bool URLRequestJob::NeedsAuth() { + return false; +} + void URLRequestJob::GetAuthChallengeInfo( scoped_refptr<net::AuthChallengeInfo>* auth_info) { // This will only be called if NeedsAuth() returns true, in which @@ -148,6 +159,10 @@ int64 URLRequestJob::GetByteReadCount() const { return filter_input_byte_count_; } +bool URLRequestJob::GetMimeType(std::string* mime_type) const { + return false; +} + bool URLRequestJob::GetURL(GURL* gurl) const { if (!request_) return false; @@ -161,6 +176,18 @@ base::Time URLRequestJob::GetRequestTime() const { return request_->request_time(); }; +bool URLRequestJob::IsCachedContent() const { + return false; +} + +int URLRequestJob::GetResponseCode() const { + return -1; +} + +int URLRequestJob::GetInputStreamBufferSize() const { + return kFilterBufSize; +} + // This function calls ReadData to get stream data. If a filter exists, passes // the data to the attached filter. Then returns the output from filter back to // the caller. @@ -199,6 +226,38 @@ void URLRequestJob::StopCaching() { // Nothing to do here. } +net::LoadState URLRequestJob::GetLoadState() const { + return net::LOAD_STATE_IDLE; +} + +uint64 URLRequestJob::GetUploadProgress() const { + return 0; +} + +bool URLRequestJob::GetCharset(std::string* charset) { + return false; +} + +void URLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) { +} + +bool URLRequestJob::GetResponseCookies(std::vector<std::string>* cookies) { + return false; +} + +bool URLRequestJob::GetContentEncodings( + std::vector<Filter::FilterType>* encoding_types) { + return false; +} + +bool URLRequestJob::IsDownload() const { + return (load_flags_ & net::LOAD_IS_DOWNLOAD) != 0; +} + +bool URLRequestJob::IsSdchResponse() const { + return false; +} + bool URLRequestJob::ReadRawDataForFilter(int* bytes_read) { bool rv = false; diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h index c0916e8..617bbf9 100644 --- a/net/url_request/url_request_job.h +++ b/net/url_request/url_request_job.h @@ -51,10 +51,10 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, // Sets the upload data, most requests have no upload data, so this is a NOP. // Job types supporting upload data will override this. - virtual void SetUpload(net::UploadData* upload) { } + virtual void SetUpload(net::UploadData* upload); // Sets extra request headers for Job types that support request headers. - virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) {} + virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); // If any error occurs while starting the Job, NotifyStartError should be // called. @@ -98,26 +98,24 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, virtual void StopCaching(); // Called to fetch the current load state for the job. - virtual net::LoadState GetLoadState() const { return net::LOAD_STATE_IDLE; } + virtual net::LoadState GetLoadState() const; // Called to get the upload progress in bytes. - virtual uint64 GetUploadProgress() const { return 0; } + virtual uint64 GetUploadProgress() const; // Called to fetch the charset for this request. Only makes sense for some // types of requests. Returns true on success. Calling this on a type that // doesn't have a charset will return false. - virtual bool GetCharset(std::string* charset) { return false; } + virtual bool GetCharset(std::string* charset); // Called to get response info. - virtual void GetResponseInfo(net::HttpResponseInfo* info) {} + virtual void GetResponseInfo(net::HttpResponseInfo* info); // Returns the cookie values included in the response, if applicable. // Returns true if applicable. // NOTE: This removes the cookies from the job, so it will only return // useful results once per job. - virtual bool GetResponseCookies(std::vector<std::string>* cookies) { - return false; - } + virtual bool GetResponseCookies(std::vector<std::string>* cookies); // Called to fetch the encoding types for this request. Only makes sense for // some types of requests. Returns true on success. Calling this on a request @@ -130,16 +128,14 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, // in the reverse order (in the above example, ungzip first, and then sdch // expand). virtual bool GetContentEncodings( - std::vector<Filter::FilterType>* encoding_types) { - return false; - } + std::vector<Filter::FilterType>* encoding_types); // Find out if this is a download. virtual bool IsDownload() const; // Find out if this is a response to a request that advertised an SDCH // dictionary. Only makes sense for some types of requests. - virtual bool IsSdchResponse() const { return false; } + virtual bool IsSdchResponse() const; // Called to setup stream filter for this request. An example of filter is // content encoding/decoding. @@ -162,14 +158,12 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, // location. This may be used to implement protocol-specific restrictions. // If this function returns false, then the URLRequest will fail reporting // net::ERR_UNSAFE_REDIRECT. - virtual bool IsSafeRedirect(const GURL& location) { - return true; - } + virtual bool IsSafeRedirect(const GURL& location); // Called to determine if this response is asking for authentication. Only // makes sense for some types of requests. The caller is responsible for // obtaining the credentials passing them to SetAuth. - virtual bool NeedsAuth() { return false; } + virtual bool NeedsAuth(); // Fills the authentication info with the server's response. virtual void GetAuthChallengeInfo( @@ -212,13 +206,13 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, // FilterContext methods: // These methods are not applicable to all connections. - virtual bool GetMimeType(std::string* mime_type) const { return false; } + virtual bool GetMimeType(std::string* mime_type) const; virtual bool GetURL(GURL* gurl) const; virtual base::Time GetRequestTime() const; - virtual bool IsCachedContent() const { return false; } + virtual bool IsCachedContent() const; virtual int64 GetByteReadCount() const; - virtual int GetResponseCode() const { return -1; } - virtual int GetInputStreamBufferSize() const { return kFilterBufSize; } + virtual int GetResponseCode() const; + virtual int GetInputStreamBufferSize() const; virtual void RecordPacketStats(StatisticSelector statistic) const; protected: |