| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "chrome/browser/translate/translate_tab_helper.h" | 53 #include "chrome/browser/translate/translate_tab_helper.h" |
| 54 #include "chrome/browser/ui/browser.h" | 54 #include "chrome/browser/ui/browser.h" |
| 55 #include "chrome/browser/ui/browser_list.h" | 55 #include "chrome/browser/ui/browser_list.h" |
| 56 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 56 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 57 #include "chrome/browser/ui/login/login_prompt.h" | 57 #include "chrome/browser/ui/login/login_prompt.h" |
| 58 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 58 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 59 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 59 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 60 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" | 60 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" |
| 61 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 61 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 62 #include "chrome/common/automation_messages.h" | 62 #include "chrome/common/automation_messages.h" |
| 63 #include "chrome/common/chrome_notification_types.h" |
| 63 #include "chrome/common/extensions/extension.h" | 64 #include "chrome/common/extensions/extension.h" |
| 64 #include "content/browser/renderer_host/render_process_host.h" | 65 #include "content/browser/renderer_host/render_process_host.h" |
| 65 #include "content/browser/renderer_host/render_view_host.h" | 66 #include "content/browser/renderer_host/render_view_host.h" |
| 66 #include "content/browser/tab_contents/navigation_controller.h" | 67 #include "content/browser/tab_contents/navigation_controller.h" |
| 67 #include "content/browser/tab_contents/tab_contents.h" | 68 #include "content/browser/tab_contents/tab_contents.h" |
| 68 #include "content/common/notification_service.h" | 69 #include "content/common/notification_service.h" |
| 69 #include "googleurl/src/gurl.h" | 70 #include "googleurl/src/gurl.h" |
| 70 #include "ui/gfx/codec/png_codec.h" | 71 #include "ui/gfx/codec/png_codec.h" |
| 71 #include "ui/gfx/rect.h" | 72 #include "ui/gfx/rect.h" |
| 72 | 73 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 89 base::TimeTicks load_start_time_; | 90 base::TimeTicks load_start_time_; |
| 90 base::TimeTicks load_stop_time_; | 91 base::TimeTicks load_stop_time_; |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 InitialLoadObserver::InitialLoadObserver(size_t tab_count, | 94 InitialLoadObserver::InitialLoadObserver(size_t tab_count, |
| 94 AutomationProvider* automation) | 95 AutomationProvider* automation) |
| 95 : automation_(automation->AsWeakPtr()), | 96 : automation_(automation->AsWeakPtr()), |
| 96 outstanding_tab_count_(tab_count), | 97 outstanding_tab_count_(tab_count), |
| 97 init_time_(base::TimeTicks::Now()) { | 98 init_time_(base::TimeTicks::Now()) { |
| 98 if (outstanding_tab_count_ > 0) { | 99 if (outstanding_tab_count_ > 0) { |
| 99 registrar_.Add(this, NotificationType::LOAD_START, | 100 registrar_.Add(this, content::NOTIFICATION_LOAD_START, |
| 100 NotificationService::AllSources()); | 101 NotificationService::AllSources()); |
| 101 registrar_.Add(this, NotificationType::LOAD_STOP, | 102 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 102 NotificationService::AllSources()); | 103 NotificationService::AllSources()); |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 | 106 |
| 106 InitialLoadObserver::~InitialLoadObserver() { | 107 InitialLoadObserver::~InitialLoadObserver() { |
| 107 } | 108 } |
| 108 | 109 |
| 109 void InitialLoadObserver::Observe(NotificationType type, | 110 void InitialLoadObserver::Observe(int type, |
| 110 const NotificationSource& source, | 111 const NotificationSource& source, |
| 111 const NotificationDetails& details) { | 112 const NotificationDetails& details) { |
| 112 if (type == NotificationType::LOAD_START) { | 113 if (type == content::NOTIFICATION_LOAD_START) { |
| 113 if (outstanding_tab_count_ > loading_tabs_.size()) | 114 if (outstanding_tab_count_ > loading_tabs_.size()) |
| 114 loading_tabs_.insert(TabTimeMap::value_type( | 115 loading_tabs_.insert(TabTimeMap::value_type( |
| 115 source.map_key(), | 116 source.map_key(), |
| 116 TabTime(base::TimeTicks::Now()))); | 117 TabTime(base::TimeTicks::Now()))); |
| 117 } else if (type == NotificationType::LOAD_STOP) { | 118 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
| 118 if (outstanding_tab_count_ > finished_tabs_.size()) { | 119 if (outstanding_tab_count_ > finished_tabs_.size()) { |
| 119 TabTimeMap::iterator iter = loading_tabs_.find(source.map_key()); | 120 TabTimeMap::iterator iter = loading_tabs_.find(source.map_key()); |
| 120 if (iter != loading_tabs_.end()) { | 121 if (iter != loading_tabs_.end()) { |
| 121 finished_tabs_.insert(source.map_key()); | 122 finished_tabs_.insert(source.map_key()); |
| 122 iter->second.set_stop_time(base::TimeTicks::Now()); | 123 iter->second.set_stop_time(base::TimeTicks::Now()); |
| 123 } | 124 } |
| 124 if (outstanding_tab_count_ == finished_tabs_.size()) | 125 if (outstanding_tab_count_ == finished_tabs_.size()) |
| 125 ConditionMet(); | 126 ConditionMet(); |
| 126 } | 127 } |
| 127 } else { | 128 } else { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 152 } | 153 } |
| 153 | 154 |
| 154 void InitialLoadObserver::ConditionMet() { | 155 void InitialLoadObserver::ConditionMet() { |
| 155 registrar_.RemoveAll(); | 156 registrar_.RemoveAll(); |
| 156 if (automation_) | 157 if (automation_) |
| 157 automation_->OnInitialTabLoadsComplete(); | 158 automation_->OnInitialTabLoadsComplete(); |
| 158 } | 159 } |
| 159 | 160 |
| 160 NewTabUILoadObserver::NewTabUILoadObserver(AutomationProvider* automation) | 161 NewTabUILoadObserver::NewTabUILoadObserver(AutomationProvider* automation) |
| 161 : automation_(automation->AsWeakPtr()) { | 162 : automation_(automation->AsWeakPtr()) { |
| 162 registrar_.Add(this, NotificationType::INITIAL_NEW_TAB_UI_LOAD, | 163 registrar_.Add(this, chrome::NOTIFICATION_INITIAL_NEW_TAB_UI_LOAD, |
| 163 NotificationService::AllSources()); | 164 NotificationService::AllSources()); |
| 164 } | 165 } |
| 165 | 166 |
| 166 NewTabUILoadObserver::~NewTabUILoadObserver() { | 167 NewTabUILoadObserver::~NewTabUILoadObserver() { |
| 167 } | 168 } |
| 168 | 169 |
| 169 void NewTabUILoadObserver::Observe(NotificationType type, | 170 void NewTabUILoadObserver::Observe(int type, |
| 170 const NotificationSource& source, | 171 const NotificationSource& source, |
| 171 const NotificationDetails& details) { | 172 const NotificationDetails& details) { |
| 172 if (type == NotificationType::INITIAL_NEW_TAB_UI_LOAD) { | 173 if (type == chrome::NOTIFICATION_INITIAL_NEW_TAB_UI_LOAD) { |
| 173 Details<int> load_time(details); | 174 Details<int> load_time(details); |
| 174 if (automation_) { | 175 if (automation_) { |
| 175 automation_->Send( | 176 automation_->Send( |
| 176 new AutomationMsg_InitialNewTabUILoadComplete(*load_time.ptr())); | 177 new AutomationMsg_InitialNewTabUILoadComplete(*load_time.ptr())); |
| 177 } | 178 } |
| 178 } else { | 179 } else { |
| 179 NOTREACHED(); | 180 NOTREACHED(); |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 | 183 |
| 183 NavigationControllerRestoredObserver::NavigationControllerRestoredObserver( | 184 NavigationControllerRestoredObserver::NavigationControllerRestoredObserver( |
| 184 AutomationProvider* automation, | 185 AutomationProvider* automation, |
| 185 NavigationController* controller, | 186 NavigationController* controller, |
| 186 IPC::Message* reply_message) | 187 IPC::Message* reply_message) |
| 187 : automation_(automation->AsWeakPtr()), | 188 : automation_(automation->AsWeakPtr()), |
| 188 controller_(controller), | 189 controller_(controller), |
| 189 reply_message_(reply_message) { | 190 reply_message_(reply_message) { |
| 190 if (FinishedRestoring()) { | 191 if (FinishedRestoring()) { |
| 191 SendDone(); | 192 SendDone(); |
| 192 } else { | 193 } else { |
| 193 registrar_.Add(this, NotificationType::LOAD_STOP, | 194 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 194 NotificationService::AllSources()); | 195 NotificationService::AllSources()); |
| 195 } | 196 } |
| 196 } | 197 } |
| 197 | 198 |
| 198 NavigationControllerRestoredObserver::~NavigationControllerRestoredObserver() { | 199 NavigationControllerRestoredObserver::~NavigationControllerRestoredObserver() { |
| 199 } | 200 } |
| 200 | 201 |
| 201 void NavigationControllerRestoredObserver::Observe( | 202 void NavigationControllerRestoredObserver::Observe( |
| 202 NotificationType type, const NotificationSource& source, | 203 int type, const NotificationSource& source, |
| 203 const NotificationDetails& details) { | 204 const NotificationDetails& details) { |
| 204 if (FinishedRestoring()) { | 205 if (FinishedRestoring()) { |
| 205 SendDone(); | 206 SendDone(); |
| 206 registrar_.RemoveAll(); | 207 registrar_.RemoveAll(); |
| 207 } | 208 } |
| 208 } | 209 } |
| 209 | 210 |
| 210 bool NavigationControllerRestoredObserver::FinishedRestoring() { | 211 bool NavigationControllerRestoredObserver::FinishedRestoring() { |
| 211 return (!controller_->needs_reload() && !controller_->pending_entry() && | 212 return (!controller_->needs_reload() && !controller_->pending_entry() && |
| 212 !controller_->tab_contents()->is_loading()); | 213 !controller_->tab_contents()->is_loading()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 229 bool include_current_navigation, | 230 bool include_current_navigation, |
| 230 bool use_json_interface) | 231 bool use_json_interface) |
| 231 : automation_(automation->AsWeakPtr()), | 232 : automation_(automation->AsWeakPtr()), |
| 232 reply_message_(reply_message), | 233 reply_message_(reply_message), |
| 233 controller_(controller), | 234 controller_(controller), |
| 234 navigations_remaining_(number_of_navigations), | 235 navigations_remaining_(number_of_navigations), |
| 235 navigation_started_(false), | 236 navigation_started_(false), |
| 236 use_json_interface_(use_json_interface) { | 237 use_json_interface_(use_json_interface) { |
| 237 DCHECK_LT(0, navigations_remaining_); | 238 DCHECK_LT(0, navigations_remaining_); |
| 238 Source<NavigationController> source(controller_); | 239 Source<NavigationController> source(controller_); |
| 239 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, source); | 240 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
| 240 registrar_.Add(this, NotificationType::LOAD_START, source); | 241 registrar_.Add(this, content::NOTIFICATION_LOAD_START, source); |
| 241 registrar_.Add(this, NotificationType::LOAD_STOP, source); | 242 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); |
| 242 registrar_.Add(this, NotificationType::AUTH_NEEDED, source); | 243 registrar_.Add(this, chrome::NOTIFICATION_AUTH_NEEDED, source); |
| 243 registrar_.Add(this, NotificationType::AUTH_SUPPLIED, source); | 244 registrar_.Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED, source); |
| 244 registrar_.Add(this, NotificationType::AUTH_CANCELLED, source); | 245 registrar_.Add(this, chrome::NOTIFICATION_AUTH_CANCELLED, source); |
| 245 | 246 |
| 246 if (include_current_navigation && controller->tab_contents()->is_loading()) | 247 if (include_current_navigation && controller->tab_contents()->is_loading()) |
| 247 navigation_started_ = true; | 248 navigation_started_ = true; |
| 248 } | 249 } |
| 249 | 250 |
| 250 NavigationNotificationObserver::~NavigationNotificationObserver() { | 251 NavigationNotificationObserver::~NavigationNotificationObserver() { |
| 251 } | 252 } |
| 252 | 253 |
| 253 void NavigationNotificationObserver::Observe( | 254 void NavigationNotificationObserver::Observe( |
| 254 NotificationType type, const NotificationSource& source, | 255 int type, const NotificationSource& source, |
| 255 const NotificationDetails& details) { | 256 const NotificationDetails& details) { |
| 256 if (!automation_) { | 257 if (!automation_) { |
| 257 delete this; | 258 delete this; |
| 258 return; | 259 return; |
| 259 } | 260 } |
| 260 | 261 |
| 261 // We listen for 2 events to determine when the navigation started because: | 262 // We listen for 2 events to determine when the navigation started because: |
| 262 // - when this is used by the WaitForNavigation method, we might be invoked | 263 // - when this is used by the WaitForNavigation method, we might be invoked |
| 263 // afer the load has started (but not after the entry was committed, as | 264 // afer the load has started (but not after the entry was committed, as |
| 264 // WaitForNavigation compares times of the last navigation). | 265 // WaitForNavigation compares times of the last navigation). |
| 265 // - when this is used with a page requiring authentication, we will not get | 266 // - when this is used with a page requiring authentication, we will not get |
| 266 // a NotificationType::NAV_ENTRY_COMMITTED until after we authenticate, so | 267 // a chrome::NAV_ENTRY_COMMITTED until after we authenticate, so |
| 267 // we need the NotificationType::LOAD_START. | 268 // we need the chrome::LOAD_START. |
| 268 if (type == NotificationType::NAV_ENTRY_COMMITTED || | 269 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED || |
| 269 type == NotificationType::LOAD_START) { | 270 type == content::NOTIFICATION_LOAD_START) { |
| 270 navigation_started_ = true; | 271 navigation_started_ = true; |
| 271 } else if (type == NotificationType::LOAD_STOP) { | 272 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
| 272 if (navigation_started_) { | 273 if (navigation_started_) { |
| 273 navigation_started_ = false; | 274 navigation_started_ = false; |
| 274 if (--navigations_remaining_ == 0) | 275 if (--navigations_remaining_ == 0) |
| 275 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); | 276 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); |
| 276 } | 277 } |
| 277 } else if (type == NotificationType::AUTH_SUPPLIED || | 278 } else if (type == chrome::NOTIFICATION_AUTH_SUPPLIED || |
| 278 type == NotificationType::AUTH_CANCELLED) { | 279 type == chrome::NOTIFICATION_AUTH_CANCELLED) { |
| 279 // The LoginHandler for this tab is no longer valid. | 280 // The LoginHandler for this tab is no longer valid. |
| 280 automation_->RemoveLoginHandler(controller_); | 281 automation_->RemoveLoginHandler(controller_); |
| 281 | 282 |
| 282 // Treat this as if navigation started again, since load start/stop don't | 283 // Treat this as if navigation started again, since load start/stop don't |
| 283 // occur while authentication is ongoing. | 284 // occur while authentication is ongoing. |
| 284 navigation_started_ = true; | 285 navigation_started_ = true; |
| 285 } else if (type == NotificationType::AUTH_NEEDED) { | 286 } else if (type == chrome::NOTIFICATION_AUTH_NEEDED) { |
| 286 // Remember the login handler that wants authentication. | 287 // Remember the login handler that wants authentication. |
| 287 // We do this in all cases (not just when navigation_started_ == true) so | 288 // We do this in all cases (not just when navigation_started_ == true) so |
| 288 // tests can still wait for auth dialogs outside of navigation. | 289 // tests can still wait for auth dialogs outside of navigation. |
| 289 LoginHandler* handler = | 290 LoginHandler* handler = |
| 290 Details<LoginNotificationDetails>(details)->handler(); | 291 Details<LoginNotificationDetails>(details)->handler(); |
| 291 automation_->AddLoginHandler(controller_, handler); | 292 automation_->AddLoginHandler(controller_, handler); |
| 292 | 293 |
| 293 // Respond that authentication is needed. | 294 // Respond that authentication is needed. |
| 294 navigation_started_ = false; | 295 navigation_started_ = false; |
| 295 ConditionMet(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED); | 296 ConditionMet(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 310 IPC::ParamTraits<AutomationMsg_NavigationResponseValues>::Write( | 311 IPC::ParamTraits<AutomationMsg_NavigationResponseValues>::Write( |
| 311 reply_message_.get(), navigation_result); | 312 reply_message_.get(), navigation_result); |
| 312 automation_->Send(reply_message_.release()); | 313 automation_->Send(reply_message_.release()); |
| 313 } | 314 } |
| 314 } | 315 } |
| 315 | 316 |
| 316 delete this; | 317 delete this; |
| 317 } | 318 } |
| 318 | 319 |
| 319 TabStripNotificationObserver::TabStripNotificationObserver( | 320 TabStripNotificationObserver::TabStripNotificationObserver( |
| 320 NotificationType notification, AutomationProvider* automation) | 321 int notification, AutomationProvider* automation) |
| 321 : automation_(automation->AsWeakPtr()), | 322 : automation_(automation->AsWeakPtr()), |
| 322 notification_(notification) { | 323 notification_(notification) { |
| 323 registrar_.Add(this, notification_, NotificationService::AllSources()); | 324 registrar_.Add(this, notification_, NotificationService::AllSources()); |
| 324 } | 325 } |
| 325 | 326 |
| 326 TabStripNotificationObserver::~TabStripNotificationObserver() { | 327 TabStripNotificationObserver::~TabStripNotificationObserver() { |
| 327 } | 328 } |
| 328 | 329 |
| 329 void TabStripNotificationObserver::Observe(NotificationType type, | 330 void TabStripNotificationObserver::Observe(int type, |
| 330 const NotificationSource& source, | 331 const NotificationSource& source, |
| 331 const NotificationDetails& details) { | 332 const NotificationDetails& details) { |
| 332 if (type == notification_) { | 333 if (type == notification_) { |
| 333 if (type == NotificationType::TAB_PARENTED) | 334 if (type == content::NOTIFICATION_TAB_PARENTED) |
| 334 ObserveTab(&(Source<TabContentsWrapper>(source).ptr()->controller())); | 335 ObserveTab(&(Source<TabContentsWrapper>(source).ptr()->controller())); |
| 335 else | 336 else |
| 336 ObserveTab(Source<NavigationController>(source).ptr()); | 337 ObserveTab(Source<NavigationController>(source).ptr()); |
| 337 delete this; | 338 delete this; |
| 338 } else { | 339 } else { |
| 339 NOTREACHED(); | 340 NOTREACHED(); |
| 340 } | 341 } |
| 341 } | 342 } |
| 342 | 343 |
| 343 TabAppendedNotificationObserver::TabAppendedNotificationObserver( | 344 TabAppendedNotificationObserver::TabAppendedNotificationObserver( |
| 344 Browser* parent, AutomationProvider* automation, | 345 Browser* parent, AutomationProvider* automation, |
| 345 IPC::Message* reply_message) | 346 IPC::Message* reply_message) |
| 346 : TabStripNotificationObserver(NotificationType::TAB_PARENTED, automation), | 347 : TabStripNotificationObserver(content::NOTIFICATION_TAB_PARENTED, |
| 348 automation), |
| 347 parent_(parent), | 349 parent_(parent), |
| 348 reply_message_(reply_message) { | 350 reply_message_(reply_message) { |
| 349 } | 351 } |
| 350 | 352 |
| 351 TabAppendedNotificationObserver::~TabAppendedNotificationObserver() {} | 353 TabAppendedNotificationObserver::~TabAppendedNotificationObserver() {} |
| 352 | 354 |
| 353 void TabAppendedNotificationObserver::ObserveTab( | 355 void TabAppendedNotificationObserver::ObserveTab( |
| 354 NavigationController* controller) { | 356 NavigationController* controller) { |
| 355 if (!automation_) | 357 if (!automation_) |
| 356 return; | 358 return; |
| 357 | 359 |
| 358 if (automation_->GetIndexForNavigationController(controller, parent_) == | 360 if (automation_->GetIndexForNavigationController(controller, parent_) == |
| 359 TabStripModel::kNoTab) { | 361 TabStripModel::kNoTab) { |
| 360 // This tab notification doesn't belong to the parent_. | 362 // This tab notification doesn't belong to the parent_. |
| 361 return; | 363 return; |
| 362 } | 364 } |
| 363 | 365 |
| 364 new NavigationNotificationObserver(controller, automation_, | 366 new NavigationNotificationObserver(controller, automation_, |
| 365 reply_message_.release(), | 367 reply_message_.release(), |
| 366 1, false, false); | 368 1, false, false); |
| 367 } | 369 } |
| 368 | 370 |
| 369 TabClosedNotificationObserver::TabClosedNotificationObserver( | 371 TabClosedNotificationObserver::TabClosedNotificationObserver( |
| 370 AutomationProvider* automation, bool wait_until_closed, | 372 AutomationProvider* automation, bool wait_until_closed, |
| 371 IPC::Message* reply_message) | 373 IPC::Message* reply_message) |
| 372 : TabStripNotificationObserver(wait_until_closed ? | 374 : TabStripNotificationObserver(wait_until_closed ? |
| 373 NotificationType::TAB_CLOSED : NotificationType::TAB_CLOSING, | 375 content::NOTIFICATION_TAB_CLOSED : content::NOTIFICATION_TAB_CLOSING, |
| 374 automation), | 376 automation), |
| 375 reply_message_(reply_message), | 377 reply_message_(reply_message), |
| 376 for_browser_command_(false) { | 378 for_browser_command_(false) { |
| 377 } | 379 } |
| 378 | 380 |
| 379 TabClosedNotificationObserver::~TabClosedNotificationObserver() {} | 381 TabClosedNotificationObserver::~TabClosedNotificationObserver() {} |
| 380 | 382 |
| 381 void TabClosedNotificationObserver::ObserveTab( | 383 void TabClosedNotificationObserver::ObserveTab( |
| 382 NavigationController* controller) { | 384 NavigationController* controller) { |
| 383 if (!automation_) | 385 if (!automation_) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 return false; | 456 return false; |
| 455 } | 457 } |
| 456 return true; | 458 return true; |
| 457 } | 459 } |
| 458 | 460 |
| 459 ExtensionInstallNotificationObserver::ExtensionInstallNotificationObserver( | 461 ExtensionInstallNotificationObserver::ExtensionInstallNotificationObserver( |
| 460 AutomationProvider* automation, int id, IPC::Message* reply_message) | 462 AutomationProvider* automation, int id, IPC::Message* reply_message) |
| 461 : automation_(automation->AsWeakPtr()), | 463 : automation_(automation->AsWeakPtr()), |
| 462 id_(id), | 464 id_(id), |
| 463 reply_message_(reply_message) { | 465 reply_message_(reply_message) { |
| 464 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 466 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 465 NotificationService::AllSources()); | 467 NotificationService::AllSources()); |
| 466 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, | 468 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 467 NotificationService::AllSources()); | 469 NotificationService::AllSources()); |
| 468 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 470 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 469 NotificationService::AllSources()); | 471 NotificationService::AllSources()); |
| 470 } | 472 } |
| 471 | 473 |
| 472 ExtensionInstallNotificationObserver::~ExtensionInstallNotificationObserver() { | 474 ExtensionInstallNotificationObserver::~ExtensionInstallNotificationObserver() { |
| 473 } | 475 } |
| 474 | 476 |
| 475 void ExtensionInstallNotificationObserver::Observe( | 477 void ExtensionInstallNotificationObserver::Observe( |
| 476 NotificationType type, const NotificationSource& source, | 478 int type, const NotificationSource& source, |
| 477 const NotificationDetails& details) { | 479 const NotificationDetails& details) { |
| 478 switch (type.value) { | 480 switch (type) { |
| 479 case NotificationType::EXTENSION_LOADED: | 481 case chrome::NOTIFICATION_EXTENSION_LOADED: |
| 480 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED); | 482 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED); |
| 481 break; | 483 break; |
| 482 case NotificationType::EXTENSION_INSTALL_ERROR: | 484 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: |
| 483 case NotificationType::EXTENSION_UPDATE_DISABLED: | 485 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| 484 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); | 486 SendResponse(AUTOMATION_MSG_EXTENSION_INSTALL_FAILED); |
| 485 break; | 487 break; |
| 486 default: | 488 default: |
| 487 NOTREACHED(); | 489 NOTREACHED(); |
| 488 break; | 490 break; |
| 489 } | 491 } |
| 490 | 492 |
| 491 delete this; | 493 delete this; |
| 492 } | 494 } |
| 493 | 495 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 511 automation_->Send(reply_message_.release()); | 513 automation_->Send(reply_message_.release()); |
| 512 } | 514 } |
| 513 | 515 |
| 514 ExtensionUninstallObserver::ExtensionUninstallObserver( | 516 ExtensionUninstallObserver::ExtensionUninstallObserver( |
| 515 AutomationProvider* automation, | 517 AutomationProvider* automation, |
| 516 IPC::Message* reply_message, | 518 IPC::Message* reply_message, |
| 517 const std::string& id) | 519 const std::string& id) |
| 518 : automation_(automation->AsWeakPtr()), | 520 : automation_(automation->AsWeakPtr()), |
| 519 reply_message_(reply_message), | 521 reply_message_(reply_message), |
| 520 id_(id) { | 522 id_(id) { |
| 521 registrar_.Add(this, NotificationType::EXTENSION_UNINSTALLED, | 523 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
| 522 NotificationService::AllSources()); | 524 NotificationService::AllSources()); |
| 523 registrar_.Add(this, NotificationType::EXTENSION_UNINSTALL_NOT_ALLOWED, | 525 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
| 524 NotificationService::AllSources()); | 526 NotificationService::AllSources()); |
| 525 } | 527 } |
| 526 | 528 |
| 527 ExtensionUninstallObserver::~ExtensionUninstallObserver() { | 529 ExtensionUninstallObserver::~ExtensionUninstallObserver() { |
| 528 } | 530 } |
| 529 | 531 |
| 530 void ExtensionUninstallObserver::Observe( | 532 void ExtensionUninstallObserver::Observe( |
| 531 NotificationType type, | 533 int type, |
| 532 const NotificationSource& source, | 534 const NotificationSource& source, |
| 533 const NotificationDetails& details) { | 535 const NotificationDetails& details) { |
| 534 if (!automation_) { | 536 if (!automation_) { |
| 535 delete this; | 537 delete this; |
| 536 return; | 538 return; |
| 537 } | 539 } |
| 538 | 540 |
| 539 switch (type.value) { | 541 switch (type) { |
| 540 case NotificationType::EXTENSION_UNINSTALLED: { | 542 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { |
| 541 UninstalledExtensionInfo* info = | 543 UninstalledExtensionInfo* info = |
| 542 Details<UninstalledExtensionInfo>(details).ptr(); | 544 Details<UninstalledExtensionInfo>(details).ptr(); |
| 543 if (id_ == info->extension_id) { | 545 if (id_ == info->extension_id) { |
| 544 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 546 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 545 return_value->SetBoolean("success", true); | 547 return_value->SetBoolean("success", true); |
| 546 AutomationJSONReply(automation_, reply_message_.release()) | 548 AutomationJSONReply(automation_, reply_message_.release()) |
| 547 .SendSuccess(return_value.get()); | 549 .SendSuccess(return_value.get()); |
| 548 delete this; | 550 delete this; |
| 549 return; | 551 return; |
| 550 } | 552 } |
| 551 break; | 553 break; |
| 552 } | 554 } |
| 553 | 555 |
| 554 case NotificationType::EXTENSION_UNINSTALL_NOT_ALLOWED: { | 556 case chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED: { |
| 555 const Extension* extension = Details<Extension>(details).ptr(); | 557 const Extension* extension = Details<Extension>(details).ptr(); |
| 556 if (id_ == extension->id()) { | 558 if (id_ == extension->id()) { |
| 557 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 559 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 558 return_value->SetBoolean("success", false); | 560 return_value->SetBoolean("success", false); |
| 559 AutomationJSONReply(automation_, reply_message_.release()) | 561 AutomationJSONReply(automation_, reply_message_.release()) |
| 560 .SendSuccess(return_value.get()); | 562 .SendSuccess(return_value.get()); |
| 561 delete this; | 563 delete this; |
| 562 return; | 564 return; |
| 563 } | 565 } |
| 564 break; | 566 break; |
| 565 } | 567 } |
| 566 | 568 |
| 567 default: | 569 default: |
| 568 NOTREACHED(); | 570 NOTREACHED(); |
| 569 } | 571 } |
| 570 } | 572 } |
| 571 | 573 |
| 572 ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver( | 574 ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver( |
| 573 ExtensionProcessManager* manager, AutomationProvider* automation, int id, | 575 ExtensionProcessManager* manager, AutomationProvider* automation, int id, |
| 574 IPC::Message* reply_message) | 576 IPC::Message* reply_message) |
| 575 : manager_(manager), | 577 : manager_(manager), |
| 576 automation_(automation->AsWeakPtr()), | 578 automation_(automation->AsWeakPtr()), |
| 577 id_(id), | 579 id_(id), |
| 578 reply_message_(reply_message), | 580 reply_message_(reply_message), |
| 579 extension_(NULL) { | 581 extension_(NULL) { |
| 580 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 582 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 581 NotificationService::AllSources()); | 583 NotificationService::AllSources()); |
| 582 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 584 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 583 NotificationService::AllSources()); | 585 NotificationService::AllSources()); |
| 584 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, | 586 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 585 NotificationService::AllSources()); | 587 NotificationService::AllSources()); |
| 586 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 588 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 587 NotificationService::AllSources()); | 589 NotificationService::AllSources()); |
| 588 } | 590 } |
| 589 | 591 |
| 590 ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() { | 592 ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() { |
| 591 } | 593 } |
| 592 | 594 |
| 593 void ExtensionReadyNotificationObserver::Observe( | 595 void ExtensionReadyNotificationObserver::Observe( |
| 594 NotificationType type, const NotificationSource& source, | 596 int type, const NotificationSource& source, |
| 595 const NotificationDetails& details) { | 597 const NotificationDetails& details) { |
| 596 if (!automation_) { | 598 if (!automation_) { |
| 597 delete this; | 599 delete this; |
| 598 return; | 600 return; |
| 599 } | 601 } |
| 600 | 602 |
| 601 switch (type.value) { | 603 switch (type) { |
| 602 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: | 604 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: |
| 603 // Only continue on with this method if our extension has been loaded | 605 // Only continue on with this method if our extension has been loaded |
| 604 // and all the extension hosts have stopped loading. | 606 // and all the extension hosts have stopped loading. |
| 605 if (!extension_ || !DidExtensionHostsStopLoading(manager_)) | 607 if (!extension_ || !DidExtensionHostsStopLoading(manager_)) |
| 606 return; | 608 return; |
| 607 break; | 609 break; |
| 608 case NotificationType::EXTENSION_LOADED: | 610 case chrome::NOTIFICATION_EXTENSION_LOADED: |
| 609 extension_ = Details<const Extension>(details).ptr(); | 611 extension_ = Details<const Extension>(details).ptr(); |
| 610 if (!DidExtensionHostsStopLoading(manager_)) | 612 if (!DidExtensionHostsStopLoading(manager_)) |
| 611 return; | 613 return; |
| 612 break; | 614 break; |
| 613 case NotificationType::EXTENSION_INSTALL_ERROR: | 615 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: |
| 614 case NotificationType::EXTENSION_UPDATE_DISABLED: | 616 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: |
| 615 break; | 617 break; |
| 616 default: | 618 default: |
| 617 NOTREACHED(); | 619 NOTREACHED(); |
| 618 break; | 620 break; |
| 619 } | 621 } |
| 620 | 622 |
| 621 if (id_ == AutomationMsg_InstallExtensionAndGetHandle::ID) { | 623 if (id_ == AutomationMsg_InstallExtensionAndGetHandle::ID) { |
| 622 // A handle of zero indicates an error. | 624 // A handle of zero indicates an error. |
| 623 int extension_handle = 0; | 625 int extension_handle = 0; |
| 624 if (extension_) | 626 if (extension_) |
| 625 extension_handle = automation_->AddExtension(extension_); | 627 extension_handle = automation_->AddExtension(extension_); |
| 626 AutomationMsg_InstallExtensionAndGetHandle::WriteReplyParams( | 628 AutomationMsg_InstallExtensionAndGetHandle::WriteReplyParams( |
| 627 reply_message_.get(), extension_handle); | 629 reply_message_.get(), extension_handle); |
| 628 } else if (id_ == AutomationMsg_EnableExtension::ID) { | 630 } else if (id_ == AutomationMsg_EnableExtension::ID) { |
| 629 AutomationMsg_EnableExtension::WriteReplyParams(reply_message_.get(), true); | 631 AutomationMsg_EnableExtension::WriteReplyParams(reply_message_.get(), true); |
| 630 } else { | 632 } else { |
| 631 NOTREACHED(); | 633 NOTREACHED(); |
| 632 LOG(ERROR) << "Cannot write reply params for unknown message id."; | 634 LOG(ERROR) << "Cannot write reply params for unknown message id."; |
| 633 } | 635 } |
| 634 | 636 |
| 635 automation_->Send(reply_message_.release()); | 637 automation_->Send(reply_message_.release()); |
| 636 delete this; | 638 delete this; |
| 637 } | 639 } |
| 638 | 640 |
| 639 ExtensionUnloadNotificationObserver::ExtensionUnloadNotificationObserver() | 641 ExtensionUnloadNotificationObserver::ExtensionUnloadNotificationObserver() |
| 640 : did_receive_unload_notification_(false) { | 642 : did_receive_unload_notification_(false) { |
| 641 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 643 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 642 NotificationService::AllSources()); | 644 NotificationService::AllSources()); |
| 643 } | 645 } |
| 644 | 646 |
| 645 ExtensionUnloadNotificationObserver::~ExtensionUnloadNotificationObserver() { | 647 ExtensionUnloadNotificationObserver::~ExtensionUnloadNotificationObserver() { |
| 646 } | 648 } |
| 647 | 649 |
| 648 void ExtensionUnloadNotificationObserver::Observe( | 650 void ExtensionUnloadNotificationObserver::Observe( |
| 649 NotificationType type, const NotificationSource& source, | 651 int type, const NotificationSource& source, |
| 650 const NotificationDetails& details) { | 652 const NotificationDetails& details) { |
| 651 if (type.value == NotificationType::EXTENSION_UNLOADED) { | 653 if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { |
| 652 did_receive_unload_notification_ = true; | 654 did_receive_unload_notification_ = true; |
| 653 } else { | 655 } else { |
| 654 NOTREACHED(); | 656 NOTREACHED(); |
| 655 } | 657 } |
| 656 } | 658 } |
| 657 | 659 |
| 658 ExtensionsUpdatedObserver::ExtensionsUpdatedObserver( | 660 ExtensionsUpdatedObserver::ExtensionsUpdatedObserver( |
| 659 ExtensionProcessManager* manager, AutomationProvider* automation, | 661 ExtensionProcessManager* manager, AutomationProvider* automation, |
| 660 IPC::Message* reply_message) | 662 IPC::Message* reply_message) |
| 661 : manager_(manager), automation_(automation->AsWeakPtr()), | 663 : manager_(manager), automation_(automation->AsWeakPtr()), |
| 662 reply_message_(reply_message), updater_finished_(false) { | 664 reply_message_(reply_message), updater_finished_(false) { |
| 663 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 665 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
| 664 NotificationService::AllSources()); | 666 NotificationService::AllSources()); |
| 665 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_ERROR, | 667 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 666 NotificationService::AllSources()); | 668 NotificationService::AllSources()); |
| 667 registrar_.Add(this, NotificationType::EXTENSION_INSTALL_NOT_ALLOWED, | 669 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_NOT_ALLOWED, |
| 668 NotificationService::AllSources()); | 670 NotificationService::AllSources()); |
| 669 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 671 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 670 NotificationService::AllSources()); | 672 NotificationService::AllSources()); |
| 671 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, | 673 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 672 NotificationService::AllSources()); | 674 NotificationService::AllSources()); |
| 673 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_FOUND, | 675 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
| 674 NotificationService::AllSources()); | 676 NotificationService::AllSources()); |
| 675 registrar_.Add(this, NotificationType::EXTENSION_UPDATING_FINISHED, | 677 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED, |
| 676 NotificationService::AllSources()); | 678 NotificationService::AllSources()); |
| 677 } | 679 } |
| 678 | 680 |
| 679 ExtensionsUpdatedObserver::~ExtensionsUpdatedObserver() { | 681 ExtensionsUpdatedObserver::~ExtensionsUpdatedObserver() { |
| 680 } | 682 } |
| 681 | 683 |
| 682 void ExtensionsUpdatedObserver::Observe( | 684 void ExtensionsUpdatedObserver::Observe( |
| 683 NotificationType type, const NotificationSource& source, | 685 int type, const NotificationSource& source, |
| 684 const NotificationDetails& details) { | 686 const NotificationDetails& details) { |
| 685 if (!automation_) { | 687 if (!automation_) { |
| 686 delete this; | 688 delete this; |
| 687 return; | 689 return; |
| 688 } | 690 } |
| 689 | 691 |
| 690 // We expect the following sequence of events. First, the ExtensionUpdater | 692 // We expect the following sequence of events. First, the ExtensionUpdater |
| 691 // service notifies of each extension that needs to be updated. Once the | 693 // service notifies of each extension that needs to be updated. Once the |
| 692 // ExtensionUpdater has finished searching for extensions to update, it | 694 // ExtensionUpdater has finished searching for extensions to update, it |
| 693 // notifies that it is finished. Meanwhile, the extensions are updated | 695 // notifies that it is finished. Meanwhile, the extensions are updated |
| 694 // asynchronously: either they will be updated and loaded, or else they will | 696 // asynchronously: either they will be updated and loaded, or else they will |
| 695 // not load due to (1) not being allowed; (2) having updating disabled; or | 697 // not load due to (1) not being allowed; (2) having updating disabled; or |
| 696 // (3) encountering an error. Finally, notifications are also sent whenever | 698 // (3) encountering an error. Finally, notifications are also sent whenever |
| 697 // an extension host stops loading. Updating is not considered complete if | 699 // an extension host stops loading. Updating is not considered complete if |
| 698 // any extension hosts are still loading. | 700 // any extension hosts are still loading. |
| 699 switch (type.value) { | 701 switch (type) { |
| 700 case NotificationType::EXTENSION_UPDATE_FOUND: | 702 case chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND: |
| 701 // Extension updater has identified an extension that needs to be updated. | 703 // Extension updater has identified an extension that needs to be updated. |
| 702 in_progress_updates_.insert(*(Details<const std::string>(details).ptr())); | 704 in_progress_updates_.insert(*(Details<const std::string>(details).ptr())); |
| 703 break; | 705 break; |
| 704 | 706 |
| 705 case NotificationType::EXTENSION_UPDATING_FINISHED: | 707 case chrome::NOTIFICATION_EXTENSION_UPDATING_FINISHED: |
| 706 // Extension updater has completed notifying all extensions to update | 708 // Extension updater has completed notifying all extensions to update |
| 707 // themselves. | 709 // themselves. |
| 708 updater_finished_ = true; | 710 updater_finished_ = true; |
| 709 break; | 711 break; |
| 710 | 712 |
| 711 case NotificationType::EXTENSION_LOADED: | 713 case chrome::NOTIFICATION_EXTENSION_LOADED: |
| 712 case NotificationType::EXTENSION_INSTALL_NOT_ALLOWED: | 714 case chrome::NOTIFICATION_EXTENSION_INSTALL_NOT_ALLOWED: |
| 713 case NotificationType::EXTENSION_UPDATE_DISABLED: { | 715 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { |
| 714 // An extension has either completed update installation and is now | 716 // An extension has either completed update installation and is now |
| 715 // loaded, or else the install has been skipped because it is | 717 // loaded, or else the install has been skipped because it is |
| 716 // either not allowed or else has been disabled. | 718 // either not allowed or else has been disabled. |
| 717 const Extension* extension = Details<Extension>(details).ptr(); | 719 const Extension* extension = Details<Extension>(details).ptr(); |
| 718 in_progress_updates_.erase(extension->id()); | 720 in_progress_updates_.erase(extension->id()); |
| 719 break; | 721 break; |
| 720 } | 722 } |
| 721 | 723 |
| 722 case NotificationType::EXTENSION_INSTALL_ERROR: { | 724 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { |
| 723 // An extension had an error on update installation. | 725 // An extension had an error on update installation. |
| 724 CrxInstaller* installer = Source<CrxInstaller>(source).ptr(); | 726 CrxInstaller* installer = Source<CrxInstaller>(source).ptr(); |
| 725 in_progress_updates_.erase(installer->expected_id()); | 727 in_progress_updates_.erase(installer->expected_id()); |
| 726 break; | 728 break; |
| 727 } | 729 } |
| 728 | 730 |
| 729 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: | 731 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: |
| 730 // Break out to the conditional check below to see if all extension hosts | 732 // Break out to the conditional check below to see if all extension hosts |
| 731 // have stopped loading. | 733 // have stopped loading. |
| 732 break; | 734 break; |
| 733 | 735 |
| 734 default: | 736 default: |
| 735 NOTREACHED(); | 737 NOTREACHED(); |
| 736 break; | 738 break; |
| 737 } | 739 } |
| 738 | 740 |
| 739 // Send the reply if (1) the extension updater has finished notifying all | 741 // Send the reply if (1) the extension updater has finished notifying all |
| 740 // extensions to update themselves; (2) all extensions that need to be updated | 742 // extensions to update themselves; (2) all extensions that need to be updated |
| 741 // have completed installation and are now loaded; and (3) all extension hosts | 743 // have completed installation and are now loaded; and (3) all extension hosts |
| 742 // have stopped loading. | 744 // have stopped loading. |
| 743 if (updater_finished_ && in_progress_updates_.empty() && | 745 if (updater_finished_ && in_progress_updates_.empty() && |
| 744 DidExtensionHostsStopLoading(manager_)) { | 746 DidExtensionHostsStopLoading(manager_)) { |
| 745 AutomationJSONReply reply(automation_, reply_message_.release()); | 747 AutomationJSONReply reply(automation_, reply_message_.release()); |
| 746 reply.SendSuccess(NULL); | 748 reply.SendSuccess(NULL); |
| 747 delete this; | 749 delete this; |
| 748 } | 750 } |
| 749 } | 751 } |
| 750 | 752 |
| 751 ExtensionTestResultNotificationObserver:: | 753 ExtensionTestResultNotificationObserver:: |
| 752 ExtensionTestResultNotificationObserver(AutomationProvider* automation) | 754 ExtensionTestResultNotificationObserver(AutomationProvider* automation) |
| 753 : automation_(automation->AsWeakPtr()) { | 755 : automation_(automation->AsWeakPtr()) { |
| 754 registrar_.Add(this, NotificationType::EXTENSION_TEST_PASSED, | 756 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_PASSED, |
| 755 NotificationService::AllSources()); | 757 NotificationService::AllSources()); |
| 756 registrar_.Add(this, NotificationType::EXTENSION_TEST_FAILED, | 758 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_TEST_FAILED, |
| 757 NotificationService::AllSources()); | 759 NotificationService::AllSources()); |
| 758 } | 760 } |
| 759 | 761 |
| 760 ExtensionTestResultNotificationObserver:: | 762 ExtensionTestResultNotificationObserver:: |
| 761 ~ExtensionTestResultNotificationObserver() { | 763 ~ExtensionTestResultNotificationObserver() { |
| 762 } | 764 } |
| 763 | 765 |
| 764 void ExtensionTestResultNotificationObserver::Observe( | 766 void ExtensionTestResultNotificationObserver::Observe( |
| 765 NotificationType type, const NotificationSource& source, | 767 int type, const NotificationSource& source, |
| 766 const NotificationDetails& details) { | 768 const NotificationDetails& details) { |
| 767 switch (type.value) { | 769 switch (type) { |
| 768 case NotificationType::EXTENSION_TEST_PASSED: | 770 case chrome::NOTIFICATION_EXTENSION_TEST_PASSED: |
| 769 results_.push_back(true); | 771 results_.push_back(true); |
| 770 messages_.push_back(""); | 772 messages_.push_back(""); |
| 771 break; | 773 break; |
| 772 | 774 |
| 773 case NotificationType::EXTENSION_TEST_FAILED: | 775 case chrome::NOTIFICATION_EXTENSION_TEST_FAILED: |
| 774 results_.push_back(false); | 776 results_.push_back(false); |
| 775 messages_.push_back(*(Details<std::string>(details).ptr())); | 777 messages_.push_back(*(Details<std::string>(details).ptr())); |
| 776 break; | 778 break; |
| 777 | 779 |
| 778 default: | 780 default: |
| 779 NOTREACHED(); | 781 NOTREACHED(); |
| 780 } | 782 } |
| 781 // There may be a reply message waiting for this event, so check. | 783 // There may be a reply message waiting for this event, so check. |
| 782 MaybeSendResult(); | 784 MaybeSendResult(); |
| 783 } | 785 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 802 } | 804 } |
| 803 } | 805 } |
| 804 | 806 |
| 805 BrowserOpenedNotificationObserver::BrowserOpenedNotificationObserver( | 807 BrowserOpenedNotificationObserver::BrowserOpenedNotificationObserver( |
| 806 AutomationProvider* automation, | 808 AutomationProvider* automation, |
| 807 IPC::Message* reply_message) | 809 IPC::Message* reply_message) |
| 808 : automation_(automation->AsWeakPtr()), | 810 : automation_(automation->AsWeakPtr()), |
| 809 reply_message_(reply_message), | 811 reply_message_(reply_message), |
| 810 new_window_id_(extension_misc::kUnknownWindowId), | 812 new_window_id_(extension_misc::kUnknownWindowId), |
| 811 for_browser_command_(false) { | 813 for_browser_command_(false) { |
| 812 registrar_.Add(this, NotificationType::BROWSER_OPENED, | 814 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, |
| 813 NotificationService::AllSources()); | 815 NotificationService::AllSources()); |
| 814 registrar_.Add(this, NotificationType::LOAD_STOP, | 816 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 815 NotificationService::AllSources()); | 817 NotificationService::AllSources()); |
| 816 } | 818 } |
| 817 | 819 |
| 818 BrowserOpenedNotificationObserver::~BrowserOpenedNotificationObserver() { | 820 BrowserOpenedNotificationObserver::~BrowserOpenedNotificationObserver() { |
| 819 } | 821 } |
| 820 | 822 |
| 821 void BrowserOpenedNotificationObserver::Observe( | 823 void BrowserOpenedNotificationObserver::Observe( |
| 822 NotificationType type, const NotificationSource& source, | 824 int type, const NotificationSource& source, |
| 823 const NotificationDetails& details) { | 825 const NotificationDetails& details) { |
| 824 if (!automation_) { | 826 if (!automation_) { |
| 825 delete this; | 827 delete this; |
| 826 return; | 828 return; |
| 827 } | 829 } |
| 828 | 830 |
| 829 if (type.value == NotificationType::BROWSER_OPENED) { | 831 if (type == chrome::NOTIFICATION_BROWSER_OPENED) { |
| 830 // Store the new browser ID and continue waiting for a new tab within it | 832 // Store the new browser ID and continue waiting for a new tab within it |
| 831 // to stop loading. | 833 // to stop loading. |
| 832 new_window_id_ = ExtensionTabUtil::GetWindowId( | 834 new_window_id_ = ExtensionTabUtil::GetWindowId( |
| 833 Source<Browser>(source).ptr()); | 835 Source<Browser>(source).ptr()); |
| 834 } else if (type.value == NotificationType::LOAD_STOP) { | 836 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
| 835 // Only send the result if the loaded tab is in the new window. | 837 // Only send the result if the loaded tab is in the new window. |
| 836 NavigationController* controller = | 838 NavigationController* controller = |
| 837 Source<NavigationController>(source).ptr(); | 839 Source<NavigationController>(source).ptr(); |
| 838 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( | 840 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( |
| 839 controller->tab_contents()); | 841 controller->tab_contents()); |
| 840 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 842 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
| 841 if (window_id == new_window_id_) { | 843 if (window_id == new_window_id_) { |
| 842 if (for_browser_command_) { | 844 if (for_browser_command_) { |
| 843 AutomationMsg_WindowExecuteCommand::WriteReplyParams( | 845 AutomationMsg_WindowExecuteCommand::WriteReplyParams( |
| 844 reply_message_.get(), true); | 846 reply_message_.get(), true); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 857 for_browser_command_ = for_browser_command; | 859 for_browser_command_ = for_browser_command; |
| 858 } | 860 } |
| 859 | 861 |
| 860 BrowserClosedNotificationObserver::BrowserClosedNotificationObserver( | 862 BrowserClosedNotificationObserver::BrowserClosedNotificationObserver( |
| 861 Browser* browser, | 863 Browser* browser, |
| 862 AutomationProvider* automation, | 864 AutomationProvider* automation, |
| 863 IPC::Message* reply_message) | 865 IPC::Message* reply_message) |
| 864 : automation_(automation->AsWeakPtr()), | 866 : automation_(automation->AsWeakPtr()), |
| 865 reply_message_(reply_message), | 867 reply_message_(reply_message), |
| 866 for_browser_command_(false) { | 868 for_browser_command_(false) { |
| 867 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 869 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 868 Source<Browser>(browser)); | 870 Source<Browser>(browser)); |
| 869 } | 871 } |
| 870 | 872 |
| 871 BrowserClosedNotificationObserver::~BrowserClosedNotificationObserver() {} | 873 BrowserClosedNotificationObserver::~BrowserClosedNotificationObserver() {} |
| 872 | 874 |
| 873 void BrowserClosedNotificationObserver::Observe( | 875 void BrowserClosedNotificationObserver::Observe( |
| 874 NotificationType type, const NotificationSource& source, | 876 int type, const NotificationSource& source, |
| 875 const NotificationDetails& details) { | 877 const NotificationDetails& details) { |
| 876 DCHECK(type == NotificationType::BROWSER_CLOSED); | 878 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED); |
| 877 | 879 |
| 878 if (!automation_) { | 880 if (!automation_) { |
| 879 delete this; | 881 delete this; |
| 880 return; | 882 return; |
| 881 } | 883 } |
| 882 | 884 |
| 883 Details<bool> close_app(details); | 885 Details<bool> close_app(details); |
| 884 | 886 |
| 885 if (for_browser_command_) { | 887 if (for_browser_command_) { |
| 886 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), | 888 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 898 for_browser_command_ = for_browser_command; | 900 for_browser_command_ = for_browser_command; |
| 899 } | 901 } |
| 900 | 902 |
| 901 BrowserCountChangeNotificationObserver::BrowserCountChangeNotificationObserver( | 903 BrowserCountChangeNotificationObserver::BrowserCountChangeNotificationObserver( |
| 902 int target_count, | 904 int target_count, |
| 903 AutomationProvider* automation, | 905 AutomationProvider* automation, |
| 904 IPC::Message* reply_message) | 906 IPC::Message* reply_message) |
| 905 : target_count_(target_count), | 907 : target_count_(target_count), |
| 906 automation_(automation->AsWeakPtr()), | 908 automation_(automation->AsWeakPtr()), |
| 907 reply_message_(reply_message) { | 909 reply_message_(reply_message) { |
| 908 registrar_.Add(this, NotificationType::BROWSER_OPENED, | 910 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, |
| 909 NotificationService::AllSources()); | 911 NotificationService::AllSources()); |
| 910 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 912 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 911 NotificationService::AllSources()); | 913 NotificationService::AllSources()); |
| 912 } | 914 } |
| 913 | 915 |
| 914 BrowserCountChangeNotificationObserver:: | 916 BrowserCountChangeNotificationObserver:: |
| 915 ~BrowserCountChangeNotificationObserver() {} | 917 ~BrowserCountChangeNotificationObserver() {} |
| 916 | 918 |
| 917 void BrowserCountChangeNotificationObserver::Observe( | 919 void BrowserCountChangeNotificationObserver::Observe( |
| 918 NotificationType type, | 920 int type, |
| 919 const NotificationSource& source, | 921 const NotificationSource& source, |
| 920 const NotificationDetails& details) { | 922 const NotificationDetails& details) { |
| 921 DCHECK(type == NotificationType::BROWSER_OPENED || | 923 DCHECK(type == chrome::NOTIFICATION_BROWSER_OPENED || |
| 922 type == NotificationType::BROWSER_CLOSED); | 924 type == chrome::NOTIFICATION_BROWSER_CLOSED); |
| 923 int current_count = static_cast<int>(BrowserList::size()); | 925 int current_count = static_cast<int>(BrowserList::size()); |
| 924 if (type == NotificationType::BROWSER_CLOSED) { | 926 if (type == chrome::NOTIFICATION_BROWSER_CLOSED) { |
| 925 // At the time of the notification the browser being closed is not removed | 927 // At the time of the notification the browser being closed is not removed |
| 926 // from the list. The real count is one less than the reported count. | 928 // from the list. The real count is one less than the reported count. |
| 927 DCHECK_LT(0, current_count); | 929 DCHECK_LT(0, current_count); |
| 928 current_count--; | 930 current_count--; |
| 929 } | 931 } |
| 930 | 932 |
| 931 if (!automation_) { | 933 if (!automation_) { |
| 932 delete this; | 934 delete this; |
| 933 return; | 935 return; |
| 934 } | 936 } |
| 935 | 937 |
| 936 if (current_count == target_count_) { | 938 if (current_count == target_count_) { |
| 937 AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams( | 939 AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams( |
| 938 reply_message_.get(), true); | 940 reply_message_.get(), true); |
| 939 automation_->Send(reply_message_.release()); | 941 automation_->Send(reply_message_.release()); |
| 940 delete this; | 942 delete this; |
| 941 } | 943 } |
| 942 } | 944 } |
| 943 | 945 |
| 944 AppModalDialogShownObserver::AppModalDialogShownObserver( | 946 AppModalDialogShownObserver::AppModalDialogShownObserver( |
| 945 AutomationProvider* automation, IPC::Message* reply_message) | 947 AutomationProvider* automation, IPC::Message* reply_message) |
| 946 : automation_(automation->AsWeakPtr()), | 948 : automation_(automation->AsWeakPtr()), |
| 947 reply_message_(reply_message) { | 949 reply_message_(reply_message) { |
| 948 registrar_.Add(this, NotificationType::APP_MODAL_DIALOG_SHOWN, | 950 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
| 949 NotificationService::AllSources()); | 951 NotificationService::AllSources()); |
| 950 } | 952 } |
| 951 | 953 |
| 952 AppModalDialogShownObserver::~AppModalDialogShownObserver() { | 954 AppModalDialogShownObserver::~AppModalDialogShownObserver() { |
| 953 } | 955 } |
| 954 | 956 |
| 955 void AppModalDialogShownObserver::Observe( | 957 void AppModalDialogShownObserver::Observe( |
| 956 NotificationType type, const NotificationSource& source, | 958 int type, const NotificationSource& source, |
| 957 const NotificationDetails& details) { | 959 const NotificationDetails& details) { |
| 958 DCHECK(type == NotificationType::APP_MODAL_DIALOG_SHOWN); | 960 DCHECK(type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN); |
| 959 | 961 |
| 960 if (automation_) { | 962 if (automation_) { |
| 961 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams( | 963 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams( |
| 962 reply_message_.get(), true); | 964 reply_message_.get(), true); |
| 963 automation_->Send(reply_message_.release()); | 965 automation_->Send(reply_message_.release()); |
| 964 } | 966 } |
| 965 delete this; | 967 delete this; |
| 966 } | 968 } |
| 967 | 969 |
| 968 namespace { | 970 namespace { |
| 969 | 971 |
| 970 // Define mapping from command to notification | 972 // Define mapping from command to notification |
| 971 struct CommandNotification { | 973 struct CommandNotification { |
| 972 int command; | 974 int command; |
| 973 NotificationType::Type notification_type; | 975 int notification_type; |
| 974 }; | 976 }; |
| 975 | 977 |
| 976 const struct CommandNotification command_notifications[] = { | 978 const struct CommandNotification command_notifications[] = { |
| 977 {IDC_DUPLICATE_TAB, NotificationType::TAB_PARENTED}, | 979 {IDC_DUPLICATE_TAB, content::NOTIFICATION_TAB_PARENTED}, |
| 978 | 980 |
| 979 // Returns as soon as the restored tab is created. To further wait until | 981 // Returns as soon as the restored tab is created. To further wait until |
| 980 // the content page is loaded, use WaitForTabToBeRestored. | 982 // the content page is loaded, use WaitForTabToBeRestored. |
| 981 {IDC_RESTORE_TAB, NotificationType::TAB_PARENTED}, | 983 {IDC_RESTORE_TAB, content::NOTIFICATION_TAB_PARENTED}, |
| 982 | 984 |
| 983 // For the following commands, we need to wait for a new tab to be created, | 985 // For the following commands, we need to wait for a new tab to be created, |
| 984 // load to finish, and title to change. | 986 // load to finish, and title to change. |
| 985 {IDC_MANAGE_EXTENSIONS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, | 987 {IDC_MANAGE_EXTENSIONS, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED}, |
| 986 {IDC_OPTIONS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, | 988 {IDC_OPTIONS, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED}, |
| 987 {IDC_PRINT, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, | 989 {IDC_PRINT, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED}, |
| 988 {IDC_SHOW_DOWNLOADS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, | 990 {IDC_SHOW_DOWNLOADS, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED}, |
| 989 {IDC_SHOW_HISTORY, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, | 991 {IDC_SHOW_HISTORY, content::NOTIFICATION_TAB_CONTENTS_TITLE_UPDATED}, |
| 990 }; | 992 }; |
| 991 | 993 |
| 992 } // namespace | 994 } // namespace |
| 993 | 995 |
| 994 ExecuteBrowserCommandObserver::~ExecuteBrowserCommandObserver() { | 996 ExecuteBrowserCommandObserver::~ExecuteBrowserCommandObserver() { |
| 995 } | 997 } |
| 996 | 998 |
| 997 // static | 999 // static |
| 998 bool ExecuteBrowserCommandObserver::CreateAndRegisterObserver( | 1000 bool ExecuteBrowserCommandObserver::CreateAndRegisterObserver( |
| 999 AutomationProvider* automation, Browser* browser, int command, | 1001 AutomationProvider* automation, Browser* browser, int command, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 delete observer; | 1041 delete observer; |
| 1040 result = false; | 1042 result = false; |
| 1041 } | 1043 } |
| 1042 break; | 1044 break; |
| 1043 } | 1045 } |
| 1044 } | 1046 } |
| 1045 return result; | 1047 return result; |
| 1046 } | 1048 } |
| 1047 | 1049 |
| 1048 void ExecuteBrowserCommandObserver::Observe( | 1050 void ExecuteBrowserCommandObserver::Observe( |
| 1049 NotificationType type, const NotificationSource& source, | 1051 int type, const NotificationSource& source, |
| 1050 const NotificationDetails& details) { | 1052 const NotificationDetails& details) { |
| 1051 if (type == notification_type_) { | 1053 if (type == notification_type_) { |
| 1052 if (automation_) { | 1054 if (automation_) { |
| 1053 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), | 1055 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), |
| 1054 true); | 1056 true); |
| 1055 automation_->Send(reply_message_.release()); | 1057 automation_->Send(reply_message_.release()); |
| 1056 } | 1058 } |
| 1057 delete this; | 1059 delete this; |
| 1058 } else { | 1060 } else { |
| 1059 NOTREACHED(); | 1061 NOTREACHED(); |
| 1060 } | 1062 } |
| 1061 } | 1063 } |
| 1062 | 1064 |
| 1063 ExecuteBrowserCommandObserver::ExecuteBrowserCommandObserver( | 1065 ExecuteBrowserCommandObserver::ExecuteBrowserCommandObserver( |
| 1064 AutomationProvider* automation, IPC::Message* reply_message) | 1066 AutomationProvider* automation, IPC::Message* reply_message) |
| 1065 : automation_(automation->AsWeakPtr()), | 1067 : automation_(automation->AsWeakPtr()), |
| 1066 notification_type_(NotificationType::ALL), | 1068 notification_type_(content::NOTIFICATION_ALL), |
| 1067 reply_message_(reply_message) { | 1069 reply_message_(reply_message) { |
| 1068 } | 1070 } |
| 1069 | 1071 |
| 1070 bool ExecuteBrowserCommandObserver::Register(int command) { | 1072 bool ExecuteBrowserCommandObserver::Register(int command) { |
| 1071 if (!GetNotificationType(command, ¬ification_type_)) | 1073 if (!Getint(command, ¬ification_type_)) |
| 1072 return false; | 1074 return false; |
| 1073 registrar_.Add(this, notification_type_, NotificationService::AllSources()); | 1075 registrar_.Add(this, notification_type_, NotificationService::AllSources()); |
| 1074 return true; | 1076 return true; |
| 1075 } | 1077 } |
| 1076 | 1078 |
| 1077 bool ExecuteBrowserCommandObserver::GetNotificationType( | 1079 bool ExecuteBrowserCommandObserver::Getint( |
| 1078 int command, NotificationType::Type* type) { | 1080 int command, int* type) { |
| 1079 if (!type) | 1081 if (!type) |
| 1080 return false; | 1082 return false; |
| 1081 bool found = false; | 1083 bool found = false; |
| 1082 for (unsigned int i = 0; i < arraysize(command_notifications); i++) { | 1084 for (unsigned int i = 0; i < arraysize(command_notifications); i++) { |
| 1083 if (command_notifications[i].command == command) { | 1085 if (command_notifications[i].command == command) { |
| 1084 *type = command_notifications[i].notification_type; | 1086 *type = command_notifications[i].notification_type; |
| 1085 found = true; | 1087 found = true; |
| 1086 break; | 1088 break; |
| 1087 } | 1089 } |
| 1088 } | 1090 } |
| 1089 return found; | 1091 return found; |
| 1090 } | 1092 } |
| 1091 | 1093 |
| 1092 FindInPageNotificationObserver::FindInPageNotificationObserver( | 1094 FindInPageNotificationObserver::FindInPageNotificationObserver( |
| 1093 AutomationProvider* automation, TabContents* parent_tab, | 1095 AutomationProvider* automation, TabContents* parent_tab, |
| 1094 bool reply_with_json, IPC::Message* reply_message) | 1096 bool reply_with_json, IPC::Message* reply_message) |
| 1095 : automation_(automation->AsWeakPtr()), | 1097 : automation_(automation->AsWeakPtr()), |
| 1096 active_match_ordinal_(-1), | 1098 active_match_ordinal_(-1), |
| 1097 reply_with_json_(reply_with_json), | 1099 reply_with_json_(reply_with_json), |
| 1098 reply_message_(reply_message) { | 1100 reply_message_(reply_message) { |
| 1099 registrar_.Add(this, NotificationType::FIND_RESULT_AVAILABLE, | 1101 registrar_.Add(this, chrome::NOTIFICATION_FIND_RESULT_AVAILABLE, |
| 1100 Source<TabContents>(parent_tab)); | 1102 Source<TabContents>(parent_tab)); |
| 1101 } | 1103 } |
| 1102 | 1104 |
| 1103 FindInPageNotificationObserver::~FindInPageNotificationObserver() { | 1105 FindInPageNotificationObserver::~FindInPageNotificationObserver() { |
| 1104 } | 1106 } |
| 1105 | 1107 |
| 1106 void FindInPageNotificationObserver::Observe( | 1108 void FindInPageNotificationObserver::Observe( |
| 1107 NotificationType type, const NotificationSource& source, | 1109 int type, const NotificationSource& source, |
| 1108 const NotificationDetails& details) { | 1110 const NotificationDetails& details) { |
| 1109 Details<FindNotificationDetails> find_details(details); | 1111 Details<FindNotificationDetails> find_details(details); |
| 1110 if (!(find_details->final_update() && reply_message_ != NULL)) { | 1112 if (!(find_details->final_update() && reply_message_ != NULL)) { |
| 1111 DVLOG(1) << "Ignoring, since we only care about the final message"; | 1113 DVLOG(1) << "Ignoring, since we only care about the final message"; |
| 1112 return; | 1114 return; |
| 1113 } | 1115 } |
| 1114 | 1116 |
| 1115 if (!automation_) { | 1117 if (!automation_) { |
| 1116 delete this; | 1118 delete this; |
| 1117 return; | 1119 return; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1145 automation_->Send(reply_message_.release()); | 1147 automation_->Send(reply_message_.release()); |
| 1146 } | 1148 } |
| 1147 } | 1149 } |
| 1148 } | 1150 } |
| 1149 } | 1151 } |
| 1150 | 1152 |
| 1151 // static | 1153 // static |
| 1152 const int FindInPageNotificationObserver::kFindInPageRequestId = -1; | 1154 const int FindInPageNotificationObserver::kFindInPageRequestId = -1; |
| 1153 | 1155 |
| 1154 DomOperationObserver::DomOperationObserver() { | 1156 DomOperationObserver::DomOperationObserver() { |
| 1155 registrar_.Add(this, NotificationType::DOM_OPERATION_RESPONSE, | 1157 registrar_.Add(this, chrome::NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 1156 NotificationService::AllSources()); | 1158 NotificationService::AllSources()); |
| 1157 } | 1159 } |
| 1158 | 1160 |
| 1159 DomOperationObserver::~DomOperationObserver() {} | 1161 DomOperationObserver::~DomOperationObserver() {} |
| 1160 | 1162 |
| 1161 void DomOperationObserver::Observe( | 1163 void DomOperationObserver::Observe( |
| 1162 NotificationType type, const NotificationSource& source, | 1164 int type, const NotificationSource& source, |
| 1163 const NotificationDetails& details) { | 1165 const NotificationDetails& details) { |
| 1164 if (NotificationType::DOM_OPERATION_RESPONSE == type) { | 1166 if (chrome::NOTIFICATION_DOM_OPERATION_RESPONSE == type) { |
| 1165 Details<DomOperationNotificationDetails> dom_op_details(details); | 1167 Details<DomOperationNotificationDetails> dom_op_details(details); |
| 1166 OnDomOperationCompleted(dom_op_details->json()); | 1168 OnDomOperationCompleted(dom_op_details->json()); |
| 1167 } | 1169 } |
| 1168 } | 1170 } |
| 1169 | 1171 |
| 1170 DomOperationMessageSender::DomOperationMessageSender( | 1172 DomOperationMessageSender::DomOperationMessageSender( |
| 1171 AutomationProvider* automation, | 1173 AutomationProvider* automation, |
| 1172 IPC::Message* reply_message, | 1174 IPC::Message* reply_message, |
| 1173 bool use_json_interface) | 1175 bool use_json_interface) |
| 1174 : automation_(automation->AsWeakPtr()), | 1176 : automation_(automation->AsWeakPtr()), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1192 } | 1194 } |
| 1193 } | 1195 } |
| 1194 delete this; | 1196 delete this; |
| 1195 } | 1197 } |
| 1196 | 1198 |
| 1197 DocumentPrintedNotificationObserver::DocumentPrintedNotificationObserver( | 1199 DocumentPrintedNotificationObserver::DocumentPrintedNotificationObserver( |
| 1198 AutomationProvider* automation, IPC::Message* reply_message) | 1200 AutomationProvider* automation, IPC::Message* reply_message) |
| 1199 : automation_(automation->AsWeakPtr()), | 1201 : automation_(automation->AsWeakPtr()), |
| 1200 success_(false), | 1202 success_(false), |
| 1201 reply_message_(reply_message) { | 1203 reply_message_(reply_message) { |
| 1202 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT, | 1204 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, |
| 1203 NotificationService::AllSources()); | 1205 NotificationService::AllSources()); |
| 1204 } | 1206 } |
| 1205 | 1207 |
| 1206 DocumentPrintedNotificationObserver::~DocumentPrintedNotificationObserver() { | 1208 DocumentPrintedNotificationObserver::~DocumentPrintedNotificationObserver() { |
| 1207 if (automation_) { | 1209 if (automation_) { |
| 1208 AutomationMsg_PrintNow::WriteReplyParams(reply_message_.get(), success_); | 1210 AutomationMsg_PrintNow::WriteReplyParams(reply_message_.get(), success_); |
| 1209 automation_->Send(reply_message_.release()); | 1211 automation_->Send(reply_message_.release()); |
| 1210 } | 1212 } |
| 1211 } | 1213 } |
| 1212 | 1214 |
| 1213 void DocumentPrintedNotificationObserver::Observe( | 1215 void DocumentPrintedNotificationObserver::Observe( |
| 1214 NotificationType type, | 1216 int type, |
| 1215 const NotificationSource& source, | 1217 const NotificationSource& source, |
| 1216 const NotificationDetails& details) { | 1218 const NotificationDetails& details) { |
| 1217 DCHECK(type == NotificationType::PRINT_JOB_EVENT); | 1219 DCHECK(type == chrome::NOTIFICATION_PRINT_JOB_EVENT); |
| 1218 switch (Details<printing::JobEventDetails>(details)->type()) { | 1220 switch (Details<printing::JobEventDetails>(details)->type()) { |
| 1219 case printing::JobEventDetails::JOB_DONE: { | 1221 case printing::JobEventDetails::JOB_DONE: { |
| 1220 // Succeeded. | 1222 // Succeeded. |
| 1221 success_ = true; | 1223 success_ = true; |
| 1222 delete this; | 1224 delete this; |
| 1223 break; | 1225 break; |
| 1224 } | 1226 } |
| 1225 case printing::JobEventDetails::USER_INIT_CANCELED: | 1227 case printing::JobEventDetails::USER_INIT_CANCELED: |
| 1226 case printing::JobEventDetails::FAILED: { | 1228 case printing::JobEventDetails::FAILED: { |
| 1227 // Failed. | 1229 // Failed. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1239 break; | 1241 break; |
| 1240 } | 1242 } |
| 1241 default: { | 1243 default: { |
| 1242 NOTREACHED(); | 1244 NOTREACHED(); |
| 1243 break; | 1245 break; |
| 1244 } | 1246 } |
| 1245 } | 1247 } |
| 1246 } | 1248 } |
| 1247 | 1249 |
| 1248 MetricEventDurationObserver::MetricEventDurationObserver() { | 1250 MetricEventDurationObserver::MetricEventDurationObserver() { |
| 1249 registrar_.Add(this, NotificationType::METRIC_EVENT_DURATION, | 1251 registrar_.Add(this, chrome::NOTIFICATION_METRIC_EVENT_DURATION, |
| 1250 NotificationService::AllSources()); | 1252 NotificationService::AllSources()); |
| 1251 } | 1253 } |
| 1252 | 1254 |
| 1253 MetricEventDurationObserver::~MetricEventDurationObserver() {} | 1255 MetricEventDurationObserver::~MetricEventDurationObserver() {} |
| 1254 | 1256 |
| 1255 int MetricEventDurationObserver::GetEventDurationMs( | 1257 int MetricEventDurationObserver::GetEventDurationMs( |
| 1256 const std::string& event_name) { | 1258 const std::string& event_name) { |
| 1257 EventDurationMap::const_iterator it = durations_.find(event_name); | 1259 EventDurationMap::const_iterator it = durations_.find(event_name); |
| 1258 if (it == durations_.end()) | 1260 if (it == durations_.end()) |
| 1259 return -1; | 1261 return -1; |
| 1260 return it->second; | 1262 return it->second; |
| 1261 } | 1263 } |
| 1262 | 1264 |
| 1263 void MetricEventDurationObserver::Observe(NotificationType type, | 1265 void MetricEventDurationObserver::Observe(int type, |
| 1264 const NotificationSource& source, const NotificationDetails& details) { | 1266 const NotificationSource& source, const NotificationDetails& details) { |
| 1265 if (type != NotificationType::METRIC_EVENT_DURATION) { | 1267 if (type != chrome::NOTIFICATION_METRIC_EVENT_DURATION) { |
| 1266 NOTREACHED(); | 1268 NOTREACHED(); |
| 1267 return; | 1269 return; |
| 1268 } | 1270 } |
| 1269 MetricEventDurationDetails* metric_event_duration = | 1271 MetricEventDurationDetails* metric_event_duration = |
| 1270 Details<MetricEventDurationDetails>(details).ptr(); | 1272 Details<MetricEventDurationDetails>(details).ptr(); |
| 1271 durations_[metric_event_duration->event_name] = | 1273 durations_[metric_event_duration->event_name] = |
| 1272 metric_event_duration->duration_ms; | 1274 metric_event_duration->duration_ms; |
| 1273 } | 1275 } |
| 1274 | 1276 |
| 1275 PageTranslatedObserver::PageTranslatedObserver(AutomationProvider* automation, | 1277 PageTranslatedObserver::PageTranslatedObserver(AutomationProvider* automation, |
| 1276 IPC::Message* reply_message, | 1278 IPC::Message* reply_message, |
| 1277 TabContents* tab_contents) | 1279 TabContents* tab_contents) |
| 1278 : automation_(automation->AsWeakPtr()), | 1280 : automation_(automation->AsWeakPtr()), |
| 1279 reply_message_(reply_message) { | 1281 reply_message_(reply_message) { |
| 1280 registrar_.Add(this, NotificationType::PAGE_TRANSLATED, | 1282 registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED, |
| 1281 Source<TabContents>(tab_contents)); | 1283 Source<TabContents>(tab_contents)); |
| 1282 } | 1284 } |
| 1283 | 1285 |
| 1284 PageTranslatedObserver::~PageTranslatedObserver() {} | 1286 PageTranslatedObserver::~PageTranslatedObserver() {} |
| 1285 | 1287 |
| 1286 void PageTranslatedObserver::Observe(NotificationType type, | 1288 void PageTranslatedObserver::Observe(int type, |
| 1287 const NotificationSource& source, | 1289 const NotificationSource& source, |
| 1288 const NotificationDetails& details) { | 1290 const NotificationDetails& details) { |
| 1289 if (!automation_) { | 1291 if (!automation_) { |
| 1290 delete this; | 1292 delete this; |
| 1291 return; | 1293 return; |
| 1292 } | 1294 } |
| 1293 | 1295 |
| 1294 DCHECK(type == NotificationType::PAGE_TRANSLATED); | 1296 DCHECK(type == chrome::NOTIFICATION_PAGE_TRANSLATED); |
| 1295 AutomationJSONReply reply(automation_, reply_message_.release()); | 1297 AutomationJSONReply reply(automation_, reply_message_.release()); |
| 1296 | 1298 |
| 1297 PageTranslatedDetails* translated_details = | 1299 PageTranslatedDetails* translated_details = |
| 1298 Details<PageTranslatedDetails>(details).ptr(); | 1300 Details<PageTranslatedDetails>(details).ptr(); |
| 1299 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1301 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 1300 return_value->SetBoolean( | 1302 return_value->SetBoolean( |
| 1301 "translation_success", | 1303 "translation_success", |
| 1302 translated_details->error_type == TranslateErrors::NONE); | 1304 translated_details->error_type == TranslateErrors::NONE); |
| 1303 reply.SendSuccess(return_value.get()); | 1305 reply.SendSuccess(return_value.get()); |
| 1304 delete this; | 1306 delete this; |
| 1305 } | 1307 } |
| 1306 | 1308 |
| 1307 TabLanguageDeterminedObserver::TabLanguageDeterminedObserver( | 1309 TabLanguageDeterminedObserver::TabLanguageDeterminedObserver( |
| 1308 AutomationProvider* automation, IPC::Message* reply_message, | 1310 AutomationProvider* automation, IPC::Message* reply_message, |
| 1309 TabContents* tab_contents, TranslateInfoBarDelegate* translate_bar) | 1311 TabContents* tab_contents, TranslateInfoBarDelegate* translate_bar) |
| 1310 : automation_(automation->AsWeakPtr()), | 1312 : automation_(automation->AsWeakPtr()), |
| 1311 reply_message_(reply_message), | 1313 reply_message_(reply_message), |
| 1312 tab_contents_(tab_contents), | 1314 tab_contents_(tab_contents), |
| 1313 translate_bar_(translate_bar) { | 1315 translate_bar_(translate_bar) { |
| 1314 registrar_.Add(this, NotificationType::TAB_LANGUAGE_DETERMINED, | 1316 registrar_.Add(this, chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 1315 Source<TabContents>(tab_contents)); | 1317 Source<TabContents>(tab_contents)); |
| 1316 } | 1318 } |
| 1317 | 1319 |
| 1318 TabLanguageDeterminedObserver::~TabLanguageDeterminedObserver() {} | 1320 TabLanguageDeterminedObserver::~TabLanguageDeterminedObserver() {} |
| 1319 | 1321 |
| 1320 void TabLanguageDeterminedObserver::Observe( | 1322 void TabLanguageDeterminedObserver::Observe( |
| 1321 NotificationType type, const NotificationSource& source, | 1323 int type, const NotificationSource& source, |
| 1322 const NotificationDetails& details) { | 1324 const NotificationDetails& details) { |
| 1323 DCHECK(type == NotificationType::TAB_LANGUAGE_DETERMINED); | 1325 DCHECK(type == chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED); |
| 1324 | 1326 |
| 1325 if (!automation_) { | 1327 if (!automation_) { |
| 1326 delete this; | 1328 delete this; |
| 1327 return; | 1329 return; |
| 1328 } | 1330 } |
| 1329 | 1331 |
| 1330 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( | 1332 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( |
| 1331 tab_contents_)->translate_tab_helper(); | 1333 tab_contents_)->translate_tab_helper(); |
| 1332 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1334 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 1333 return_value->SetBoolean("page_translated", | 1335 return_value->SetBoolean("page_translated", |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 | 1371 |
| 1370 InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, | 1372 InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, |
| 1371 IPC::Message* reply_message, | 1373 IPC::Message* reply_message, |
| 1372 TabContentsWrapper* tab_contents, | 1374 TabContentsWrapper* tab_contents, |
| 1373 size_t target_count) | 1375 size_t target_count) |
| 1374 : automation_(automation->AsWeakPtr()), | 1376 : automation_(automation->AsWeakPtr()), |
| 1375 reply_message_(reply_message), | 1377 reply_message_(reply_message), |
| 1376 tab_contents_(tab_contents), | 1378 tab_contents_(tab_contents), |
| 1377 target_count_(target_count) { | 1379 target_count_(target_count) { |
| 1378 Source<TabContentsWrapper> source(tab_contents); | 1380 Source<TabContentsWrapper> source(tab_contents); |
| 1379 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_ADDED, source); | 1381 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 1380 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source); | 1382 source); |
| 1383 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
| 1384 source); |
| 1381 CheckCount(); | 1385 CheckCount(); |
| 1382 } | 1386 } |
| 1383 | 1387 |
| 1384 InfoBarCountObserver::~InfoBarCountObserver() {} | 1388 InfoBarCountObserver::~InfoBarCountObserver() {} |
| 1385 | 1389 |
| 1386 void InfoBarCountObserver::Observe(NotificationType type, | 1390 void InfoBarCountObserver::Observe(int type, |
| 1387 const NotificationSource& source, | 1391 const NotificationSource& source, |
| 1388 const NotificationDetails& details) { | 1392 const NotificationDetails& details) { |
| 1389 DCHECK(type == NotificationType::TAB_CONTENTS_INFOBAR_ADDED || | 1393 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED || |
| 1390 type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED); | 1394 type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); |
| 1391 CheckCount(); | 1395 CheckCount(); |
| 1392 } | 1396 } |
| 1393 | 1397 |
| 1394 void InfoBarCountObserver::CheckCount() { | 1398 void InfoBarCountObserver::CheckCount() { |
| 1395 if (tab_contents_->infobar_count() != target_count_) | 1399 if (tab_contents_->infobar_count() != target_count_) |
| 1396 return; | 1400 return; |
| 1397 | 1401 |
| 1398 if (automation_) { | 1402 if (automation_) { |
| 1399 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(), | 1403 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(), |
| 1400 true); | 1404 true); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 BrowserThread::PostTask( | 1717 BrowserThread::PostTask( |
| 1714 BrowserThread::DB, | 1718 BrowserThread::DB, |
| 1715 FROM_HERE, | 1719 FROM_HERE, |
| 1716 NewRunnableMethod( | 1720 NewRunnableMethod( |
| 1717 this, &PasswordStoreLoginsChangedObserver::RegisterObserversTask)); | 1721 this, &PasswordStoreLoginsChangedObserver::RegisterObserversTask)); |
| 1718 done_event_.Wait(); | 1722 done_event_.Wait(); |
| 1719 } | 1723 } |
| 1720 | 1724 |
| 1721 void PasswordStoreLoginsChangedObserver::RegisterObserversTask() { | 1725 void PasswordStoreLoginsChangedObserver::RegisterObserversTask() { |
| 1722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 1726 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 1723 registrar_.Add(this, NotificationType::LOGINS_CHANGED, | 1727 registrar_.Add(this, chrome::NOTIFICATION_LOGINS_CHANGED, |
| 1724 NotificationService::AllSources()); | 1728 NotificationService::AllSources()); |
| 1725 done_event_.Signal(); | 1729 done_event_.Signal(); |
| 1726 } | 1730 } |
| 1727 | 1731 |
| 1728 void PasswordStoreLoginsChangedObserver::Observe( | 1732 void PasswordStoreLoginsChangedObserver::Observe( |
| 1729 NotificationType type, | 1733 int type, |
| 1730 const NotificationSource& source, | 1734 const NotificationSource& source, |
| 1731 const NotificationDetails& details) { | 1735 const NotificationDetails& details) { |
| 1732 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 1736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 1733 DCHECK(type.value == NotificationType::LOGINS_CHANGED); | 1737 DCHECK(type == chrome::NOTIFICATION_LOGINS_CHANGED); |
| 1734 PasswordStoreChangeList* change_details = | 1738 PasswordStoreChangeList* change_details = |
| 1735 Details<PasswordStoreChangeList>(details).ptr(); | 1739 Details<PasswordStoreChangeList>(details).ptr(); |
| 1736 if (change_details->size() != 1 || | 1740 if (change_details->size() != 1 || |
| 1737 change_details->front().type() != expected_type_) { | 1741 change_details->front().type() != expected_type_) { |
| 1738 // Notify the UI thread that there's an error. | 1742 // Notify the UI thread that there's an error. |
| 1739 std::string error = "Unexpected password store login change details."; | 1743 std::string error = "Unexpected password store login change details."; |
| 1740 BrowserThread::PostTask( | 1744 BrowserThread::PostTask( |
| 1741 BrowserThread::UI, | 1745 BrowserThread::UI, |
| 1742 FROM_HERE, | 1746 FROM_HERE, |
| 1743 NewRunnableMethod( | 1747 NewRunnableMethod( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 } | 1800 } |
| 1797 | 1801 |
| 1798 OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver( | 1802 OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver( |
| 1799 NavigationController* controller, | 1803 NavigationController* controller, |
| 1800 AutomationProvider* automation, | 1804 AutomationProvider* automation, |
| 1801 IPC::Message* reply_message) | 1805 IPC::Message* reply_message) |
| 1802 : automation_(automation->AsWeakPtr()), | 1806 : automation_(automation->AsWeakPtr()), |
| 1803 reply_message_(reply_message), | 1807 reply_message_(reply_message), |
| 1804 controller_(controller) { | 1808 controller_(controller) { |
| 1805 Source<NavigationController> source(controller_); | 1809 Source<NavigationController> source(controller_); |
| 1806 registrar_.Add(this, NotificationType::LOAD_STOP, source); | 1810 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); |
| 1807 // Pages requiring auth don't send LOAD_STOP. | 1811 // Pages requiring auth don't send LOAD_STOP. |
| 1808 registrar_.Add(this, NotificationType::AUTH_NEEDED, source); | 1812 registrar_.Add(this, chrome::NOTIFICATION_AUTH_NEEDED, source); |
| 1809 } | 1813 } |
| 1810 | 1814 |
| 1811 OmniboxAcceptNotificationObserver::~OmniboxAcceptNotificationObserver() { | 1815 OmniboxAcceptNotificationObserver::~OmniboxAcceptNotificationObserver() { |
| 1812 } | 1816 } |
| 1813 | 1817 |
| 1814 void OmniboxAcceptNotificationObserver::Observe( | 1818 void OmniboxAcceptNotificationObserver::Observe( |
| 1815 NotificationType type, | 1819 int type, |
| 1816 const NotificationSource& source, | 1820 const NotificationSource& source, |
| 1817 const NotificationDetails& details) { | 1821 const NotificationDetails& details) { |
| 1818 if (type == NotificationType::LOAD_STOP || | 1822 if (type == content::NOTIFICATION_LOAD_STOP || |
| 1819 type == NotificationType::AUTH_NEEDED) { | 1823 type == chrome::NOTIFICATION_AUTH_NEEDED) { |
| 1820 if (automation_) { | 1824 if (automation_) { |
| 1821 AutomationJSONReply(automation_, | 1825 AutomationJSONReply(automation_, |
| 1822 reply_message_.release()).SendSuccess(NULL); | 1826 reply_message_.release()).SendSuccess(NULL); |
| 1823 } | 1827 } |
| 1824 delete this; | 1828 delete this; |
| 1825 } else { | 1829 } else { |
| 1826 NOTREACHED(); | 1830 NOTREACHED(); |
| 1827 } | 1831 } |
| 1828 } | 1832 } |
| 1829 | 1833 |
| 1830 SavePackageNotificationObserver::SavePackageNotificationObserver( | 1834 SavePackageNotificationObserver::SavePackageNotificationObserver( |
| 1831 SavePackage* save_package, | 1835 SavePackage* save_package, |
| 1832 AutomationProvider* automation, | 1836 AutomationProvider* automation, |
| 1833 IPC::Message* reply_message) | 1837 IPC::Message* reply_message) |
| 1834 : automation_(automation->AsWeakPtr()), | 1838 : automation_(automation->AsWeakPtr()), |
| 1835 reply_message_(reply_message) { | 1839 reply_message_(reply_message) { |
| 1836 Source<SavePackage> source(save_package); | 1840 Source<SavePackage> source(save_package); |
| 1837 registrar_.Add(this, NotificationType::SAVE_PACKAGE_SUCCESSFULLY_FINISHED, | 1841 registrar_.Add(this, chrome::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED, |
| 1838 source); | 1842 source); |
| 1839 } | 1843 } |
| 1840 | 1844 |
| 1841 SavePackageNotificationObserver::~SavePackageNotificationObserver() {} | 1845 SavePackageNotificationObserver::~SavePackageNotificationObserver() {} |
| 1842 | 1846 |
| 1843 void SavePackageNotificationObserver::Observe( | 1847 void SavePackageNotificationObserver::Observe( |
| 1844 NotificationType type, | 1848 int type, |
| 1845 const NotificationSource& source, | 1849 const NotificationSource& source, |
| 1846 const NotificationDetails& details) { | 1850 const NotificationDetails& details) { |
| 1847 if (type == NotificationType::SAVE_PACKAGE_SUCCESSFULLY_FINISHED) { | 1851 if (type == chrome::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED) { |
| 1848 if (automation_) { | 1852 if (automation_) { |
| 1849 AutomationJSONReply(automation_, | 1853 AutomationJSONReply(automation_, |
| 1850 reply_message_.release()).SendSuccess(NULL); | 1854 reply_message_.release()).SendSuccess(NULL); |
| 1851 } | 1855 } |
| 1852 delete this; | 1856 delete this; |
| 1853 } else { | 1857 } else { |
| 1854 NOTREACHED(); | 1858 NOTREACHED(); |
| 1855 } | 1859 } |
| 1856 } | 1860 } |
| 1857 | 1861 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 | 2045 |
| 2042 // Add default site URLs. | 2046 // Add default site URLs. |
| 2043 ListValue* default_sites_list = new ListValue; | 2047 ListValue* default_sites_list = new ListValue; |
| 2044 std::vector<GURL> urls = MostVisitedHandler::GetPrePopulatedUrls(); | 2048 std::vector<GURL> urls = MostVisitedHandler::GetPrePopulatedUrls(); |
| 2045 for (size_t i = 0; i < urls.size(); ++i) { | 2049 for (size_t i = 0; i < urls.size(); ++i) { |
| 2046 default_sites_list->Append(Value::CreateStringValue( | 2050 default_sites_list->Append(Value::CreateStringValue( |
| 2047 urls[i].possibly_invalid_spec())); | 2051 urls[i].possibly_invalid_spec())); |
| 2048 } | 2052 } |
| 2049 ntp_info_->Set("default_sites", default_sites_list); | 2053 ntp_info_->Set("default_sites", default_sites_list); |
| 2050 | 2054 |
| 2051 registrar_.Add(this, NotificationType::TOP_SITES_UPDATED, | 2055 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_UPDATED, |
| 2052 Source<history::TopSites>(top_sites_)); | 2056 Source<history::TopSites>(top_sites_)); |
| 2053 if (top_sites_->loaded()) { | 2057 if (top_sites_->loaded()) { |
| 2054 OnTopSitesLoaded(); | 2058 OnTopSitesLoaded(); |
| 2055 } else { | 2059 } else { |
| 2056 registrar_.Add(this, NotificationType::TOP_SITES_LOADED, | 2060 registrar_.Add(this, chrome::NOTIFICATION_TOP_SITES_LOADED, |
| 2057 Source<Profile>(automation_->profile())); | 2061 Source<Profile>(automation_->profile())); |
| 2058 } | 2062 } |
| 2059 } | 2063 } |
| 2060 | 2064 |
| 2061 NTPInfoObserver::~NTPInfoObserver() {} | 2065 NTPInfoObserver::~NTPInfoObserver() {} |
| 2062 | 2066 |
| 2063 void NTPInfoObserver::Observe(NotificationType type, | 2067 void NTPInfoObserver::Observe(int type, |
| 2064 const NotificationSource& source, | 2068 const NotificationSource& source, |
| 2065 const NotificationDetails& details) { | 2069 const NotificationDetails& details) { |
| 2066 if (type == NotificationType::TOP_SITES_LOADED) { | 2070 if (type == chrome::NOTIFICATION_TOP_SITES_LOADED) { |
| 2067 OnTopSitesLoaded(); | 2071 OnTopSitesLoaded(); |
| 2068 } else if (type == NotificationType::TOP_SITES_UPDATED) { | 2072 } else if (type == chrome::NOTIFICATION_TOP_SITES_UPDATED) { |
| 2069 Details<CancelableRequestProvider::Handle> request_details(details); | 2073 Details<CancelableRequestProvider::Handle> request_details(details); |
| 2070 if (request_ == *request_details.ptr()) { | 2074 if (request_ == *request_details.ptr()) { |
| 2071 top_sites_->GetMostVisitedURLs( | 2075 top_sites_->GetMostVisitedURLs( |
| 2072 consumer_, | 2076 consumer_, |
| 2073 NewCallback(this, &NTPInfoObserver::OnTopSitesReceived)); | 2077 NewCallback(this, &NTPInfoObserver::OnTopSitesReceived)); |
| 2074 } | 2078 } |
| 2075 } | 2079 } |
| 2076 } | 2080 } |
| 2077 | 2081 |
| 2078 void NTPInfoObserver::OnTopSitesLoaded() { | 2082 void NTPInfoObserver::OnTopSitesLoaded() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2109 IPC::Message* reply_message, | 2113 IPC::Message* reply_message, |
| 2110 extension_misc::LaunchContainer launch_container) | 2114 extension_misc::LaunchContainer launch_container) |
| 2111 : controller_(controller), | 2115 : controller_(controller), |
| 2112 automation_(automation->AsWeakPtr()), | 2116 automation_(automation->AsWeakPtr()), |
| 2113 reply_message_(reply_message), | 2117 reply_message_(reply_message), |
| 2114 launch_container_(launch_container), | 2118 launch_container_(launch_container), |
| 2115 new_window_id_(extension_misc::kUnknownWindowId) { | 2119 new_window_id_(extension_misc::kUnknownWindowId) { |
| 2116 if (launch_container_ == extension_misc::LAUNCH_TAB) { | 2120 if (launch_container_ == extension_misc::LAUNCH_TAB) { |
| 2117 // Need to wait for the currently-active tab to reload. | 2121 // Need to wait for the currently-active tab to reload. |
| 2118 Source<NavigationController> source(controller_); | 2122 Source<NavigationController> source(controller_); |
| 2119 registrar_.Add(this, NotificationType::LOAD_STOP, source); | 2123 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); |
| 2120 } else { | 2124 } else { |
| 2121 // Need to wait for a new tab in a new window to load. | 2125 // Need to wait for a new tab in a new window to load. |
| 2122 registrar_.Add(this, NotificationType::LOAD_STOP, | 2126 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 2123 NotificationService::AllSources()); | 2127 NotificationService::AllSources()); |
| 2124 registrar_.Add(this, NotificationType::BROWSER_WINDOW_READY, | 2128 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 2125 NotificationService::AllSources()); | 2129 NotificationService::AllSources()); |
| 2126 } | 2130 } |
| 2127 } | 2131 } |
| 2128 | 2132 |
| 2129 AppLaunchObserver::~AppLaunchObserver() {} | 2133 AppLaunchObserver::~AppLaunchObserver() {} |
| 2130 | 2134 |
| 2131 void AppLaunchObserver::Observe(NotificationType type, | 2135 void AppLaunchObserver::Observe(int type, |
| 2132 const NotificationSource& source, | 2136 const NotificationSource& source, |
| 2133 const NotificationDetails& details) { | 2137 const NotificationDetails& details) { |
| 2134 if (type.value == NotificationType::LOAD_STOP) { | 2138 if (type == content::NOTIFICATION_LOAD_STOP) { |
| 2135 if (launch_container_ == extension_misc::LAUNCH_TAB) { | 2139 if (launch_container_ == extension_misc::LAUNCH_TAB) { |
| 2136 // The app has been launched in the new tab. | 2140 // The app has been launched in the new tab. |
| 2137 if (automation_) { | 2141 if (automation_) { |
| 2138 AutomationJSONReply(automation_, | 2142 AutomationJSONReply(automation_, |
| 2139 reply_message_.release()).SendSuccess(NULL); | 2143 reply_message_.release()).SendSuccess(NULL); |
| 2140 } | 2144 } |
| 2141 delete this; | 2145 delete this; |
| 2142 return; | 2146 return; |
| 2143 } else { | 2147 } else { |
| 2144 // The app has launched only if the loaded tab is in the new window. | 2148 // The app has launched only if the loaded tab is in the new window. |
| 2145 NavigationController* controller = | 2149 NavigationController* controller = |
| 2146 Source<NavigationController>(source).ptr(); | 2150 Source<NavigationController>(source).ptr(); |
| 2147 TabContentsWrapper* tab = | 2151 TabContentsWrapper* tab = |
| 2148 TabContentsWrapper::GetCurrentWrapperForContents( | 2152 TabContentsWrapper::GetCurrentWrapperForContents( |
| 2149 controller->tab_contents()); | 2153 controller->tab_contents()); |
| 2150 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 2154 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
| 2151 if (window_id == new_window_id_) { | 2155 if (window_id == new_window_id_) { |
| 2152 if (automation_) { | 2156 if (automation_) { |
| 2153 AutomationJSONReply(automation_, | 2157 AutomationJSONReply(automation_, |
| 2154 reply_message_.release()).SendSuccess(NULL); | 2158 reply_message_.release()).SendSuccess(NULL); |
| 2155 } | 2159 } |
| 2156 delete this; | 2160 delete this; |
| 2157 return; | 2161 return; |
| 2158 } | 2162 } |
| 2159 } | 2163 } |
| 2160 } else if (type.value == NotificationType::BROWSER_WINDOW_READY) { | 2164 } else if (type == chrome::NOTIFICATION_BROWSER_WINDOW_READY) { |
| 2161 new_window_id_ = ExtensionTabUtil::GetWindowId( | 2165 new_window_id_ = ExtensionTabUtil::GetWindowId( |
| 2162 Source<Browser>(source).ptr()); | 2166 Source<Browser>(source).ptr()); |
| 2163 } else { | 2167 } else { |
| 2164 NOTREACHED(); | 2168 NOTREACHED(); |
| 2165 } | 2169 } |
| 2166 } | 2170 } |
| 2167 | 2171 |
| 2168 AutofillDisplayedObserver::AutofillDisplayedObserver( | 2172 AutofillDisplayedObserver::AutofillDisplayedObserver( |
| 2169 NotificationType notification, | 2173 int notification, |
| 2170 RenderViewHost* render_view_host, | 2174 RenderViewHost* render_view_host, |
| 2171 AutomationProvider* automation, | 2175 AutomationProvider* automation, |
| 2172 IPC::Message* reply_message) | 2176 IPC::Message* reply_message) |
| 2173 : notification_(notification), | 2177 : notification_(notification), |
| 2174 render_view_host_(render_view_host), | 2178 render_view_host_(render_view_host), |
| 2175 automation_(automation->AsWeakPtr()), | 2179 automation_(automation->AsWeakPtr()), |
| 2176 reply_message_(reply_message) { | 2180 reply_message_(reply_message) { |
| 2177 Source<RenderViewHost> source(render_view_host_); | 2181 Source<RenderViewHost> source(render_view_host_); |
| 2178 registrar_.Add(this, notification_, source); | 2182 registrar_.Add(this, notification_, source); |
| 2179 } | 2183 } |
| 2180 | 2184 |
| 2181 AutofillDisplayedObserver::~AutofillDisplayedObserver() {} | 2185 AutofillDisplayedObserver::~AutofillDisplayedObserver() {} |
| 2182 | 2186 |
| 2183 void AutofillDisplayedObserver::Observe( | 2187 void AutofillDisplayedObserver::Observe( |
| 2184 NotificationType type, | 2188 int type, |
| 2185 const NotificationSource& source, | 2189 const NotificationSource& source, |
| 2186 const NotificationDetails& details) { | 2190 const NotificationDetails& details) { |
| 2187 DCHECK_EQ(type.value, notification_.value); | 2191 DCHECK_EQ(type, notification_); |
| 2188 DCHECK_EQ(Source<RenderViewHost>(source).ptr(), render_view_host_); | 2192 DCHECK_EQ(Source<RenderViewHost>(source).ptr(), render_view_host_); |
| 2189 if (automation_) { | 2193 if (automation_) { |
| 2190 AutomationJSONReply(automation_, | 2194 AutomationJSONReply(automation_, |
| 2191 reply_message_.release()).SendSuccess(NULL); | 2195 reply_message_.release()).SendSuccess(NULL); |
| 2192 } | 2196 } |
| 2193 delete this; | 2197 delete this; |
| 2194 } | 2198 } |
| 2195 | 2199 |
| 2196 AutofillChangedObserver::AutofillChangedObserver( | 2200 AutofillChangedObserver::AutofillChangedObserver( |
| 2197 AutomationProvider* automation, | 2201 AutomationProvider* automation, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2216 BrowserThread::PostTask( | 2220 BrowserThread::PostTask( |
| 2217 BrowserThread::DB, | 2221 BrowserThread::DB, |
| 2218 FROM_HERE, | 2222 FROM_HERE, |
| 2219 NewRunnableMethod(this, &AutofillChangedObserver::RegisterObserversTask)); | 2223 NewRunnableMethod(this, &AutofillChangedObserver::RegisterObserversTask)); |
| 2220 done_event_.Wait(); | 2224 done_event_.Wait(); |
| 2221 } | 2225 } |
| 2222 | 2226 |
| 2223 void AutofillChangedObserver::RegisterObserversTask() { | 2227 void AutofillChangedObserver::RegisterObserversTask() { |
| 2224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 2228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 2225 registrar_.Add(this, NotificationType::AUTOFILL_CREDIT_CARD_CHANGED, | 2229 registrar_.Add(this, chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, |
| 2226 NotificationService::AllSources()); | 2230 NotificationService::AllSources()); |
| 2227 registrar_.Add(this, NotificationType::AUTOFILL_PROFILE_CHANGED, | 2231 registrar_.Add(this, chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
| 2228 NotificationService::AllSources()); | 2232 NotificationService::AllSources()); |
| 2229 done_event_.Signal(); | 2233 done_event_.Signal(); |
| 2230 } | 2234 } |
| 2231 | 2235 |
| 2232 void AutofillChangedObserver::Observe( | 2236 void AutofillChangedObserver::Observe( |
| 2233 NotificationType type, | 2237 int type, |
| 2234 const NotificationSource& source, | 2238 const NotificationSource& source, |
| 2235 const NotificationDetails& details) { | 2239 const NotificationDetails& details) { |
| 2236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 2240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 2237 | 2241 |
| 2238 if (type.value == NotificationType::AUTOFILL_CREDIT_CARD_CHANGED) { | 2242 if (type == chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED) { |
| 2239 num_credit_cards_--; | 2243 num_credit_cards_--; |
| 2240 } else if (type.value == NotificationType::AUTOFILL_PROFILE_CHANGED) { | 2244 } else if (type == chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED) { |
| 2241 num_profiles_--; | 2245 num_profiles_--; |
| 2242 } else { | 2246 } else { |
| 2243 NOTREACHED(); | 2247 NOTREACHED(); |
| 2244 } | 2248 } |
| 2245 | 2249 |
| 2246 if (num_profiles_ == 0 && num_credit_cards_ == 0) { | 2250 if (num_profiles_ == 0 && num_credit_cards_ == 0) { |
| 2247 registrar_.RemoveAll(); // Must be done from the DB thread. | 2251 registrar_.RemoveAll(); // Must be done from the DB thread. |
| 2248 | 2252 |
| 2249 // Notify the UI thread that we're done listening for all relevant | 2253 // Notify the UI thread that we're done listening for all relevant |
| 2250 // autofill notifications. | 2254 // autofill notifications. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2282 } // namespace | 2286 } // namespace |
| 2283 | 2287 |
| 2284 GetActiveNotificationsObserver::GetActiveNotificationsObserver( | 2288 GetActiveNotificationsObserver::GetActiveNotificationsObserver( |
| 2285 AutomationProvider* automation, | 2289 AutomationProvider* automation, |
| 2286 IPC::Message* reply_message) | 2290 IPC::Message* reply_message) |
| 2287 : automation_(automation->AsWeakPtr()), | 2291 : automation_(automation->AsWeakPtr()), |
| 2288 reply_message_(reply_message) { | 2292 reply_message_(reply_message) { |
| 2289 if (AreActiveNotificationProcessesReady()) { | 2293 if (AreActiveNotificationProcessesReady()) { |
| 2290 SendMessage(); | 2294 SendMessage(); |
| 2291 } else { | 2295 } else { |
| 2292 registrar_.Add(this, NotificationType::NOTIFY_BALLOON_CONNECTED, | 2296 registrar_.Add(this, chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED, |
| 2293 NotificationService::AllSources()); | 2297 NotificationService::AllSources()); |
| 2294 } | 2298 } |
| 2295 } | 2299 } |
| 2296 | 2300 |
| 2297 GetActiveNotificationsObserver::~GetActiveNotificationsObserver() {} | 2301 GetActiveNotificationsObserver::~GetActiveNotificationsObserver() {} |
| 2298 | 2302 |
| 2299 void GetActiveNotificationsObserver::Observe( | 2303 void GetActiveNotificationsObserver::Observe( |
| 2300 NotificationType type, | 2304 int type, |
| 2301 const NotificationSource& source, | 2305 const NotificationSource& source, |
| 2302 const NotificationDetails& details) { | 2306 const NotificationDetails& details) { |
| 2303 if (!automation_) { | 2307 if (!automation_) { |
| 2304 delete this; | 2308 delete this; |
| 2305 return; | 2309 return; |
| 2306 } | 2310 } |
| 2307 if (AreActiveNotificationProcessesReady()) | 2311 if (AreActiveNotificationProcessesReady()) |
| 2308 SendMessage(); | 2312 SendMessage(); |
| 2309 } | 2313 } |
| 2310 | 2314 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2335 | 2339 |
| 2336 OnNotificationBalloonCountObserver::OnNotificationBalloonCountObserver( | 2340 OnNotificationBalloonCountObserver::OnNotificationBalloonCountObserver( |
| 2337 AutomationProvider* provider, | 2341 AutomationProvider* provider, |
| 2338 IPC::Message* reply_message, | 2342 IPC::Message* reply_message, |
| 2339 int count) | 2343 int count) |
| 2340 : automation_(provider->AsWeakPtr()), | 2344 : automation_(provider->AsWeakPtr()), |
| 2341 reply_message_(reply_message), | 2345 reply_message_(reply_message), |
| 2342 collection_( | 2346 collection_( |
| 2343 g_browser_process->notification_ui_manager()->balloon_collection()), | 2347 g_browser_process->notification_ui_manager()->balloon_collection()), |
| 2344 count_(count) { | 2348 count_(count) { |
| 2345 registrar_.Add(this, NotificationType::NOTIFY_BALLOON_CONNECTED, | 2349 registrar_.Add(this, chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED, |
| 2346 NotificationService::AllSources()); | 2350 NotificationService::AllSources()); |
| 2347 collection_->set_on_collection_changed_callback(NewCallback( | 2351 collection_->set_on_collection_changed_callback(NewCallback( |
| 2348 this, &OnNotificationBalloonCountObserver::CheckBalloonCount)); | 2352 this, &OnNotificationBalloonCountObserver::CheckBalloonCount)); |
| 2349 CheckBalloonCount(); | 2353 CheckBalloonCount(); |
| 2350 } | 2354 } |
| 2351 | 2355 |
| 2352 OnNotificationBalloonCountObserver::~OnNotificationBalloonCountObserver() { | 2356 OnNotificationBalloonCountObserver::~OnNotificationBalloonCountObserver() { |
| 2353 } | 2357 } |
| 2354 | 2358 |
| 2355 void OnNotificationBalloonCountObserver::Observe( | 2359 void OnNotificationBalloonCountObserver::Observe( |
| 2356 NotificationType type, | 2360 int type, |
| 2357 const NotificationSource& source, | 2361 const NotificationSource& source, |
| 2358 const NotificationDetails& details) { | 2362 const NotificationDetails& details) { |
| 2359 CheckBalloonCount(); | 2363 CheckBalloonCount(); |
| 2360 } | 2364 } |
| 2361 | 2365 |
| 2362 void OnNotificationBalloonCountObserver::CheckBalloonCount() { | 2366 void OnNotificationBalloonCountObserver::CheckBalloonCount() { |
| 2363 bool balloon_count_met = AreActiveNotificationProcessesReady() && | 2367 bool balloon_count_met = AreActiveNotificationProcessesReady() && |
| 2364 static_cast<int>(collection_->GetActiveBalloons().size()) == count_; | 2368 static_cast<int>(collection_->GetActiveBalloons().size()) == count_; |
| 2365 | 2369 |
| 2366 if (balloon_count_met && automation_) { | 2370 if (balloon_count_met && automation_) { |
| 2367 AutomationJSONReply(automation_, | 2371 AutomationJSONReply(automation_, |
| 2368 reply_message_.release()).SendSuccess(NULL); | 2372 reply_message_.release()).SendSuccess(NULL); |
| 2369 } | 2373 } |
| 2370 | 2374 |
| 2371 if (balloon_count_met || !automation_) { | 2375 if (balloon_count_met || !automation_) { |
| 2372 collection_->set_on_collection_changed_callback(NULL); | 2376 collection_->set_on_collection_changed_callback(NULL); |
| 2373 delete this; | 2377 delete this; |
| 2374 } | 2378 } |
| 2375 } | 2379 } |
| 2376 | 2380 |
| 2377 RendererProcessClosedObserver::RendererProcessClosedObserver( | 2381 RendererProcessClosedObserver::RendererProcessClosedObserver( |
| 2378 AutomationProvider* automation, | 2382 AutomationProvider* automation, |
| 2379 IPC::Message* reply_message) | 2383 IPC::Message* reply_message) |
| 2380 : automation_(automation->AsWeakPtr()), | 2384 : automation_(automation->AsWeakPtr()), |
| 2381 reply_message_(reply_message) { | 2385 reply_message_(reply_message) { |
| 2382 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, | 2386 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 2383 NotificationService::AllSources()); | 2387 NotificationService::AllSources()); |
| 2384 } | 2388 } |
| 2385 | 2389 |
| 2386 RendererProcessClosedObserver::~RendererProcessClosedObserver() {} | 2390 RendererProcessClosedObserver::~RendererProcessClosedObserver() {} |
| 2387 | 2391 |
| 2388 void RendererProcessClosedObserver::Observe( | 2392 void RendererProcessClosedObserver::Observe( |
| 2389 NotificationType type, | 2393 int type, |
| 2390 const NotificationSource& source, | 2394 const NotificationSource& source, |
| 2391 const NotificationDetails& details) { | 2395 const NotificationDetails& details) { |
| 2392 if (automation_) { | 2396 if (automation_) { |
| 2393 AutomationJSONReply(automation_, | 2397 AutomationJSONReply(automation_, |
| 2394 reply_message_.release()).SendSuccess(NULL); | 2398 reply_message_.release()).SendSuccess(NULL); |
| 2395 } | 2399 } |
| 2396 delete this; | 2400 delete this; |
| 2397 } | 2401 } |
| 2398 | 2402 |
| 2399 InputEventAckNotificationObserver::InputEventAckNotificationObserver( | 2403 InputEventAckNotificationObserver::InputEventAckNotificationObserver( |
| 2400 AutomationProvider* automation, | 2404 AutomationProvider* automation, |
| 2401 IPC::Message* reply_message, | 2405 IPC::Message* reply_message, |
| 2402 int event_type, | 2406 int event_type, |
| 2403 int count) | 2407 int count) |
| 2404 : automation_(automation->AsWeakPtr()), | 2408 : automation_(automation->AsWeakPtr()), |
| 2405 reply_message_(reply_message), | 2409 reply_message_(reply_message), |
| 2406 event_type_(event_type), | 2410 event_type_(event_type), |
| 2407 count_(count) { | 2411 count_(count) { |
| 2408 DCHECK(1 <= count); | 2412 DCHECK(1 <= count); |
| 2409 registrar_.Add( | 2413 registrar_.Add( |
| 2410 this, NotificationType::RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, | 2414 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK
, |
| 2411 NotificationService::AllSources()); | 2415 NotificationService::AllSources()); |
| 2412 } | 2416 } |
| 2413 | 2417 |
| 2414 InputEventAckNotificationObserver::~InputEventAckNotificationObserver() {} | 2418 InputEventAckNotificationObserver::~InputEventAckNotificationObserver() {} |
| 2415 | 2419 |
| 2416 void InputEventAckNotificationObserver::Observe( | 2420 void InputEventAckNotificationObserver::Observe( |
| 2417 NotificationType type, | 2421 int type, |
| 2418 const NotificationSource& source, | 2422 const NotificationSource& source, |
| 2419 const NotificationDetails& details) { | 2423 const NotificationDetails& details) { |
| 2420 Details<int> request_details(details); | 2424 Details<int> request_details(details); |
| 2421 // If the event type matches for |count_| times, replies with a JSON message. | 2425 // If the event type matches for |count_| times, replies with a JSON message. |
| 2422 if (event_type_ == *request_details.ptr()) { | 2426 if (event_type_ == *request_details.ptr()) { |
| 2423 if (--count_ == 0 && automation_) { | 2427 if (--count_ == 0 && automation_) { |
| 2424 AutomationJSONReply(automation_, | 2428 AutomationJSONReply(automation_, |
| 2425 reply_message_.release()).SendSuccess(NULL); | 2429 reply_message_.release()).SendSuccess(NULL); |
| 2426 delete this; | 2430 delete this; |
| 2427 } | 2431 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2489 delete this; | 2493 delete this; |
| 2490 } | 2494 } |
| 2491 } | 2495 } |
| 2492 | 2496 |
| 2493 NewTabObserver::NewTabObserver(AutomationProvider* automation, | 2497 NewTabObserver::NewTabObserver(AutomationProvider* automation, |
| 2494 IPC::Message* reply_message) | 2498 IPC::Message* reply_message) |
| 2495 : automation_(automation->AsWeakPtr()), | 2499 : automation_(automation->AsWeakPtr()), |
| 2496 reply_message_(reply_message) { | 2500 reply_message_(reply_message) { |
| 2497 // Use TAB_PARENTED to detect the new tab. | 2501 // Use TAB_PARENTED to detect the new tab. |
| 2498 registrar_.Add(this, | 2502 registrar_.Add(this, |
| 2499 NotificationType::TAB_PARENTED, | 2503 content::NOTIFICATION_TAB_PARENTED, |
| 2500 NotificationService::AllSources()); | 2504 NotificationService::AllSources()); |
| 2501 } | 2505 } |
| 2502 | 2506 |
| 2503 void NewTabObserver::Observe(NotificationType type, | 2507 void NewTabObserver::Observe(int type, |
| 2504 const NotificationSource& source, | 2508 const NotificationSource& source, |
| 2505 const NotificationDetails& details) { | 2509 const NotificationDetails& details) { |
| 2506 DCHECK_EQ(NotificationType::TAB_PARENTED, type.value); | 2510 DCHECK_EQ(content::NOTIFICATION_TAB_PARENTED, type); |
| 2507 NavigationController* controller = | 2511 NavigationController* controller = |
| 2508 &(Source<TabContentsWrapper>(source).ptr()->controller()); | 2512 &(Source<TabContentsWrapper>(source).ptr()->controller()); |
| 2509 if (automation_) { | 2513 if (automation_) { |
| 2510 // TODO(phajdan.jr): Clean up this hack. We write the correct return type | 2514 // TODO(phajdan.jr): Clean up this hack. We write the correct return type |
| 2511 // here, but don't send the message. NavigationNotificationObserver | 2515 // here, but don't send the message. NavigationNotificationObserver |
| 2512 // will wait properly for the load to finish, and send the message, | 2516 // will wait properly for the load to finish, and send the message, |
| 2513 // but it will also append its own return value at the end of the reply. | 2517 // but it will also append its own return value at the end of the reply. |
| 2514 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), | 2518 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), |
| 2515 true); | 2519 true); |
| 2516 new NavigationNotificationObserver(controller, automation_, | 2520 new NavigationNotificationObserver(controller, automation_, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 Release(); | 2574 Release(); |
| 2571 } | 2575 } |
| 2572 | 2576 |
| 2573 DragTargetDropAckNotificationObserver::DragTargetDropAckNotificationObserver( | 2577 DragTargetDropAckNotificationObserver::DragTargetDropAckNotificationObserver( |
| 2574 AutomationProvider* automation, | 2578 AutomationProvider* automation, |
| 2575 IPC::Message* reply_message) | 2579 IPC::Message* reply_message) |
| 2576 : automation_(automation->AsWeakPtr()), | 2580 : automation_(automation->AsWeakPtr()), |
| 2577 reply_message_(reply_message) { | 2581 reply_message_(reply_message) { |
| 2578 registrar_.Add( | 2582 registrar_.Add( |
| 2579 this, | 2583 this, |
| 2580 NotificationType::RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK, | 2584 content::NOTIFICATION_RENDER_VIEW_HOST_DID_RECEIVE_DRAG_TARGET_DROP_ACK, |
| 2581 NotificationService::AllSources()); | 2585 NotificationService::AllSources()); |
| 2582 } | 2586 } |
| 2583 | 2587 |
| 2584 DragTargetDropAckNotificationObserver:: | 2588 DragTargetDropAckNotificationObserver:: |
| 2585 ~DragTargetDropAckNotificationObserver() {} | 2589 ~DragTargetDropAckNotificationObserver() {} |
| 2586 | 2590 |
| 2587 void DragTargetDropAckNotificationObserver::Observe( | 2591 void DragTargetDropAckNotificationObserver::Observe( |
| 2588 NotificationType type, | 2592 int type, |
| 2589 const NotificationSource& source, | 2593 const NotificationSource& source, |
| 2590 const NotificationDetails& details) { | 2594 const NotificationDetails& details) { |
| 2591 if (automation_) { | 2595 if (automation_) { |
| 2592 AutomationJSONReply(automation_, | 2596 AutomationJSONReply(automation_, |
| 2593 reply_message_.release()).SendSuccess(NULL); | 2597 reply_message_.release()).SendSuccess(NULL); |
| 2594 } | 2598 } |
| 2595 delete this; | 2599 delete this; |
| 2596 } | 2600 } |
| OLD | NEW |