OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 // the right profile. | 579 // the right profile. |
580 registrar_.Add(this, NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, | 580 registrar_.Add(this, NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, |
581 content::Source<Profile>(profile)); | 581 content::Source<Profile>(profile)); |
582 | 582 |
583 // Set a timeout for waiting for the notification that the popup is loaded. | 583 // Set a timeout for waiting for the notification that the popup is loaded. |
584 // Waiting is required so that the popup view can be retrieved by the custom | 584 // Waiting is required so that the popup view can be retrieved by the custom |
585 // bindings for the response callback. It's also needed to keep this function | 585 // bindings for the response callback. It's also needed to keep this function |
586 // instance around until a notification is observed. | 586 // instance around until a notification is observed. |
587 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 587 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
588 FROM_HERE, | 588 FROM_HERE, |
589 base::Bind(&BrowserActionOpenPopupFunction::OpenPopupTimedOut, this), | 589 base::BindOnce(&BrowserActionOpenPopupFunction::OpenPopupTimedOut, this), |
590 base::TimeDelta::FromSeconds(10)); | 590 base::TimeDelta::FromSeconds(10)); |
591 return true; | 591 return true; |
592 } | 592 } |
593 | 593 |
594 void BrowserActionOpenPopupFunction::OpenPopupTimedOut() { | 594 void BrowserActionOpenPopupFunction::OpenPopupTimedOut() { |
595 if (response_sent_) | 595 if (response_sent_) |
596 return; | 596 return; |
597 | 597 |
598 DVLOG(1) << "chrome.browserAction.openPopup did not show a popup."; | 598 DVLOG(1) << "chrome.browserAction.openPopup did not show a popup."; |
599 error_ = kOpenPopupError; | 599 error_ = kOpenPopupError; |
(...skipping 13 matching lines...) Expand all Loading... |
613 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 613 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
614 host->extension()->id() != extension_->id()) | 614 host->extension()->id() != extension_->id()) |
615 return; | 615 return; |
616 | 616 |
617 SendResponse(true); | 617 SendResponse(true); |
618 response_sent_ = true; | 618 response_sent_ = true; |
619 registrar_.RemoveAll(); | 619 registrar_.RemoveAll(); |
620 } | 620 } |
621 | 621 |
622 } // namespace extensions | 622 } // namespace extensions |
OLD | NEW |