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

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 10033001: Convert printing ui_tests to browser_tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/automation/automation_provider_observers.h" 5 #include "chrome/browser/automation/automation_provider_observers.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 #include "chrome/browser/history/top_sites.h" 37 #include "chrome/browser/history/top_sites.h"
38 #include "chrome/browser/infobars/infobar_tab_helper.h" 38 #include "chrome/browser/infobars/infobar_tab_helper.h"
39 #include "chrome/browser/metrics/metric_event_duration_details.h" 39 #include "chrome/browser/metrics/metric_event_duration_details.h"
40 #include "chrome/browser/notifications/balloon.h" 40 #include "chrome/browser/notifications/balloon.h"
41 #include "chrome/browser/notifications/balloon_collection.h" 41 #include "chrome/browser/notifications/balloon_collection.h"
42 #include "chrome/browser/notifications/balloon_host.h" 42 #include "chrome/browser/notifications/balloon_host.h"
43 #include "chrome/browser/notifications/notification.h" 43 #include "chrome/browser/notifications/notification.h"
44 #include "chrome/browser/notifications/notification_ui_manager.h" 44 #include "chrome/browser/notifications/notification_ui_manager.h"
45 #include "chrome/browser/password_manager/password_store_change.h" 45 #include "chrome/browser/password_manager/password_store_change.h"
46 #include "chrome/browser/policy/browser_policy_connector.h" 46 #include "chrome/browser/policy/browser_policy_connector.h"
47 #include "chrome/browser/printing/print_job.h"
48 #include "chrome/browser/profiles/profile.h" 47 #include "chrome/browser/profiles/profile.h"
49 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 48 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
50 #include "chrome/browser/search_engines/template_url_service.h" 49 #include "chrome/browser/search_engines/template_url_service.h"
51 #include "chrome/browser/search_engines/template_url_service_factory.h" 50 #include "chrome/browser/search_engines/template_url_service_factory.h"
52 #include "chrome/browser/sessions/restore_tab_helper.h" 51 #include "chrome/browser/sessions/restore_tab_helper.h"
53 #include "chrome/browser/sessions/tab_restore_service.h" 52 #include "chrome/browser/sessions/tab_restore_service.h"
54 #include "chrome/browser/sessions/tab_restore_service_factory.h" 53 #include "chrome/browser/sessions/tab_restore_service_factory.h"
55 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 54 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
56 #include "chrome/browser/tab_contents/thumbnail_generator.h" 55 #include "chrome/browser/tab_contents/thumbnail_generator.h"
57 #include "chrome/browser/translate/page_translated_details.h" 56 #include "chrome/browser/translate/page_translated_details.h"
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 } 1274 }
1276 1275
1277 void DomOperationMessageSender::OnJavascriptBlocked() { 1276 void DomOperationMessageSender::OnJavascriptBlocked() {
1278 if (automation_ && use_json_interface_) { 1277 if (automation_ && use_json_interface_) {
1279 AutomationJSONReply(automation_, reply_message_.release()) 1278 AutomationJSONReply(automation_, reply_message_.release())
1280 .SendError("Javascript execution was blocked"); 1279 .SendError("Javascript execution was blocked");
1281 delete this; 1280 delete this;
1282 } 1281 }
1283 } 1282 }
1284 1283
1285 DocumentPrintedNotificationObserver::DocumentPrintedNotificationObserver(
1286 AutomationProvider* automation, IPC::Message* reply_message)
1287 : automation_(automation->AsWeakPtr()),
1288 success_(false),
1289 reply_message_(reply_message) {
1290 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
1291 content::NotificationService::AllSources());
1292 }
1293
1294 DocumentPrintedNotificationObserver::~DocumentPrintedNotificationObserver() {
1295 if (automation_) {
1296 AutomationMsg_PrintNow::WriteReplyParams(reply_message_.get(), success_);
1297 automation_->Send(reply_message_.release());
1298 }
1299 }
1300
1301 void DocumentPrintedNotificationObserver::Observe(
1302 int type,
1303 const content::NotificationSource& source,
1304 const content::NotificationDetails& details) {
1305 DCHECK(type == chrome::NOTIFICATION_PRINT_JOB_EVENT);
1306 switch (content::Details<printing::JobEventDetails>(details)->type()) {
1307 case printing::JobEventDetails::JOB_DONE: {
1308 // Succeeded.
1309 success_ = true;
1310 delete this;
1311 break;
1312 }
1313 case printing::JobEventDetails::USER_INIT_CANCELED:
1314 case printing::JobEventDetails::FAILED: {
1315 // Failed.
1316 delete this;
1317 break;
1318 }
1319 case printing::JobEventDetails::NEW_DOC:
1320 case printing::JobEventDetails::USER_INIT_DONE:
1321 case printing::JobEventDetails::DEFAULT_INIT_DONE:
1322 case printing::JobEventDetails::NEW_PAGE:
1323 case printing::JobEventDetails::PAGE_DONE:
1324 case printing::JobEventDetails::DOC_DONE:
1325 case printing::JobEventDetails::ALL_PAGES_REQUESTED: {
1326 // Don't care.
1327 break;
1328 }
1329 default: {
1330 NOTREACHED();
1331 break;
1332 }
1333 }
1334 }
1335
1336 MetricEventDurationObserver::MetricEventDurationObserver() { 1284 MetricEventDurationObserver::MetricEventDurationObserver() {
1337 registrar_.Add(this, chrome::NOTIFICATION_METRIC_EVENT_DURATION, 1285 registrar_.Add(this, chrome::NOTIFICATION_METRIC_EVENT_DURATION,
1338 content::NotificationService::AllSources()); 1286 content::NotificationService::AllSources());
1339 } 1287 }
1340 1288
1341 MetricEventDurationObserver::~MetricEventDurationObserver() {} 1289 MetricEventDurationObserver::~MetricEventDurationObserver() {}
1342 1290
1343 int MetricEventDurationObserver::GetEventDurationMs( 1291 int MetricEventDurationObserver::GetEventDurationMs(
1344 const std::string& event_name) { 1292 const std::string& event_name) {
1345 EventDurationMap::const_iterator it = durations_.find(event_name); 1293 EventDurationMap::const_iterator it = durations_.find(event_name);
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 } 3141 }
3194 3142
3195 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 3143 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
3196 if (host->extension_id() == extension_id_ && 3144 if (host->extension_id() == extension_id_ &&
3197 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { 3145 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) {
3198 AutomationJSONReply(automation_, reply_message_.release()) 3146 AutomationJSONReply(automation_, reply_message_.release())
3199 .SendSuccess(NULL); 3147 .SendSuccess(NULL);
3200 delete this; 3148 delete this;
3201 } 3149 }
3202 } 3150 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.h ('k') | chrome/browser/automation/testing_automation_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698