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

Unified Diff: chrome/browser/chromeos/arc/arc_support_host.cc

Issue 2380683008: Fix resource leak on extension window closing. (Closed)
Patch Set: Address comments. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/arc_support_host.cc
diff --git a/chrome/browser/chromeos/arc/arc_support_host.cc b/chrome/browser/chromeos/arc/arc_support_host.cc
index fe4452513f15e4e0ae5d20576fa8fab5bfca5fae..9fd69720979e3c56b70f03ed264230704d1025eb 100644
--- a/chrome/browser/chromeos/arc/arc_support_host.cc
+++ b/chrome/browser/chromeos/arc/arc_support_host.cc
@@ -47,14 +47,17 @@ const char kActionBackupAndRestoreMode[] = "setBackupAndRestoreMode";
const char kActionLocationServiceMode[] = "setLocationServiceMode";
const char kActionSetWindowBounds[] = "setWindowBounds";
const char kActionStartLso[] = "startLso";
-const char kActionCancelAuthCode[] = "cancelAuthCode";
const char kActionSetAuthCode[] = "setAuthCode";
const char kActionEnableMetrics[] = "enableMetrics";
const char kActionSendFeedback[] = "sendFeedback";
const char kActionSetBackupRestore[] = "setBackupRestore";
const char kActionSetLocationService[] = "setLocationService";
-const char kActionCloseUI[] = "closeUI";
+const char kActionCloseWindow[] = "closeWindow";
const char kActionShowPage[] = "showPage";
+
+// Fired when the extension window is closed.
+const char kActionOnWindowClosed[] = "onWindowClosed";
+
} // namespace
// static
@@ -109,12 +112,24 @@ ArcSupportHost::~ArcSupportHost() {
arc_auth_service->RemoveObserver(this);
}
+void ArcSupportHost::Close() {
+ if (!client_)
+ return;
+
+ close_requested_ = true;
+ base::DictionaryValue response;
+ response.SetString(kAction, kActionCloseWindow);
+ std::string response_string;
+ base::JSONWriter::Write(response, &response_string);
+ client_->PostMessageFromNativeHost(response_string);
+}
+
void ArcSupportHost::Start(Client* client) {
DCHECK(!client_);
client_ = client;
if (!Initialize()) {
- OnOptInUIClose();
+ Close();
return;
}
@@ -285,14 +300,7 @@ void ArcSupportHost::SendLocationServicesMode() {
}
void ArcSupportHost::OnOptInUIClose() {
- if (!client_)
- return;
-
- base::DictionaryValue response;
- response.SetString(kAction, kActionCloseUI);
- std::string response_string;
- base::JSONWriter::Write(response, &response_string);
- client_->PostMessageFromNativeHost(response_string);
+ Close();
}
void ArcSupportHost::OnOptInUIShowPage(arc::ArcAuthService::UIPage page,
@@ -354,8 +362,9 @@ void ArcSupportHost::OnMessage(const std::string& request_string) {
return;
}
arc_auth_service->SetAuthCodeAndStartArc(code);
- } else if (action == kActionCancelAuthCode) {
- arc_auth_service->CancelAuthCode();
+ } else if (action == kActionOnWindowClosed) {
+ if (!close_requested_)
+ arc_auth_service->CancelAuthCode();
} else if (action == kActionEnableMetrics) {
bool is_enabled;
if (!request->GetBoolean(kEnabled, &is_enabled)) {
« no previous file with comments | « chrome/browser/chromeos/arc/arc_support_host.h ('k') | chrome/browser/resources/chromeos/arc_support/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698