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

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

Issue 6930034: Print Preview: Print in the background. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
« no previous file with comments | « chrome/browser/ui/browser_list.h ('k') | chrome/browser/ui/browser_list_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/printing/background_printing_manager.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
15 #include "content/browser/renderer_host/render_process_host.h" 16 #include "content/browser/renderer_host/render_process_host.h"
16 #include "content/browser/tab_contents/navigation_controller.h" 17 #include "content/browser/tab_contents/navigation_controller.h"
17 #include "content/common/notification_registrar.h" 18 #include "content/common/notification_registrar.h"
18 #include "content/common/notification_service.h" 19 #include "content/common/notification_service.h"
19 #include "content/common/result_codes.h" 20 #include "content/common/result_codes.h"
20 21
21 #if defined(OS_MACOSX) 22 #if defined(OS_MACOSX)
22 #include "chrome/browser/chrome_browser_application_mac.h" 23 #include "chrome/browser/chrome_browser_application_mac.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 match_types |= kMatchOriginalProfile; 165 match_types |= kMatchOriginalProfile;
165 Browser* browser = FindBrowserMatching( 166 Browser* browser = FindBrowserMatching(
166 BrowserList::begin_last_active(), BrowserList::end_last_active(), 167 BrowserList::begin_last_active(), BrowserList::end_last_active(),
167 profile, Browser::FEATURE_NONE, match_types); 168 profile, Browser::FEATURE_NONE, match_types);
168 // Fall back to a forward scan of all Browsers if no active one was found. 169 // Fall back to a forward scan of all Browsers if no active one was found.
169 return browser ? browser : 170 return browser ? browser :
170 FindBrowserMatching(BrowserList::begin(), BrowserList::end(), profile, 171 FindBrowserMatching(BrowserList::begin(), BrowserList::end(), profile,
171 Browser::FEATURE_NONE, match_types); 172 Browser::FEATURE_NONE, match_types);
172 } 173 }
173 174
175 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() {
176 return g_browser_process->background_printing_manager();
177 }
178
174 } // namespace 179 } // namespace
175 180
176 BrowserList::BrowserVector BrowserList::browsers_; 181 BrowserList::BrowserVector BrowserList::browsers_;
177 ObserverList<BrowserList::Observer> BrowserList::observers_; 182 ObserverList<BrowserList::Observer> BrowserList::observers_;
178 183
179 // static 184 // static
180 void BrowserList::AddBrowser(Browser* browser) { 185 void BrowserList::AddBrowser(Browser* browser) {
181 DCHECK(browser); 186 DCHECK(browser);
182 browsers_.push_back(browser); 187 browsers_.push_back(browser);
183 188
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 BrowserVector* browser_list) { 619 BrowserVector* browser_list) {
615 const iterator remove_browser = 620 const iterator remove_browser =
616 std::find(browser_list->begin(), browser_list->end(), browser); 621 std::find(browser_list->begin(), browser_list->end(), browser);
617 if (remove_browser != browser_list->end()) 622 if (remove_browser != browser_list->end())
618 browser_list->erase(remove_browser); 623 browser_list->erase(remove_browser);
619 } 624 }
620 625
621 TabContentsIterator::TabContentsIterator() 626 TabContentsIterator::TabContentsIterator()
622 : browser_iterator_(BrowserList::begin()), 627 : browser_iterator_(BrowserList::begin()),
623 web_view_index_(-1), 628 web_view_index_(-1),
629 bg_printing_iterator_(GetBackgroundPrintingManager()->begin()),
624 cur_(NULL) { 630 cur_(NULL) {
625 Advance(); 631 Advance();
626 } 632 }
627 633
628 void TabContentsIterator::Advance() { 634 void TabContentsIterator::Advance() {
629 // The current TabContents should be valid unless we are at the beginning. 635 // The current TabContents should be valid unless we are at the beginning.
630 DCHECK(cur_ || (web_view_index_ == -1 && 636 DCHECK(cur_ || (web_view_index_ == -1 &&
631 browser_iterator_ == BrowserList::begin())) 637 browser_iterator_ == BrowserList::begin()))
632 << "Trying to advance past the end"; 638 << "Trying to advance past the end";
633 639
634 // Update cur_ to the next TabContents in the list. 640 // Update cur_ to the next TabContents in the list.
635 while (browser_iterator_ != BrowserList::end()) { 641 while (browser_iterator_ != BrowserList::end()) {
636 if (++web_view_index_ >= (*browser_iterator_)->tab_count()) { 642 if (++web_view_index_ >= (*browser_iterator_)->tab_count()) {
637 // Advance to the next Browser in the list. 643 // Advance to the next Browser in the list.
638 ++browser_iterator_; 644 ++browser_iterator_;
639 web_view_index_ = -1; 645 web_view_index_ = -1;
640 continue; 646 continue;
641 } 647 }
642 648
643 TabContentsWrapper* next_tab = 649 TabContentsWrapper* next_tab =
644 (*browser_iterator_)->GetTabContentsWrapperAt(web_view_index_); 650 (*browser_iterator_)->GetTabContentsWrapperAt(web_view_index_);
645 if (next_tab) { 651 if (next_tab) {
646 cur_ = next_tab; 652 cur_ = next_tab;
647 return; 653 return;
648 } 654 }
649 } 655 }
656 // If no more TabContents from Browsers, check the BackgroundPrintingManager.
657 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) {
658 cur_ = *bg_printing_iterator_;
659 CHECK(cur_);
660 ++bg_printing_iterator_;
661 return;
662 }
650 // Reached the end - no more TabContents. 663 // Reached the end - no more TabContents.
651 cur_ = NULL; 664 cur_ = NULL;
652 } 665 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_list.h ('k') | chrome/browser/ui/browser_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698