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

Side by Side Diff: chrome/browser/ui/panels/panel.cc

Issue 1778873002: Replace Increment/DecrementKeepAliveCount by ScopedKeepAlives (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@KAObserver
Patch Set: replace the commented dcheck by a dlog Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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/panels/panel.h" 5 #include "chrome/browser/ui/panels/panel.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/devtools/devtools_window.h" 15 #include "chrome/browser/devtools/devtools_window.h"
16 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 16 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
17 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" 17 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h"
18 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" 18 #include "chrome/browser/extensions/api/tabs/windows_event_router.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_tab_util.h" 20 #include "chrome/browser/extensions/extension_tab_util.h"
21 #include "chrome/browser/extensions/window_controller.h" 21 #include "chrome/browser/extensions/window_controller.h"
22 #include "chrome/browser/extensions/window_controller_list.h" 22 #include "chrome/browser/extensions/window_controller_list.h"
23 #include "chrome/browser/lifetime/application_lifetime.h" 23 #include "chrome/browser/lifetime/application_lifetime.h"
24 #include "chrome/browser/lifetime/keep_alive_types.h"
25 #include "chrome/browser/lifetime/scoped_keep_alive.h"
24 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/sessions/session_tab_helper.h" 27 #include "chrome/browser/sessions/session_tab_helper.h"
26 #include "chrome/browser/task_management/web_contents_tags.h" 28 #include "chrome/browser/task_management/web_contents_tags.h"
27 #include "chrome/browser/themes/theme_service.h" 29 #include "chrome/browser/themes/theme_service.h"
28 #include "chrome/browser/themes/theme_service_factory.h" 30 #include "chrome/browser/themes/theme_service_factory.h"
29 #include "chrome/browser/ui/panels/native_panel.h" 31 #include "chrome/browser/ui/panels/native_panel.h"
30 #include "chrome/browser/ui/panels/panel_collection.h" 32 #include "chrome/browser/ui/panels/panel_collection.h"
31 #include "chrome/browser/ui/panels/panel_host.h" 33 #include "chrome/browser/ui/panels/panel_host.h"
32 #include "chrome/browser/ui/panels/panel_manager.h" 34 #include "chrome/browser/ui/panels/panel_manager.h"
33 #include "chrome/browser/ui/panels/stacked_panel_collection.h" 35 #include "chrome/browser/ui/panels/stacked_panel_collection.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 bool PanelExtensionWindowController::IsVisibleToExtension( 161 bool PanelExtensionWindowController::IsVisibleToExtension(
160 const extensions::Extension* extension) const { 162 const extensions::Extension* extension) const {
161 DCHECK(extension); 163 DCHECK(extension);
162 return extension->id() == panel_->extension_id(); 164 return extension->id() == panel_->extension_id();
163 } 165 }
164 166
165 } // namespace panel_internal 167 } // namespace panel_internal
166 168
167 Panel::~Panel() { 169 Panel::~Panel() {
168 DCHECK(!collection_); 170 DCHECK(!collection_);
169 #if !defined(USE_AURA)
170 // Invoked by native panel destructor. Do not access native_panel_ here.
171 chrome::DecrementKeepAliveCount(); // Remove shutdown prevention.
172 #endif
173 } 171 }
174 172
175 PanelManager* Panel::manager() const { 173 PanelManager* Panel::manager() const {
176 return PanelManager::GetInstance(); 174 return PanelManager::GetInstance();
177 } 175 }
178 176
179 const std::string Panel::extension_id() const { 177 const std::string Panel::extension_id() const {
180 return web_app::GetExtensionIdFromApplicationName(app_name_); 178 return web_app::GetExtensionIdFromApplicationName(app_name_);
181 } 179 }
182 180
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 549 }
552 550
553 // Close when the extension is unloaded or the browser is exiting. 551 // Close when the extension is unloaded or the browser is exiting.
554 extension_registry_->AddObserver(this); 552 extension_registry_->AddObserver(this);
555 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 553 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
556 content::NotificationService::AllSources()); 554 content::NotificationService::AllSources());
557 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 555 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
558 content::Source<ThemeService>( 556 content::Source<ThemeService>(
559 ThemeServiceFactory::GetForProfile(profile_))); 557 ThemeServiceFactory::GetForProfile(profile_)));
560 558
559 // TODO(dgn): Should keep_alive be always registered regardless of the platform
560 // here? (https://crbug.com/590173)
561 #if !defined(USE_AURA) 561 #if !defined(USE_AURA)
562 // Keep alive for AURA has been moved to panel_view. 562 // Keep alive for AURA has been moved to panel_view.
563 // Prevent the browser process from shutting down while this window is open. 563 // Prevent the browser process from shutting down while this window is open.
564 chrome::IncrementKeepAliveCount(); 564 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::PANEL,
565 KeepAliveRestartOption::DISABLED));
565 #endif 566 #endif
566 567
567 UpdateAppIcon(); 568 UpdateAppIcon();
568 } 569 }
569 570
570 void Panel::SetPanelBounds(const gfx::Rect& bounds) { 571 void Panel::SetPanelBounds(const gfx::Rect& bounds) {
571 if (bounds != native_panel_->GetPanelBounds()) 572 if (bounds != native_panel_->GetPanelBounds())
572 native_panel_->SetPanelBounds(bounds); 573 native_panel_->SetPanelBounds(bounds);
573 } 574 }
574 575
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 // static 904 // static
904 void Panel::FormatTitleForDisplay(base::string16* title) { 905 void Panel::FormatTitleForDisplay(base::string16* title) {
905 size_t current_index = 0; 906 size_t current_index = 0;
906 size_t match_index; 907 size_t match_index;
907 while ((match_index = title->find(L'\n', current_index)) != 908 while ((match_index = title->find(L'\n', current_index)) !=
908 base::string16::npos) { 909 base::string16::npos) {
909 title->replace(match_index, 1, base::string16()); 910 title->replace(match_index, 1, base::string16());
910 current_index = match_index; 911 current_index = match_index;
911 } 912 }
912 } 913 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698