Commit f92003d2 authored by limasdf@gmail.com's avatar limasdf@gmail.com

Use EventRouter::Get instead of ExtensionSystem::Get(browser_context)->event_router()

from c/b/e/api

and remove unwanted extensions:: prefix.

R=rdevlin.cronin@chromium.org
BUG=362672

Review URL: https://codereview.chromium.org/280853004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271590 0039d316-1c4b-4281-b951-d872f2087c98
parent 3d4d9337
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/common/extensions/api/automation_internal.h" #include "chrome/common/extensions/api/automation_internal.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
#include "extensions/browser/extension_system.h"
#include "ui/accessibility/ax_enums.h" #include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
...@@ -113,10 +112,10 @@ void PopulateNodeData(const ui::AXNodeData& node_data, ...@@ -113,10 +112,10 @@ void PopulateNodeData(const ui::AXNodeData& node_data,
void DispatchEventInternal(content::BrowserContext* context, void DispatchEventInternal(content::BrowserContext* context,
const std::string& event_name, const std::string& event_name,
scoped_ptr<base::ListValue> args) { scoped_ptr<base::ListValue> args) {
if (context && ExtensionSystem::Get(context)->event_router()) { if (context && EventRouter::Get(context)) {
scoped_ptr<Event> event(new Event(event_name, args.Pass())); scoped_ptr<Event> event(new Event(event_name, args.Pass()));
event->restrict_to_browser_context = context; event->restrict_to_browser_context = context;
ExtensionSystem::Get(context)->event_router()->BroadcastEvent(event.Pass()); EventRouter::Get(context)->BroadcastEvent(event.Pass());
} }
} }
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "chrome/browser/download/download_shelf.h" #include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/download/download_stats.h" #include "chrome/browser/download/download_stats.h"
#include "chrome/browser/download/drag_download_item.h" #include "chrome/browser/download/drag_download_item.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_warning_service.h" #include "chrome/browser/extensions/extension_warning_service.h"
#include "chrome/browser/icon_loader.h" #include "chrome/browser/icon_loader.h"
#include "chrome/browser/icon_manager.h" #include "chrome/browser/icon_manager.h"
...@@ -63,8 +62,8 @@ ...@@ -63,8 +62,8 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
#include "extensions/browser/extension_function_dispatcher.h" #include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "net/base/filename_util.h" #include "net/base/filename_util.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/http/http_util.h" #include "net/http/http_util.h"
...@@ -116,7 +115,7 @@ namespace extensions { ...@@ -116,7 +115,7 @@ namespace extensions {
namespace { namespace {
namespace downloads = extensions::api::downloads; namespace downloads = api::downloads;
// Default icon size for getFileIcon() in pixels. // Default icon size for getFileIcon() in pixels.
const int kDefaultIconSize = 32; const int kDefaultIconSize = 32;
...@@ -280,10 +279,9 @@ scoped_ptr<base::DictionaryValue> DownloadItemToJSON( ...@@ -280,10 +279,9 @@ scoped_ptr<base::DictionaryValue> DownloadItemToJSON(
// Lookup the extension's current name() in case the user changed their // Lookup the extension's current name() in case the user changed their
// language. This won't work if the extension was uninstalled, so the name // language. This won't work if the extension was uninstalled, so the name
// might be the wrong language. // might be the wrong language.
bool include_disabled = true; const Extension* extension =
const extensions::Extension* extension = extensions::ExtensionSystem::Get( ExtensionRegistry::Get(profile)
profile)->extension_service()->GetExtensionById( ->GetExtensionById(by_ext->id(), ExtensionRegistry::EVERYTHING);
by_ext->id(), include_disabled);
if (extension) if (extension)
json->SetString(kByExtensionNameKey, extension->name()); json->SetString(kByExtensionNameKey, extension->name());
} }
...@@ -737,7 +735,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data { ...@@ -737,7 +735,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
// later take precedence over previous extensions. // later take precedence over previous extensions.
if (!filename.empty() || if (!filename.empty() ||
(conflict_action != downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY)) { (conflict_action != downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY)) {
extensions::ExtensionWarningSet warnings; ExtensionWarningSet warnings;
std::string winner_extension_id; std::string winner_extension_id;
ExtensionDownloadsEventRouter::DetermineFilenameInternal( ExtensionDownloadsEventRouter::DetermineFilenameInternal(
filename, filename,
...@@ -751,8 +749,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data { ...@@ -751,8 +749,7 @@ class ExtensionDownloadsEventRouterData : public base::SupportsUserData::Data {
&determined_conflict_action_, &determined_conflict_action_,
&warnings); &warnings);
if (!warnings.empty()) if (!warnings.empty())
extensions::ExtensionWarningService::NotifyWarningsOnUI( ExtensionWarningService::NotifyWarningsOnUI(profile, warnings);
profile, warnings);
if (winner_extension_id == determiners_[index].extension_id) if (winner_extension_id == determiners_[index].extension_id)
determiner_ = determiners_[index]; determiner_ = determiners_[index];
} }
...@@ -926,11 +923,11 @@ void OnDeterminingFilenameWillDispatchCallback( ...@@ -926,11 +923,11 @@ void OnDeterminingFilenameWillDispatchCallback(
bool* any_determiners, bool* any_determiners,
ExtensionDownloadsEventRouterData* data, ExtensionDownloadsEventRouterData* data,
content::BrowserContext* context, content::BrowserContext* context,
const extensions::Extension* extension, const Extension* extension,
base::ListValue* event_args) { base::ListValue* event_args) {
*any_determiners = true; *any_determiners = true;
base::Time installed = base::Time installed =
extensions::ExtensionPrefs::Get(context)->GetInstallTime(extension->id()); ExtensionPrefs::Get(context)->GetInstallTime(extension->id());
data->AddPendingDeterminer(extension->id(), installed); data->AddPendingDeterminer(extension->id(), installed);
} }
...@@ -1387,10 +1384,11 @@ bool DownloadsOpenFunction::RunSync() { ...@@ -1387,10 +1384,11 @@ bool DownloadsOpenFunction::RunSync() {
if (InvalidId(download_item, &error_) || if (InvalidId(download_item, &error_) ||
Fault(!user_gesture(), errors::kUserGesture, &error_) || Fault(!user_gesture(), errors::kUserGesture, &error_) ||
Fault(download_item->GetState() != DownloadItem::COMPLETE, Fault(download_item->GetState() != DownloadItem::COMPLETE,
errors::kNotComplete, &error_) || errors::kNotComplete,
Fault(!GetExtension()->HasAPIPermission( &error_) ||
extensions::APIPermission::kDownloadsOpen), Fault(!GetExtension()->HasAPIPermission(APIPermission::kDownloadsOpen),
errors::kOpenPermission, &error_)) errors::kOpenPermission,
&error_))
return false; return false;
download_item->OpenDownload(); download_item->OpenDownload();
RecordApiFunctions(DOWNLOADS_FUNCTION_OPEN); RecordApiFunctions(DOWNLOADS_FUNCTION_OPEN);
...@@ -1433,8 +1431,7 @@ bool DownloadsSetShelfEnabledFunction::RunSync() { ...@@ -1433,8 +1431,7 @@ bool DownloadsSetShelfEnabledFunction::RunSync() {
scoped_ptr<downloads::SetShelfEnabled::Params> params( scoped_ptr<downloads::SetShelfEnabled::Params> params(
downloads::SetShelfEnabled::Params::Create(*args_)); downloads::SetShelfEnabled::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get()); EXTENSION_FUNCTION_VALIDATE(params.get());
if (!GetExtension()->HasAPIPermission( if (!GetExtension()->HasAPIPermission(APIPermission::kDownloadsShelf)) {
extensions::APIPermission::kDownloadsShelf)) {
error_ = download_extension_errors::kShelfPermission; error_ = download_extension_errors::kShelfPermission;
return false; return false;
} }
...@@ -1549,9 +1546,8 @@ ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( ...@@ -1549,9 +1546,8 @@ ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter(
extension_registry_observer_(this) { extension_registry_observer_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(profile_); DCHECK(profile_);
extension_registry_observer_.Add( extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
extensions::ExtensionRegistry::Get(profile_)); EventRouter* router = EventRouter::Get(profile_);
extensions::EventRouter* router = extensions::EventRouter::Get(profile_);
if (router) if (router)
router->RegisterObserver(this, router->RegisterObserver(this,
downloads::OnDeterminingFilename::kEventName); downloads::OnDeterminingFilename::kEventName);
...@@ -1559,7 +1555,7 @@ ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter( ...@@ -1559,7 +1555,7 @@ ExtensionDownloadsEventRouter::ExtensionDownloadsEventRouter(
ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() { ExtensionDownloadsEventRouter::~ExtensionDownloadsEventRouter() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
extensions::EventRouter* router = extensions::EventRouter::Get(profile_); EventRouter* router = EventRouter::Get(profile_);
if (router) if (router)
router->UnregisterObserver(this); router->UnregisterObserver(this);
} }
...@@ -1570,10 +1566,10 @@ void ExtensionDownloadsEventRouter:: ...@@ -1570,10 +1566,10 @@ void ExtensionDownloadsEventRouter::
SetDetermineFilenameTimeoutSecondsForTesting(s); SetDetermineFilenameTimeoutSecondsForTesting(s);
} }
void ExtensionDownloadsEventRouter::SetShelfEnabled( void ExtensionDownloadsEventRouter::SetShelfEnabled(const Extension* extension,
const extensions::Extension* extension, bool enabled) { bool enabled) {
std::set<const extensions::Extension*>::iterator iter = std::set<const Extension*>::iterator iter =
shelf_disabling_extensions_.find(extension); shelf_disabling_extensions_.find(extension);
if (iter == shelf_disabling_extensions_.end()) { if (iter == shelf_disabling_extensions_.end()) {
if (!enabled) if (!enabled)
shelf_disabling_extensions_.insert(extension); shelf_disabling_extensions_.insert(extension);
...@@ -1657,9 +1653,8 @@ void ExtensionDownloadsEventRouter::DetermineFilenameInternal( ...@@ -1657,9 +1653,8 @@ void ExtensionDownloadsEventRouter::DetermineFilenameInternal(
const base::Time& incumbent_install_time, const base::Time& incumbent_install_time,
std::string* winner_extension_id, std::string* winner_extension_id,
base::FilePath* determined_filename, base::FilePath* determined_filename,
downloads::FilenameConflictAction* downloads::FilenameConflictAction* determined_conflict_action,
determined_conflict_action, ExtensionWarningSet* warnings) {
extensions::ExtensionWarningSet* warnings) {
DCHECK(!filename.empty() || DCHECK(!filename.empty() ||
(conflict_action != downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY)); (conflict_action != downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY));
DCHECK(!suggesting_extension_id.empty()); DCHECK(!suggesting_extension_id.empty());
...@@ -1673,22 +1668,20 @@ void ExtensionDownloadsEventRouter::DetermineFilenameInternal( ...@@ -1673,22 +1668,20 @@ void ExtensionDownloadsEventRouter::DetermineFilenameInternal(
if (suggesting_install_time < incumbent_install_time) { if (suggesting_install_time < incumbent_install_time) {
*winner_extension_id = incumbent_extension_id; *winner_extension_id = incumbent_extension_id;
warnings->insert( warnings->insert(ExtensionWarning::CreateDownloadFilenameConflictWarning(
extensions::ExtensionWarning::CreateDownloadFilenameConflictWarning( suggesting_extension_id,
suggesting_extension_id, incumbent_extension_id,
incumbent_extension_id, filename,
filename, *determined_filename));
*determined_filename));
return; return;
} }
*winner_extension_id = suggesting_extension_id; *winner_extension_id = suggesting_extension_id;
warnings->insert( warnings->insert(ExtensionWarning::CreateDownloadFilenameConflictWarning(
extensions::ExtensionWarning::CreateDownloadFilenameConflictWarning( incumbent_extension_id,
incumbent_extension_id, suggesting_extension_id,
suggesting_extension_id, *determined_filename,
*determined_filename, filename));
filename));
*determined_filename = filename; *determined_filename = filename;
*determined_conflict_action = conflict_action; *determined_conflict_action = conflict_action;
} }
...@@ -1737,15 +1730,14 @@ bool ExtensionDownloadsEventRouter::DetermineFilename( ...@@ -1737,15 +1730,14 @@ bool ExtensionDownloadsEventRouter::DetermineFilename(
} }
void ExtensionDownloadsEventRouter::OnListenerRemoved( void ExtensionDownloadsEventRouter::OnListenerRemoved(
const extensions::EventListenerInfo& details) { const EventListenerInfo& details) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DownloadManager* manager = notifier_.GetManager(); DownloadManager* manager = notifier_.GetManager();
if (!manager) if (!manager)
return; return;
bool determiner_removed = ( bool determiner_removed = (
details.event_name == downloads::OnDeterminingFilename::kEventName); details.event_name == downloads::OnDeterminingFilename::kEventName);
extensions::EventRouter* router = extensions::ExtensionSystem::Get(profile_)-> EventRouter* router = EventRouter::Get(profile_);
event_router();
bool any_listeners = bool any_listeners =
router->HasEventListener(downloads::OnChanged::kEventName) || router->HasEventListener(downloads::OnChanged::kEventName) ||
router->HasEventListener(downloads::OnDeterminingFilename::kEventName); router->HasEventListener(downloads::OnDeterminingFilename::kEventName);
...@@ -1784,8 +1776,7 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated( ...@@ -1784,8 +1776,7 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated(
if (download_item->IsTemporary()) if (download_item->IsTemporary())
return; return;
extensions::EventRouter* router = extensions::ExtensionSystem::Get(profile_)-> EventRouter* router = EventRouter::Get(profile_);
event_router();
// Avoid allocating a bunch of memory in DownloadItemToJSON if it isn't going // Avoid allocating a bunch of memory in DownloadItemToJSON if it isn't going
// to be used. // to be used.
if (!router || if (!router ||
...@@ -1799,7 +1790,7 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated( ...@@ -1799,7 +1790,7 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated(
DownloadItemToJSON(download_item, profile_)); DownloadItemToJSON(download_item, profile_));
DispatchEvent(downloads::OnCreated::kEventName, DispatchEvent(downloads::OnCreated::kEventName,
true, true,
extensions::Event::WillDispatchCallback(), Event::WillDispatchCallback(),
json_item->DeepCopy()); json_item->DeepCopy());
if (!ExtensionDownloadsEventRouterData::Get(download_item) && if (!ExtensionDownloadsEventRouterData::Get(download_item) &&
(router->HasEventListener(downloads::OnChanged::kEventName) || (router->HasEventListener(downloads::OnChanged::kEventName) ||
...@@ -1812,8 +1803,7 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated( ...@@ -1812,8 +1803,7 @@ void ExtensionDownloadsEventRouter::OnDownloadCreated(
void ExtensionDownloadsEventRouter::OnDownloadUpdated( void ExtensionDownloadsEventRouter::OnDownloadUpdated(
DownloadManager* manager, DownloadItem* download_item) { DownloadManager* manager, DownloadItem* download_item) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
extensions::EventRouter* router = extensions::ExtensionSystem::Get(profile_)-> EventRouter* router = EventRouter::Get(profile_);
event_router();
ExtensionDownloadsEventRouterData* data = ExtensionDownloadsEventRouterData* data =
ExtensionDownloadsEventRouterData::Get(download_item); ExtensionDownloadsEventRouterData::Get(download_item);
if (download_item->IsTemporary() || if (download_item->IsTemporary() ||
...@@ -1872,7 +1862,7 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated( ...@@ -1872,7 +1862,7 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
if (changed) { if (changed) {
DispatchEvent(downloads::OnChanged::kEventName, DispatchEvent(downloads::OnChanged::kEventName,
true, true,
extensions::Event::WillDispatchCallback(), Event::WillDispatchCallback(),
delta.release()); delta.release());
data->OnChangedFired(); data->OnChangedFired();
} }
...@@ -1884,27 +1874,26 @@ void ExtensionDownloadsEventRouter::OnDownloadRemoved( ...@@ -1884,27 +1874,26 @@ void ExtensionDownloadsEventRouter::OnDownloadRemoved(
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (download_item->IsTemporary()) if (download_item->IsTemporary())
return; return;
DispatchEvent(downloads::OnErased::kEventName, DispatchEvent(
true, downloads::OnErased::kEventName,
extensions::Event::WillDispatchCallback(), true,
new base::FundamentalValue( Event::WillDispatchCallback(),
static_cast<int>(download_item->GetId()))); new base::FundamentalValue(static_cast<int>(download_item->GetId())));
} }
void ExtensionDownloadsEventRouter::DispatchEvent( void ExtensionDownloadsEventRouter::DispatchEvent(
const std::string& event_name, const std::string& event_name,
bool include_incognito, bool include_incognito,
const extensions::Event::WillDispatchCallback& will_dispatch_callback, const Event::WillDispatchCallback& will_dispatch_callback,
base::Value* arg) { base::Value* arg) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!extensions::EventRouter::Get(profile_)) if (!EventRouter::Get(profile_))
return; return;
scoped_ptr<base::ListValue> args(new base::ListValue()); scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(arg); args->Append(arg);
std::string json_args; std::string json_args;
base::JSONWriter::Write(args.get(), &json_args); base::JSONWriter::Write(args.get(), &json_args);
scoped_ptr<extensions::Event> event(new extensions::Event( scoped_ptr<Event> event(new Event(event_name, args.Pass()));
event_name, args.Pass()));
// The downloads system wants to share on-record events with off-record // The downloads system wants to share on-record events with off-record
// extension renderers even in incognito_split_mode because that's how // extension renderers even in incognito_split_mode because that's how
// chrome://downloads works. The "restrict_to_profile" mechanism does not // chrome://downloads works. The "restrict_to_profile" mechanism does not
...@@ -1913,7 +1902,7 @@ void ExtensionDownloadsEventRouter::DispatchEvent( ...@@ -1913,7 +1902,7 @@ void ExtensionDownloadsEventRouter::DispatchEvent(
event->restrict_to_browser_context = event->restrict_to_browser_context =
(include_incognito && !profile_->IsOffTheRecord()) ? NULL : profile_; (include_incognito && !profile_->IsOffTheRecord()) ? NULL : profile_;
event->will_dispatch_callback = will_dispatch_callback; event->will_dispatch_callback = will_dispatch_callback;
extensions::EventRouter::Get(profile_)->BroadcastEvent(event.Pass()); EventRouter::Get(profile_)->BroadcastEvent(event.Pass());
DownloadsNotificationSource notification_source; DownloadsNotificationSource notification_source;
notification_source.event_name = event_name; notification_source.event_name = event_name;
notification_source.profile = profile_; notification_source.profile = profile_;
...@@ -1927,10 +1916,10 @@ void ExtensionDownloadsEventRouter::DispatchEvent( ...@@ -1927,10 +1916,10 @@ void ExtensionDownloadsEventRouter::DispatchEvent(
void ExtensionDownloadsEventRouter::OnExtensionUnloaded( void ExtensionDownloadsEventRouter::OnExtensionUnloaded(
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
const extensions::Extension* extension, const Extension* extension,
extensions::UnloadedExtensionInfo::Reason reason) { UnloadedExtensionInfo::Reason reason) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::set<const extensions::Extension*>::iterator iter = std::set<const Extension*>::iterator iter =
shelf_disabling_extensions_.find(extension); shelf_disabling_extensions_.find(extension);
if (iter != shelf_disabling_extensions_.end()) if (iter != shelf_disabling_extensions_.end())
shelf_disabling_extensions_.erase(iter); shelf_disabling_extensions_.erase(iter);
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "chrome/browser/extensions/browser_action_test_util.h" #include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/history/download_row.h" #include "chrome/browser/history/download_row.h"
#include "chrome/browser/net/url_request_mock_util.h" #include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
#include "content/public/common/page_transition_types.h" #include "content/public/common/page_transition_types.h"
#include "content/public/test/download_test_observer.h" #include "content/public/test/download_test_observer.h"
#include "content/test/net/url_request_slow_download_job.h" #include "content/test/net/url_request_slow_download_job.h"
#include "extensions/browser/event_router.h"
#include "net/base/data_url.h" #include "net/base/data_url.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
...@@ -63,9 +63,8 @@ using content::URLRequestSlowDownloadJob; ...@@ -63,9 +63,8 @@ using content::URLRequestSlowDownloadJob;
namespace errors = download_extension_errors; namespace errors = download_extension_errors;
namespace downloads = extensions::api::downloads;
namespace extensions { namespace extensions {
namespace downloads = api::downloads;
namespace { namespace {
...@@ -276,15 +275,15 @@ class DownloadExtensionTest : public ExtensionApiTest { ...@@ -276,15 +275,15 @@ class DownloadExtensionTest : public ExtensionApiTest {
current_browser(), current_browser(),
extension_->GetResourceURL("empty.html"), extension_->GetResourceURL("empty.html"),
content::PAGE_TRANSITION_LINK); content::PAGE_TRANSITION_LINK);
extensions::EventRouter::Get(current_browser()->profile()) EventRouter::Get(current_browser()->profile())
->AddEventListener(downloads::OnCreated::kEventName, ->AddEventListener(downloads::OnCreated::kEventName,
tab->GetRenderProcessHost(), tab->GetRenderProcessHost(),
GetExtensionId()); GetExtensionId());
extensions::EventRouter::Get(current_browser()->profile()) EventRouter::Get(current_browser()->profile())
->AddEventListener(downloads::OnChanged::kEventName, ->AddEventListener(downloads::OnChanged::kEventName,
tab->GetRenderProcessHost(), tab->GetRenderProcessHost(),
GetExtensionId()); GetExtensionId());
extensions::EventRouter::Get(current_browser()->profile()) EventRouter::Get(current_browser()->profile())
->AddEventListener(downloads::OnErased::kEventName, ->AddEventListener(downloads::OnErased::kEventName,
tab->GetRenderProcessHost(), tab->GetRenderProcessHost(),
GetExtensionId()); GetExtensionId());
...@@ -297,8 +296,7 @@ class DownloadExtensionTest : public ExtensionApiTest { ...@@ -297,8 +296,7 @@ class DownloadExtensionTest : public ExtensionApiTest {
current_browser(), current_browser(),
extension_->GetResourceURL("empty.html"), extension_->GetResourceURL("empty.html"),
content::PAGE_TRANSITION_LINK); content::PAGE_TRANSITION_LINK);
extensions::ExtensionSystem::Get(current_browser()->profile()) EventRouter::Get(current_browser()->profile())
->event_router()
->AddEventListener(downloads::OnDeterminingFilename::kEventName, ->AddEventListener(downloads::OnDeterminingFilename::kEventName,
tab->GetRenderProcessHost(), tab->GetRenderProcessHost(),
GetExtensionId()); GetExtensionId());
...@@ -306,11 +304,8 @@ class DownloadExtensionTest : public ExtensionApiTest { ...@@ -306,11 +304,8 @@ class DownloadExtensionTest : public ExtensionApiTest {
} }
void RemoveFilenameDeterminer(content::RenderProcessHost* host) { void RemoveFilenameDeterminer(content::RenderProcessHost* host) {
extensions::ExtensionSystem::Get(current_browser()->profile()) EventRouter::Get(current_browser()->profile())->RemoveEventListener(
->event_router() downloads::OnDeterminingFilename::kEventName, host, GetExtensionId());
->RemoveEventListener(downloads::OnDeterminingFilename::kEventName,
host,
GetExtensionId());
} }
Browser* current_browser() { return current_browser_; } Browser* current_browser() { return current_browser_; }
...@@ -603,7 +598,7 @@ class DownloadExtensionTest : public ExtensionApiTest { ...@@ -603,7 +598,7 @@ class DownloadExtensionTest : public ExtensionApiTest {
} }
base::ScopedTempDir downloads_directory_; base::ScopedTempDir downloads_directory_;
const extensions::Extension* extension_; const Extension* extension_;
Browser* incognito_browser_; Browser* incognito_browser_;
Browser* current_browser_; Browser* current_browser_;
scoped_ptr<DownloadsEventsListener> events_listener_; scoped_ptr<DownloadsEventsListener> events_listener_;
...@@ -4038,7 +4033,7 @@ TEST(ExtensionDetermineDownloadFilenameInternal, ...@@ -4038,7 +4033,7 @@ TEST(ExtensionDetermineDownloadFilenameInternal,
base::FilePath filename; base::FilePath filename;
downloads::FilenameConflictAction conflict_action = downloads::FilenameConflictAction conflict_action =
downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY; downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY;
extensions::ExtensionWarningSet warnings; ExtensionWarningSet warnings;
// Empty incumbent determiner // Empty incumbent determiner
warnings.clear(); warnings.clear();
...@@ -4075,7 +4070,7 @@ TEST(ExtensionDetermineDownloadFilenameInternal, ...@@ -4075,7 +4070,7 @@ TEST(ExtensionDetermineDownloadFilenameInternal,
EXPECT_EQ(FILE_PATH_LITERAL("a"), filename.value()); EXPECT_EQ(FILE_PATH_LITERAL("a"), filename.value());
EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_OVERWRITE, conflict_action); EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_OVERWRITE, conflict_action);
EXPECT_FALSE(warnings.empty()); EXPECT_FALSE(warnings.empty());
EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict, EXPECT_EQ(ExtensionWarning::kDownloadFilenameConflict,
warnings.begin()->warning_type()); warnings.begin()->warning_type());
EXPECT_EQ("suggester", warnings.begin()->extension_id()); EXPECT_EQ("suggester", warnings.begin()->extension_id());
...@@ -4096,7 +4091,7 @@ TEST(ExtensionDetermineDownloadFilenameInternal, ...@@ -4096,7 +4091,7 @@ TEST(ExtensionDetermineDownloadFilenameInternal,
EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value()); EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value());
EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action);
EXPECT_FALSE(warnings.empty()); EXPECT_FALSE(warnings.empty());
EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict, EXPECT_EQ(ExtensionWarning::kDownloadFilenameConflict,
warnings.begin()->warning_type()); warnings.begin()->warning_type());
EXPECT_EQ("incumbent", warnings.begin()->extension_id()); EXPECT_EQ("incumbent", warnings.begin()->extension_id());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment