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

Side by Side Diff: chrome/browser/ui/browser_list.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_list.h" 5 #include "chrome/browser/ui/browser_list.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/browser_shutdown.h" 12 #include "chrome/browser/browser_shutdown.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/printing/background_printing_manager.h" 14 #include "chrome/browser/printing/background_printing_manager.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "content/browser/renderer_host/render_process_host.h" 20 #include "content/browser/renderer_host/render_process_host.h"
20 #include "content/browser/tab_contents/navigation_details.h" 21 #include "content/browser/tab_contents/navigation_details.h"
21 #include "content/common/notification_registrar.h" 22 #include "content/common/notification_registrar.h"
22 #include "content/common/notification_service.h" 23 #include "content/common/notification_service.h"
23 #include "content/common/result_codes.h" 24 #include "content/common/result_codes.h"
24 25
25 #if defined(OS_MACOSX) 26 #if defined(OS_MACOSX)
26 #include "chrome/browser/chrome_browser_application_mac.h" 27 #include "chrome/browser/chrome_browser_application_mac.h"
27 #endif 28 #endif
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 void BrowserList::AddBrowser(Browser* browser) { 236 void BrowserList::AddBrowser(Browser* browser) {
236 DCHECK(browser); 237 DCHECK(browser);
237 browsers_.push_back(browser); 238 browsers_.push_back(browser);
238 239
239 g_browser_process->AddRefModule(); 240 g_browser_process->AddRefModule();
240 241
241 if (!activity_observer) 242 if (!activity_observer)
242 activity_observer = new BrowserActivityObserver; 243 activity_observer = new BrowserActivityObserver;
243 244
244 NotificationService::current()->Notify( 245 NotificationService::current()->Notify(
245 NotificationType::BROWSER_OPENED, 246 chrome::BROWSER_OPENED,
246 Source<Browser>(browser), 247 Source<Browser>(browser),
247 NotificationService::NoDetails()); 248 NotificationService::NoDetails());
248 249
249 // Send out notifications after add has occurred. Do some basic checking to 250 // Send out notifications after add has occurred. Do some basic checking to
250 // try to catch evil observers that change the list from under us. 251 // try to catch evil observers that change the list from under us.
251 size_t original_count = observers_.size(); 252 size_t original_count = observers_.size();
252 FOR_EACH_OBSERVER(Observer, observers_, OnBrowserAdded(browser)); 253 FOR_EACH_OBSERVER(Observer, observers_, OnBrowserAdded(browser));
253 DCHECK_EQ(original_count, observers_.size()) 254 DCHECK_EQ(original_count, observers_.size())
254 << "observer list modified during notification"; 255 << "observer list modified during notification";
255 } 256 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // static 313 // static
313 void BrowserList::RemoveBrowser(Browser* browser) { 314 void BrowserList::RemoveBrowser(Browser* browser) {
314 RemoveBrowserFrom(browser, &last_active_browsers_); 315 RemoveBrowserFrom(browser, &last_active_browsers_);
315 316
316 // Closing all windows does not indicate quitting the application on the Mac, 317 // Closing all windows does not indicate quitting the application on the Mac,
317 // however, many UI tests rely on this behavior so leave it be for now and 318 // however, many UI tests rely on this behavior so leave it be for now and
318 // simply ignore the behavior on the Mac outside of unit tests. 319 // simply ignore the behavior on the Mac outside of unit tests.
319 // TODO(andybons): Fix the UI tests to Do The Right Thing. 320 // TODO(andybons): Fix the UI tests to Do The Right Thing.
320 bool closing_last_browser = (browsers_.size() == 1); 321 bool closing_last_browser = (browsers_.size() == 1);
321 NotificationService::current()->Notify( 322 NotificationService::current()->Notify(
322 NotificationType::BROWSER_CLOSED, 323 chrome::BROWSER_CLOSED,
323 Source<Browser>(browser), Details<bool>(&closing_last_browser)); 324 Source<Browser>(browser), Details<bool>(&closing_last_browser));
324 325
325 RemoveBrowserFrom(browser, &browsers_); 326 RemoveBrowserFrom(browser, &browsers_);
326 327
327 // Do some basic checking to try to catch evil observers 328 // Do some basic checking to try to catch evil observers
328 // that change the list from under us. 329 // that change the list from under us.
329 size_t original_count = observers_.size(); 330 size_t original_count = observers_.size();
330 FOR_EACH_OBSERVER(Observer, observers_, OnBrowserRemoved(browser)); 331 FOR_EACH_OBSERVER(Observer, observers_, OnBrowserRemoved(browser));
331 DCHECK_EQ(original_count, observers_.size()) 332 DCHECK_EQ(original_count, observers_.size())
332 << "observer list modified during notification"; 333 << "observer list modified during notification";
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 NotificationService::NoDetails()); 505 NotificationService::NoDetails());
505 506
506 // Write important data first. 507 // Write important data first.
507 g_browser_process->EndSession(); 508 g_browser_process->EndSession();
508 509
509 BrowserList::CloseAllBrowsers(); 510 BrowserList::CloseAllBrowsers();
510 511
511 // Send out notification. This is used during testing so that the test harness 512 // Send out notification. This is used during testing so that the test harness
512 // can properly shutdown before we exit. 513 // can properly shutdown before we exit.
513 NotificationService::current()->Notify( 514 NotificationService::current()->Notify(
514 NotificationType::SESSION_END, 515 chrome::SESSION_END,
515 NotificationService::AllSources(), 516 NotificationService::AllSources(),
516 NotificationService::NoDetails()); 517 NotificationService::NoDetails());
517 518
518 // And shutdown. 519 // And shutdown.
519 browser_shutdown::Shutdown(); 520 browser_shutdown::Shutdown();
520 521
521 #if defined(OS_WIN) 522 #if defined(OS_WIN)
522 // At this point the message loop is still running yet we've shut everything 523 // At this point the message loop is still running yet we've shut everything
523 // down. If any messages are processed we'll likely crash. Exit now. 524 // down. If any messages are processed we'll likely crash. Exit now.
524 ExitProcess(ResultCodes::NORMAL_EXIT); 525 ExitProcess(ResultCodes::NORMAL_EXIT);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 // If no more TabContents from Browsers, check the BackgroundPrintingManager. 727 // If no more TabContents from Browsers, check the BackgroundPrintingManager.
727 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { 728 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) {
728 cur_ = *bg_printing_iterator_; 729 cur_ = *bg_printing_iterator_;
729 CHECK(cur_); 730 CHECK(cur_);
730 ++bg_printing_iterator_; 731 ++bg_printing_iterator_;
731 return; 732 return;
732 } 733 }
733 // Reached the end - no more TabContents. 734 // Reached the end - no more TabContents.
734 cur_ = NULL; 735 cur_ = NULL;
735 } 736 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698