| 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/ui/webui/inspect_ui.h" | 5 #include "chrome/browser/ui/webui/inspect_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 StopListeningNotifications(); | 397 StopListeningNotifications(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 void InspectUI::RefreshUI() { | 400 void InspectUI::RefreshUI() { |
| 401 web_ui()->CallJavascriptFunction("populateLists"); | 401 web_ui()->CallJavascriptFunction("populateLists"); |
| 402 } | 402 } |
| 403 | 403 |
| 404 void InspectUI::Observe(int type, | 404 void InspectUI::Observe(int type, |
| 405 const content::NotificationSource& source, | 405 const content::NotificationSource& source, |
| 406 const content::NotificationDetails& details) { | 406 const content::NotificationDetails& details) { |
| 407 if (source == content::Source<WebContents>(web_ui()->GetWebContents())) { | 407 if (source != content::Source<WebContents>(web_ui()->GetWebContents())) |
| 408 if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED) | 408 RefreshUI(); |
| 409 StopListeningNotifications(); | 409 else if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED) |
| 410 return; | 410 StopListeningNotifications(); |
| 411 } | |
| 412 RefreshUI(); | |
| 413 } | 411 } |
| 414 | 412 |
| 415 void InspectUI::StopListeningNotifications() | 413 void InspectUI::StopListeningNotifications() |
| 416 { | 414 { |
| 417 if (!observer_) | 415 if (!observer_) |
| 418 return; | 416 return; |
| 419 observer_->InspectUIDestroyed(); | 417 observer_->InspectUIDestroyed(); |
| 420 observer_ = NULL; | 418 observer_ = NULL; |
| 421 registrar_.RemoveAll(); | 419 registrar_.RemoveAll(); |
| 422 } | 420 } |
| OLD | NEW |