Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 14977013: Delete Automation[Tab/Renderer]Helper and users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update now that 202087 is committed Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/automation_provider_observers.cc
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 366cfeb21f3fd55debcae9775b83ed43c3808065..374202234f52b254ab4d891646717b1a50e573e5 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -1742,130 +1742,6 @@ void SavePackageNotificationObserver::ManagerGoingDown(
delete this;
}
-PageSnapshotTaker::PageSnapshotTaker(AutomationProvider* automation,
- IPC::Message* reply_message,
- WebContents* web_contents,
- const base::FilePath& path)
- : automation_(automation->AsWeakPtr()),
- reply_message_(reply_message),
- web_contents_(web_contents),
- image_path_(path) {
- registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
- content::NotificationService::AllSources());
-}
-
-PageSnapshotTaker::~PageSnapshotTaker() {}
-
-void PageSnapshotTaker::Start() {
- AutomationTabHelper* automation_tab_helper =
- AutomationTabHelper::FromWebContents(web_contents_);
- StartObserving(automation_tab_helper);
- automation_tab_helper->SnapshotEntirePage();
-}
-
-void PageSnapshotTaker::OnSnapshotEntirePageACK(
- bool success,
- const std::vector<unsigned char>& png_data,
- const std::string& error_msg) {
- bool overall_success = success;
- std::string overall_error_msg = error_msg;
- if (success) {
- base::ThreadRestrictions::ScopedAllowIO allow_io;
- int bytes_written = file_util::WriteFile(image_path_,
- reinterpret_cast<const char*>(&png_data[0]), png_data.size());
- overall_success = (bytes_written == static_cast<int>(png_data.size()));
- if (!overall_success)
- overall_error_msg = "could not write snapshot to disk";
- }
- SendMessage(overall_success, overall_error_msg);
-}
-
-void PageSnapshotTaker::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- SendMessage(false, "a modal dialog is active");
-}
-
-void PageSnapshotTaker::SendMessage(bool success,
- const std::string& error_msg) {
- if (automation_) {
- if (success) {
- AutomationJSONReply(automation_, reply_message_.release())
- .SendSuccess(NULL);
- } else {
- AutomationJSONReply(automation_, reply_message_.release())
- .SendError("Failed to take snapshot of page: " + error_msg);
- }
- }
- delete this;
-}
-
-AutomationMouseEventProcessor::AutomationMouseEventProcessor(
- RenderViewHost* render_view_host,
- const AutomationMouseEvent& event,
- const CompletionCallback& completion_callback,
- const ErrorCallback& error_callback)
- : RenderViewHostObserver(render_view_host),
- completion_callback_(completion_callback),
- error_callback_(error_callback),
- has_point_(false) {
- registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
- content::NotificationService::AllSources());
- Send(new AutomationMsg_ProcessMouseEvent(routing_id(), event));
-}
-
-AutomationMouseEventProcessor::~AutomationMouseEventProcessor() {}
-
-void AutomationMouseEventProcessor::OnWillProcessMouseEventAt(
- const gfx::Point& point) {
- has_point_ = true;
- point_ = point;
-}
-
-void AutomationMouseEventProcessor::OnProcessMouseEventACK(
- bool success,
- const std::string& error_msg) {
- InvokeCallback(automation::Error(error_msg));
-}
-
-void AutomationMouseEventProcessor::RenderViewHostDestroyed(
- RenderViewHost* host) {
- InvokeCallback(automation::Error("The render view host was destroyed"));
-}
-
-bool AutomationMouseEventProcessor::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- bool msg_is_good = true;
- IPC_BEGIN_MESSAGE_MAP_EX(AutomationMouseEventProcessor, message, msg_is_good)
- IPC_MESSAGE_HANDLER(AutomationMsg_WillProcessMouseEventAt,
- OnWillProcessMouseEventAt)
- IPC_MESSAGE_HANDLER(AutomationMsg_ProcessMouseEventACK,
- OnProcessMouseEventACK)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP_EX()
- if (!msg_is_good) {
- LOG(ERROR) << "Failed to deserialize an IPC message";
- }
- return handled;
-}
-
-void AutomationMouseEventProcessor::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- InvokeCallback(automation::Error(automation::kBlockedByModalDialog));
-}
-
-void AutomationMouseEventProcessor::InvokeCallback(
- const automation::Error& error) {
- if (has_point_)
- completion_callback_.Run(point_);
- else
- error_callback_.Run(error);
- delete this;
-}
-
namespace {
// Returns a vector of dictionaries containing information about installed apps,
@@ -2315,90 +2191,6 @@ void InputEventAckNotificationObserver::Observe(
}
}
-AllViewsStoppedLoadingObserver::AllViewsStoppedLoadingObserver(
- AutomationProvider* automation,
- IPC::Message* reply_message,
- ExtensionProcessManager* extension_process_manager)
- : automation_(automation->AsWeakPtr()),
- reply_message_(reply_message),
- extension_process_manager_(extension_process_manager) {
- registrar_.Add(this,
- chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
- content::NotificationService::AllSources());
- registrar_.Add(this,
- content::NOTIFICATION_LOAD_STOP,
- content::NotificationService::AllSources());
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
- for (int i = 0; i < browser->tab_strip_model()->count(); ++i) {
- WebContents* web_contents =
- browser->tab_strip_model()->GetWebContentsAt(i);
- AutomationTabHelper* automation_tab_helper =
- AutomationTabHelper::FromWebContents(web_contents);
- StartObserving(automation_tab_helper);
- if (automation_tab_helper->has_pending_loads())
- pending_tabs_.insert(web_contents);
- }
- }
- CheckIfNoMorePendingLoads();
-}
-
-AllViewsStoppedLoadingObserver::~AllViewsStoppedLoadingObserver() {
-}
-
-void AllViewsStoppedLoadingObserver::OnFirstPendingLoad(
- content::WebContents* web_contents) {
- pending_tabs_.insert(web_contents);
-}
-
-void AllViewsStoppedLoadingObserver::OnNoMorePendingLoads(
- content::WebContents* web_contents) {
- if (!automation_) {
- delete this;
- return;
- }
-
- TabSet::iterator iter = pending_tabs_.find(web_contents);
- if (iter == pending_tabs_.end()) {
- LOG(ERROR) << "Received OnNoMorePendingLoads for tab without "
- << "OnFirstPendingLoad.";
- return;
- }
- pending_tabs_.erase(iter);
- CheckIfNoMorePendingLoads();
-}
-
-void AllViewsStoppedLoadingObserver::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (!automation_) {
- delete this;
- return;
- }
- if (type == content::NOTIFICATION_LOAD_STOP) {
- CheckIfNoMorePendingLoads();
- } else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) {
- AutomationJSONReply(automation_,
- reply_message_.release()).SendSuccess(NULL);
- delete this;
- }
-}
-
-void AllViewsStoppedLoadingObserver::CheckIfNoMorePendingLoads() {
- if (!automation_) {
- delete this;
- return;
- }
-
- if (pending_tabs_.empty() &&
- DidExtensionViewsStopLoading(extension_process_manager_)) {
- AutomationJSONReply(automation_,
- reply_message_.release()).SendSuccess(NULL);
- delete this;
- }
-}
-
NewTabObserver::NewTabObserver(AutomationProvider* automation,
IPC::Message* reply_message,
bool use_json_interface)
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.h ('k') | chrome/browser/automation/automation_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698