diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/appcache/appcache_dispatcher_host.cc | 196 | ||||
-rw-r--r-- | chrome/common/appcache/appcache_dispatcher_host.h | 78 | ||||
-rw-r--r-- | chrome/common/appcache/appcache_frontend_proxy.cc | 22 | ||||
-rw-r--r-- | chrome/common/appcache/appcache_frontend_proxy.h | 31 | ||||
-rw-r--r-- | chrome/common/appcache/chrome_appcache_service.cc | 97 | ||||
-rw-r--r-- | chrome/common/appcache/chrome_appcache_service.h | 54 | ||||
-rw-r--r-- | chrome/common/extensions/extension_l10n_util.cc | 12 | ||||
-rw-r--r-- | chrome/common/extensions/extension_l10n_util.h | 6 | ||||
-rw-r--r-- | chrome/common/extensions/extension_l10n_util_unittest.cc | 97 | ||||
-rw-r--r-- | chrome/common/platform_util.h | 3 | ||||
-rw-r--r-- | chrome/common/platform_util_linux.cc | 6 | ||||
-rw-r--r-- | chrome/common/platform_util_mac.mm | 18 | ||||
-rw-r--r-- | chrome/common/platform_util_win.cc | 7 |
13 files changed, 0 insertions, 627 deletions
diff --git a/chrome/common/appcache/appcache_dispatcher_host.cc b/chrome/common/appcache/appcache_dispatcher_host.cc deleted file mode 100644 index e2f1d11..0000000 --- a/chrome/common/appcache/appcache_dispatcher_host.cc +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/appcache/appcache_dispatcher_host.h" - -#include "base/callback.h" -#include "chrome/browser/renderer_host/browser_render_process_host.h" -// TODO(eroman): uh oh, depending on stuff outside of common/ -#include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/common/appcache/chrome_appcache_service.h" -#include "chrome/common/render_messages.h" - -AppCacheDispatcherHost::AppCacheDispatcherHost( - URLRequestContextGetter* request_context_getter) - : request_context_getter_(request_context_getter), - process_handle_(0) { - DCHECK(request_context_getter_.get()); -} - -void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender, - int process_id, base::ProcessHandle process_handle) { - DCHECK(sender); - DCHECK(process_handle && !process_handle_); - DCHECK(request_context_getter_.get()); - - process_handle_ = process_handle; - - // Get the AppCacheService (it can only be accessed from IO thread). - URLRequestContext* context = request_context_getter_->GetURLRequestContext(); - appcache_service_ = - static_cast<ChromeURLRequestContext*>(context)->appcache_service(); - request_context_getter_ = NULL; - - frontend_proxy_.set_sender(sender); - if (appcache_service_.get()) { - backend_impl_.Initialize( - appcache_service_.get(), &frontend_proxy_, process_id); - get_status_callback_.reset( - NewCallback(this, &AppCacheDispatcherHost::GetStatusCallback)); - start_update_callback_.reset( - NewCallback(this, &AppCacheDispatcherHost::StartUpdateCallback)); - swap_cache_callback_.reset( - NewCallback(this, &AppCacheDispatcherHost::SwapCacheCallback)); - } -} - -bool AppCacheDispatcherHost::OnMessageReceived(const IPC::Message& msg, - bool *msg_ok) { - DCHECK(process_handle_); - *msg_ok = true; - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(AppCacheDispatcherHost, msg, *msg_ok) - IPC_MESSAGE_HANDLER(AppCacheMsg_RegisterHost, OnRegisterHost); - IPC_MESSAGE_HANDLER(AppCacheMsg_UnregisterHost, OnUnregisterHost); - IPC_MESSAGE_HANDLER(AppCacheMsg_SelectCache, OnSelectCache); - IPC_MESSAGE_HANDLER(AppCacheMsg_MarkAsForeignEntry, OnMarkAsForeignEntry); - IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_GetStatus, OnGetStatus); - IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_StartUpdate, OnStartUpdate); - IPC_MESSAGE_HANDLER_DELAY_REPLY(AppCacheMsg_SwapCache, OnSwapCache); - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP_EX() - return handled; -} - -void AppCacheDispatcherHost::OnRegisterHost(int host_id) { - if (appcache_service_.get()) { - if (!backend_impl_.RegisterHost(host_id)) { - ReceivedBadMessage(AppCacheMsg_RegisterHost::ID); - } - } -} - -void AppCacheDispatcherHost::OnUnregisterHost(int host_id) { - if (appcache_service_.get()) { - if (!backend_impl_.UnregisterHost(host_id)) { - ReceivedBadMessage(AppCacheMsg_UnregisterHost::ID); - } - } -} - -void AppCacheDispatcherHost::OnSelectCache( - int host_id, const GURL& document_url, - int64 cache_document_was_loaded_from, - const GURL& opt_manifest_url) { - if (appcache_service_.get()) { - if (!backend_impl_.SelectCache(host_id, document_url, - cache_document_was_loaded_from, - opt_manifest_url)) { - ReceivedBadMessage(AppCacheMsg_SelectCache::ID); - } - } else { - frontend_proxy_.OnCacheSelected( - host_id, appcache::kNoCacheId, appcache::UNCACHED); - } -} - -void AppCacheDispatcherHost::OnMarkAsForeignEntry( - int host_id, const GURL& document_url, - int64 cache_document_was_loaded_from) { - if (appcache_service_.get()) { - if (!backend_impl_.MarkAsForeignEntry(host_id, document_url, - cache_document_was_loaded_from)) { - ReceivedBadMessage(AppCacheMsg_MarkAsForeignEntry::ID); - } - } -} - -void AppCacheDispatcherHost::OnGetStatus(int host_id, - IPC::Message* reply_msg) { - if (pending_reply_msg_.get()) { - ReceivedBadMessage(AppCacheMsg_GetStatus::ID); - delete reply_msg; - return; - } - - pending_reply_msg_.reset(reply_msg); - if (appcache_service_.get()) { - if (!backend_impl_.GetStatusWithCallback( - host_id, get_status_callback_.get(), reply_msg)) { - ReceivedBadMessage(AppCacheMsg_GetStatus::ID); - } - return; - } - - GetStatusCallback(appcache::UNCACHED, reply_msg); -} - -void AppCacheDispatcherHost::OnStartUpdate(int host_id, - IPC::Message* reply_msg) { - if (pending_reply_msg_.get()) { - ReceivedBadMessage(AppCacheMsg_StartUpdate::ID); - delete reply_msg; - return; - } - - pending_reply_msg_.reset(reply_msg); - if (appcache_service_.get()) { - if (!backend_impl_.StartUpdateWithCallback( - host_id, start_update_callback_.get(), reply_msg)) { - ReceivedBadMessage(AppCacheMsg_StartUpdate::ID); - } - return; - } - - StartUpdateCallback(false, reply_msg); -} - -void AppCacheDispatcherHost::OnSwapCache(int host_id, - IPC::Message* reply_msg) { - if (pending_reply_msg_.get()) { - ReceivedBadMessage(AppCacheMsg_SwapCache::ID); - delete reply_msg; - return; - } - - pending_reply_msg_.reset(reply_msg); - if (appcache_service_.get()) { - if (!backend_impl_.SwapCacheWithCallback( - host_id, swap_cache_callback_.get(), reply_msg)) { - ReceivedBadMessage(AppCacheMsg_SwapCache::ID); - } - return; - } - - SwapCacheCallback(false, reply_msg); -} - -void AppCacheDispatcherHost::GetStatusCallback( - appcache::Status status, void* param) { - IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); - DCHECK(reply_msg == pending_reply_msg_.get()); - AppCacheMsg_GetStatus::WriteReplyParams(reply_msg, status); - frontend_proxy_.sender()->Send(pending_reply_msg_.release()); -} - -void AppCacheDispatcherHost::StartUpdateCallback(bool result, void* param) { - IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); - DCHECK(reply_msg == pending_reply_msg_.get()); - AppCacheMsg_StartUpdate::WriteReplyParams(reply_msg, result); - frontend_proxy_.sender()->Send(pending_reply_msg_.release()); -} - -void AppCacheDispatcherHost::SwapCacheCallback(bool result, void* param) { - IPC::Message* reply_msg = reinterpret_cast<IPC::Message*>(param); - DCHECK(reply_msg == pending_reply_msg_.get()); - AppCacheMsg_SwapCache::WriteReplyParams(reply_msg, result); - frontend_proxy_.sender()->Send(pending_reply_msg_.release()); -} - -void AppCacheDispatcherHost::ReceivedBadMessage(uint32 msg_type) { - // TODO(michaeln): Consider gathering UMA stats - // http://code.google.com/p/chromium/issues/detail?id=24634 - BrowserRenderProcessHost::BadMessageTerminateProcess( - msg_type, process_handle_); -} diff --git a/chrome/common/appcache/appcache_dispatcher_host.h b/chrome/common/appcache/appcache_dispatcher_host.h deleted file mode 100644 index 9ad46fb..0000000 --- a/chrome/common/appcache/appcache_dispatcher_host.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ -#define CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ - -#include <vector> - -#include "base/process.h" -#include "base/ref_counted.h" -#include "base/scoped_ptr.h" -#include "chrome/common/appcache/appcache_frontend_proxy.h" -#include "ipc/ipc_message.h" -#include "webkit/appcache/appcache_backend_impl.h" - -class ChromeAppCacheService; -class URLRequestContextGetter; - -// Handles appcache related messages sent to the main browser process from -// its child processes. There is a distinct host for each child process. -// Messages are handled on the IO thread. The ResourceMessageFilter creates -// an instance and delegates calls to it. -class AppCacheDispatcherHost { - public: - explicit AppCacheDispatcherHost( - URLRequestContextGetter* request_context_getter); - - void Initialize(IPC::Message::Sender* sender, int process_id, - base::ProcessHandle process_handle); - bool OnMessageReceived(const IPC::Message& msg, bool* msg_is_ok); - - int process_id() const { return backend_impl_.process_id(); } - - // Note: needed to satisfy ipc message dispatching macros. - bool Send(IPC::Message* msg) { - return frontend_proxy_.sender()->Send(msg); - } - - private: - // Ipc message handlers - void OnRegisterHost(int host_id); - void OnUnregisterHost(int host_id); - void OnSelectCache(int host_id, const GURL& document_url, - int64 cache_document_was_loaded_from, - const GURL& opt_manifest_url); - void OnMarkAsForeignEntry(int host_id, const GURL& document_url, - int64 cache_document_was_loaded_from); - void OnGetStatus(int host_id, IPC::Message* reply_msg); - void OnStartUpdate(int host_id, IPC::Message* reply_msg); - void OnSwapCache(int host_id, IPC::Message* reply_msg); - - void GetStatusCallback(appcache::Status status, void* param); - void StartUpdateCallback(bool result, void* param); - void SwapCacheCallback(bool result, void* param); - - void ReceivedBadMessage(uint32 msg_type); - - AppCacheFrontendProxy frontend_proxy_; - appcache::AppCacheBackendImpl backend_impl_; - - // Temporary until Initialize() can be called from the IO thread, - // which will extract the AppCacheService from the URLRequestContext. - scoped_refptr<URLRequestContextGetter> request_context_getter_; - - // This is only valid once Initialize() has been called. - scoped_refptr<ChromeAppCacheService> appcache_service_; - - scoped_ptr<appcache::GetStatusCallback> get_status_callback_; - scoped_ptr<appcache::StartUpdateCallback> start_update_callback_; - scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_; - base::ProcessHandle process_handle_; - scoped_ptr<IPC::Message> pending_reply_msg_; - - DISALLOW_COPY_AND_ASSIGN(AppCacheDispatcherHost); -}; - -#endif // CHROME_COMMON_APPCACHE_APPCACHE_DISPATCHER_HOST_H_ diff --git a/chrome/common/appcache/appcache_frontend_proxy.cc b/chrome/common/appcache/appcache_frontend_proxy.cc deleted file mode 100644 index 08c8510..0000000 --- a/chrome/common/appcache/appcache_frontend_proxy.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/appcache/appcache_frontend_proxy.h" - -#include "chrome/common/render_messages.h" - -void AppCacheFrontendProxy::OnCacheSelected(int host_id, int64 cache_id , - appcache::Status status) { - sender_->Send(new AppCacheMsg_CacheSelected(host_id, cache_id, status)); -} - -void AppCacheFrontendProxy::OnStatusChanged(const std::vector<int>& host_ids, - appcache::Status status) { - sender_->Send(new AppCacheMsg_StatusChanged(host_ids, status)); -} - -void AppCacheFrontendProxy::OnEventRaised(const std::vector<int>& host_ids, - appcache::EventID event_id) { - sender_->Send(new AppCacheMsg_EventRaised(host_ids, event_id)); -} diff --git a/chrome/common/appcache/appcache_frontend_proxy.h b/chrome/common/appcache/appcache_frontend_proxy.h deleted file mode 100644 index b18f9bb..0000000 --- a/chrome/common/appcache/appcache_frontend_proxy.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_APPCACHE_APPCACHE_FRONTEND_PROXY_H_ -#define CHROME_COMMON_APPCACHE_APPCACHE_FRONTEND_PROXY_H_ - -#include <vector> -#include "ipc/ipc_message.h" -#include "webkit/appcache/appcache_interfaces.h" - -// Sends appcache related messages to a child process. -class AppCacheFrontendProxy : public appcache::AppCacheFrontend { - public: - AppCacheFrontendProxy() : sender_(NULL) {} - void set_sender(IPC::Message::Sender* sender) { sender_ = sender; } - IPC::Message::Sender* sender() const { return sender_; } - - // AppCacheFrontend methods - virtual void OnCacheSelected(int host_id, int64 cache_id , - appcache::Status); - virtual void OnStatusChanged(const std::vector<int>& host_ids, - appcache::Status status); - virtual void OnEventRaised(const std::vector<int>& host_ids, - appcache::EventID event_id); - - private: - IPC::Message::Sender* sender_; -}; - -#endif // CHROME_COMMON_APPCACHE_APPCACHE_FRONTEND_PROXY_H_ diff --git a/chrome/common/appcache/chrome_appcache_service.cc b/chrome/common/appcache/chrome_appcache_service.cc deleted file mode 100644 index 5fdb17f..0000000 --- a/chrome/common/appcache/chrome_appcache_service.cc +++ /dev/null @@ -1,97 +0,0 @@ -// 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/common/appcache/chrome_appcache_service.h" - -#include "base/file_path.h" -#include "base/file_util.h" -#include "chrome/browser/chrome_thread.h" -#include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/notification_service.h" -#include "net/base/net_errors.h" -#include "webkit/appcache/appcache_thread.h" - -static bool has_initialized_thread_ids; - -ChromeAppCacheService::ChromeAppCacheService( - const FilePath& profile_path, - ChromeURLRequestContext* request_context) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); - DCHECK(request_context); - - if (!has_initialized_thread_ids) { - has_initialized_thread_ids = true; - appcache::AppCacheThread::InitIDs(ChromeThread::DB, ChromeThread::IO); - } - - host_contents_settings_map_ = request_context->host_content_settings_map(); - registrar_.Add( - this, NotificationType::PURGE_MEMORY, NotificationService::AllSources()); - - // Init our base class. - Initialize(request_context->is_off_the_record() ? - FilePath() : profile_path.Append(chrome::kAppCacheDirname)); - set_request_context(request_context); - set_appcache_policy(this); -} - -ChromeAppCacheService::~ChromeAppCacheService() { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); -} - -// static -void ChromeAppCacheService::ClearLocalState(const FilePath& profile_path) { - file_util::Delete(profile_path.Append(chrome::kAppCacheDirname), true); -} - -bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url) { - ContentSetting setting = host_contents_settings_map_->GetContentSetting( - manifest_url, CONTENT_SETTINGS_TYPE_COOKIES); - DCHECK(setting != CONTENT_SETTING_DEFAULT); - return setting == CONTENT_SETTING_ALLOW || - setting == CONTENT_SETTING_ASK; // we don't prompt for read access -} - -int ChromeAppCacheService::CanCreateAppCache( - const GURL& manifest_url, net::CompletionCallback* callback) { - ContentSetting setting = host_contents_settings_map_->GetContentSetting( - manifest_url, CONTENT_SETTINGS_TYPE_COOKIES); - DCHECK(setting != CONTENT_SETTING_DEFAULT); - if (setting == CONTENT_SETTING_ASK) { - // TODO(michaeln): prompt the user, for now we block - setting = CONTENT_SETTING_BLOCK; - } - return (setting != CONTENT_SETTING_BLOCK) ? net::OK : net::ERR_ACCESS_DENIED; -} - -void ChromeAppCacheService::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == NotificationType::PURGE_MEMORY); - PurgeMemory(); -} - -static ChromeThread::ID ToChromeThreadID(int id) { - DCHECK(has_initialized_thread_ids); - DCHECK(id == ChromeThread::DB || id == ChromeThread::IO); - return static_cast<ChromeThread::ID>(id); -} - -namespace appcache { - -// An impl of AppCacheThread we need to provide to the appcache lib. - -bool AppCacheThread::PostTask( - int id, - const tracked_objects::Location& from_here, - Task* task) { - return ChromeThread::PostTask(ToChromeThreadID(id), from_here, task); -} - -bool AppCacheThread::CurrentlyOn(int id) { - return ChromeThread::CurrentlyOn(ToChromeThreadID(id)); -} - -} // namespace appcache diff --git a/chrome/common/appcache/chrome_appcache_service.h b/chrome/common/appcache/chrome_appcache_service.h deleted file mode 100644 index fd36a05..0000000 --- a/chrome/common/appcache/chrome_appcache_service.h +++ /dev/null @@ -1,54 +0,0 @@ -// 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. - -#ifndef CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_ -#define CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_ - -#include "base/ref_counted.h" -#include "chrome/browser/host_content_settings_map.h" -#include "chrome/common/notification_registrar.h" -#include "webkit/appcache/appcache_policy.h" -#include "webkit/appcache/appcache_service.h" - -class ChromeURLRequestContext; -class FilePath; - -// An AppCacheService subclass used by the chrome. There is an instance -// associated with each Profile. This derivation adds refcounting semantics -// since a profile has multiple URLRequestContexts which refer to the same -// object, and those URLRequestContexts are refcounted independently of the -// owning profile. -// -// All methods, including the ctor and dtor, are expected to be called on -// the IO thread. -class ChromeAppCacheService - : public base::RefCounted<ChromeAppCacheService>, - public appcache::AppCacheService, - public appcache::AppCachePolicy, - public NotificationObserver { - public: - ChromeAppCacheService(const FilePath& profile_path, - ChromeURLRequestContext* request_context); - - static void ClearLocalState(const FilePath& profile_path); - - private: - friend class base::RefCounted<ChromeAppCacheService>; - virtual ~ChromeAppCacheService(); - - // AppCachePolicy overrides - virtual bool CanLoadAppCache(const GURL& manifest_url); - virtual int CanCreateAppCache(const GURL& manifest_url, - net::CompletionCallback* callback); - - // NotificationObserver override - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - scoped_refptr<HostContentSettingsMap> host_contents_settings_map_; - NotificationRegistrar registrar_; -}; - -#endif // CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_ diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index 3f329fb..e7406b2 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -14,7 +14,6 @@ #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_file_util.h" @@ -296,15 +295,4 @@ ExtensionMessageBundle* LoadMessageCatalogs( return ExtensionMessageBundle::Create(catalogs, error); } -void ApplyMessageFilterPolicy(const GURL& url, - const ResourceType::Type& resource_type, - ResourceDispatcherHostRequestInfo* request_info) { - // Apply filter only to chrome extension css files that don't have - // security filter already set. - if (url.SchemeIs(chrome::kExtensionScheme) && - request_info->filter_policy() == FilterPolicy::DONT_FILTER && - resource_type == ResourceType::STYLESHEET) - request_info->set_filter_policy(FilterPolicy::FILTER_EXTENSION_MESSAGES); -} - } // namespace extension_l10n_util diff --git a/chrome/common/extensions/extension_l10n_util.h b/chrome/common/extensions/extension_l10n_util.h index a63bfdb..886db24 100644 --- a/chrome/common/extensions/extension_l10n_util.h +++ b/chrome/common/extensions/extension_l10n_util.h @@ -95,12 +95,6 @@ ExtensionMessageBundle* LoadMessageCatalogs( const std::set<std::string>& valid_locales, std::string* error); -// Applies FilterPolicy::FILTER_EXTENSION_MESSAGES to all text/css requests -// that have "chrome-extension://" scheme. -void ApplyMessageFilterPolicy(const GURL& url, - const ResourceType::Type& resource_type, - ResourceDispatcherHostRequestInfo* request_info); - } // namespace extension_l10n_util #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ diff --git a/chrome/common/extensions/extension_l10n_util_unittest.cc b/chrome/common/extensions/extension_l10n_util_unittest.cc index 3fb2f7a..c2211a7 100644 --- a/chrome/common/extensions/extension_l10n_util_unittest.cc +++ b/chrome/common/extensions/extension_l10n_util_unittest.cc @@ -10,8 +10,6 @@ #include "base/scoped_ptr.h" #include "base/scoped_temp_dir.h" #include "base/values.h" -#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" -#include "chrome/browser/renderer_host/resource_handler.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" @@ -382,99 +380,4 @@ TEST(ExtensionL10nUtil, ShouldRelocalizeManifestDifferentCurrentLocale) { EXPECT_TRUE(extension_l10n_util::ShouldRelocalizeManifest(info)); } -class DummyResourceHandler : public ResourceHandler { - public: - DummyResourceHandler() {} - - bool OnRequestRedirected(int request_id, const GURL& url, - ResourceResponse* response, bool* defer) { - return true; - } - - bool OnResponseStarted(int request_id, ResourceResponse* response) { - return true; - } - - bool OnWillRead( - int request_id, net::IOBuffer** buf, int* buf_size, int min_size) { - return true; - } - - bool OnReadCompleted(int request_id, int* bytes_read) { return true; } - - bool OnResponseCompleted( - int request_id, const URLRequestStatus& status, const std::string& info) { - return true; - } - - private: - DISALLOW_COPY_AND_ASSIGN(DummyResourceHandler); -}; - -class ApplyMessageFilterPolicyTest : public testing::Test { - protected: - void SetUp() { - url_.reset(new GURL( - "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/popup.html")); - resource_type_ = ResourceType::STYLESHEET; - resource_handler_.reset(new DummyResourceHandler()); - request_info_.reset(CreateNewResourceRequestInfo()); - } - - ResourceDispatcherHostRequestInfo* CreateNewResourceRequestInfo() { - return new ResourceDispatcherHostRequestInfo( - resource_handler_.get(), ChildProcessInfo::RENDER_PROCESS, 0, 0, 0, - "not important", "not important", - ResourceType::STYLESHEET, 0U, false, false, -1, -1); - } - - scoped_ptr<GURL> url_; - ResourceType::Type resource_type_; - scoped_ptr<DummyResourceHandler> resource_handler_; - scoped_ptr<ResourceDispatcherHostRequestInfo> request_info_; -}; - -TEST_F(ApplyMessageFilterPolicyTest, WrongScheme) { - url_.reset(new GURL("html://behllobkkfkfnphdnhnkndlbkcpglgmj/popup.html")); - extension_l10n_util::ApplyMessageFilterPolicy( - *url_, resource_type_, request_info_.get()); - - EXPECT_EQ(FilterPolicy::DONT_FILTER, request_info_->filter_policy()); -} - -TEST_F(ApplyMessageFilterPolicyTest, GoodScheme) { - extension_l10n_util::ApplyMessageFilterPolicy( - *url_, resource_type_, request_info_.get()); - - EXPECT_EQ(FilterPolicy::FILTER_EXTENSION_MESSAGES, - request_info_->filter_policy()); -} - -TEST_F(ApplyMessageFilterPolicyTest, GoodSchemeWithSecurityFilter) { - request_info_->set_filter_policy(FilterPolicy::FILTER_ALL_EXCEPT_IMAGES); - extension_l10n_util::ApplyMessageFilterPolicy( - *url_, resource_type_, request_info_.get()); - - EXPECT_EQ(FilterPolicy::FILTER_ALL_EXCEPT_IMAGES, - request_info_->filter_policy()); -} - -TEST_F(ApplyMessageFilterPolicyTest, GoodSchemeWrongResourceType) { - resource_type_ = ResourceType::MAIN_FRAME; - extension_l10n_util::ApplyMessageFilterPolicy( - *url_, resource_type_, request_info_.get()); - - EXPECT_EQ(FilterPolicy::DONT_FILTER, request_info_->filter_policy()); -} - -TEST_F(ApplyMessageFilterPolicyTest, WrongSchemeResourceAndFilter) { - url_.reset(new GURL("html://behllobkkfkfnphdnhnkndlbkcpglgmj/popup.html")); - resource_type_ = ResourceType::MEDIA; - request_info_->set_filter_policy(FilterPolicy::FILTER_ALL); - extension_l10n_util::ApplyMessageFilterPolicy( - *url_, resource_type_, request_info_.get()); - - EXPECT_EQ(FilterPolicy::FILTER_ALL, request_info_->filter_policy()); -} - } // namespace diff --git a/chrome/common/platform_util.h b/chrome/common/platform_util.h index 99b322e..a2f5d31 100644 --- a/chrome/common/platform_util.h +++ b/chrome/common/platform_util.h @@ -26,9 +26,6 @@ void OpenExternal(const GURL& url); // Get the top level window for the native view. This can return NULL. gfx::NativeWindow GetTopLevel(gfx::NativeView view); -// Get the title of the window. -string16 GetWindowTitle(gfx::NativeWindow window); - // Returns true if |window| is the foreground top level window. bool IsWindowActive(gfx::NativeWindow window); diff --git a/chrome/common/platform_util_linux.cc b/chrome/common/platform_util_linux.cc index 5baaefc..816fca7 100644 --- a/chrome/common/platform_util_linux.cc +++ b/chrome/common/platform_util_linux.cc @@ -9,7 +9,6 @@ #include "base/file_util.h" #include "base/process_util.h" #include "base/string_util.h" -#include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/common/gtk_util.h" #include "chrome/common/process_watcher.h" #include "googleurl/src/gurl.h" @@ -73,11 +72,6 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view) { return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL; } -string16 GetWindowTitle(gfx::NativeWindow window) { - const gchar* title = gtk_window_get_title(window); - return UTF8ToUTF16(title); -} - bool IsWindowActive(gfx::NativeWindow window) { return gtk_window_is_active(window); } diff --git a/chrome/common/platform_util_mac.mm b/chrome/common/platform_util_mac.mm index 3b72ef3..8753f35 100644 --- a/chrome/common/platform_util_mac.mm +++ b/chrome/common/platform_util_mac.mm @@ -12,7 +12,6 @@ #include "base/logging.h" #include "base/mac_util.h" #include "base/sys_string_conversions.h" -#include "chrome/browser/cocoa/tab_window_controller.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" @@ -45,23 +44,6 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view) { return [view window]; } -string16 GetWindowTitle(gfx::NativeWindow window) { - NSString* title = nil; - if ([[window delegate] isKindOfClass:[TabWindowController class]]) { - TabWindowController* delegate = - reinterpret_cast<TabWindowController*>([window delegate]); - title = [delegate selectedTabTitle]; - } else { - title = [window title]; - } - // If we don't yet have a title, use "Untitled". - if (![title length]) - return WideToUTF16(l10n_util::GetString( - IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); - - return base::SysNSStringToUTF16(title); -} - bool IsWindowActive(gfx::NativeWindow window) { return [window isKeyWindow] || [window isMainWindow]; } diff --git a/chrome/common/platform_util_win.cc b/chrome/common/platform_util_win.cc index bcf3a58..5553c81 100644 --- a/chrome/common/platform_util_win.cc +++ b/chrome/common/platform_util_win.cc @@ -136,13 +136,6 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view) { return GetAncestor(view, GA_ROOT); } -string16 GetWindowTitle(gfx::NativeWindow window_handle) { - std::wstring result; - int length = ::GetWindowTextLength(window_handle) + 1; - ::GetWindowText(window_handle, WriteInto(&result, length), length); - return WideToUTF16(result); -} - bool IsWindowActive(gfx::NativeWindow window) { return ::GetForegroundWindow() == window; } |