| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/login/ui/shared_web_view.h" | 5 #include "chrome/browser/chromeos/login/ui/shared_web_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/chromeos/login/ui/web_view_handle.h" | 8 #include "chrome/browser/chromeos/login/ui/web_view_handle.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
| 12 #include "content/public/browser/render_widget_host.h" | 12 #include "content/public/browser/render_widget_host.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "ui/views/controls/webview/webview.h" | 14 #include "ui/views/controls/webview/webview.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 SharedWebView::SharedWebView(Profile* profile) : profile_(profile) { | 18 SharedWebView::SharedWebView(Profile* profile) : profile_(profile) { |
| 19 registrar_.Add(this, chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 19 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 20 content::NotificationService::AllSources()); | 20 content::NotificationService::AllSources()); |
| 21 memory_pressure_listener_ = base::MakeUnique<base::MemoryPressureListener>( | 21 memory_pressure_listener_ = base::MakeUnique<base::MemoryPressureListener>( |
| 22 base::Bind(&SharedWebView::OnMemoryPressure, base::Unretained(this))); | 22 base::Bind(&SharedWebView::OnMemoryPressure, base::Unretained(this))); |
| 23 } | 23 } |
| 24 | 24 |
| 25 SharedWebView::~SharedWebView() {} | 25 SharedWebView::~SharedWebView() {} |
| 26 | 26 |
| 27 void SharedWebView::Shutdown() { | 27 void SharedWebView::Shutdown() { |
| 28 web_view_handle_ = nullptr; | 28 web_view_handle_ = nullptr; |
| 29 } | 29 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 55 reused = false; | 55 reused = false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 *out_handle = web_view_handle_; | 58 *out_handle = web_view_handle_; |
| 59 return reused; | 59 return reused; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SharedWebView::Observe(int type, | 62 void SharedWebView::Observe(int type, |
| 63 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 64 const content::NotificationDetails& details) { | 64 const content::NotificationDetails& details) { |
| 65 DCHECK_EQ(chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, type); | 65 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); |
| 66 web_view_handle_ = nullptr; | 66 web_view_handle_ = nullptr; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void SharedWebView::OnMemoryPressure( | 69 void SharedWebView::OnMemoryPressure( |
| 70 base::MemoryPressureListener::MemoryPressureLevel level) { | 70 base::MemoryPressureListener::MemoryPressureLevel level) { |
| 71 switch (level) { | 71 switch (level) { |
| 72 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: | 72 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: |
| 73 break; | 73 break; |
| 74 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: | 74 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: |
| 75 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: | 75 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: |
| 76 web_view_handle_ = nullptr; | 76 web_view_handle_ = nullptr; |
| 77 break; | 77 break; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace chromeos | 81 } // namespace chromeos |
| OLD | NEW |