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

Side by Side Diff: chrome/browser/translate/translate_infobar_delegate.cc

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitespace Created 6 years, 8 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) 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/translate/translate_infobar_delegate.h" 5 #include "chrome/browser/translate/translate_infobar_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/string_compare.h" 9 #include "base/i18n/string_compare.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/infobars/infobar.h" 13 #include "chrome/browser/infobars/infobar.h"
14 #include "chrome/browser/infobars/infobar_manager.h"
15 #include "chrome/browser/infobars/infobar_service.h" 14 #include "chrome/browser/infobars/infobar_service.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/translate/translate_manager.h" 16 #include "chrome/browser/translate/translate_manager.h"
18 #include "chrome/browser/translate/translate_tab_helper.h" 17 #include "chrome/browser/translate/translate_tab_helper.h"
19 #include "components/translate/core/browser/translate_accept_languages.h" 18 #include "components/translate/core/browser/translate_accept_languages.h"
20 #include "components/translate/core/browser/translate_download_manager.h" 19 #include "components/translate/core/browser/translate_download_manager.h"
21 #include "components/translate/core/common/translate_constants.h" 20 #include "components/translate/core/common/translate_constants.h"
22 #include "content/public/browser/navigation_entry.h" 21 #include "content/public/browser/navigation_entry.h"
23 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
24 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 TranslateTabHelper::FromWebContents(web_contents); 81 TranslateTabHelper::FromWebContents(web_contents);
83 if (!translate_tab_helper || 82 if (!translate_tab_helper ||
84 translate_tab_helper->GetLanguageState().InTranslateNavigation()) 83 translate_tab_helper->GetLanguageState().InTranslateNavigation())
85 return; 84 return;
86 } 85 }
87 86
88 // Find any existing translate infobar delegate. 87 // Find any existing translate infobar delegate.
89 InfoBar* old_infobar = NULL; 88 InfoBar* old_infobar = NULL;
90 InfoBarService* infobar_service = 89 InfoBarService* infobar_service =
91 InfoBarService::FromWebContents(web_contents); 90 InfoBarService::FromWebContents(web_contents);
92 InfoBarManager* infobar_manager = infobar_service->infobar_manager();
93 TranslateInfoBarDelegate* old_delegate = NULL; 91 TranslateInfoBarDelegate* old_delegate = NULL;
94 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { 92 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
95 old_infobar = infobar_manager->infobar_at(i); 93 old_infobar = infobar_service->infobar_at(i);
96 old_delegate = old_infobar->delegate()->AsTranslateInfoBarDelegate(); 94 old_delegate = old_infobar->delegate()->AsTranslateInfoBarDelegate();
97 if (old_delegate) { 95 if (old_delegate) {
98 if (!replace_existing_infobar) 96 if (!replace_existing_infobar)
99 return; 97 return;
100 break; 98 break;
101 } 99 }
102 } 100 }
103 101
104 // Add the new delegate. 102 // Add the new delegate.
105 scoped_ptr<InfoBar> infobar(CreateInfoBar( 103 scoped_ptr<InfoBar> infobar(CreateInfoBar(
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 if (!details.is_navigation_to_different_page && !details.is_main_frame) 371 if (!details.is_navigation_to_different_page && !details.is_main_frame)
374 return false; 372 return false;
375 373
376 return InfoBarDelegate::ShouldExpireInternal(details); 374 return InfoBarDelegate::ShouldExpireInternal(details);
377 } 375 }
378 376
379 TranslateInfoBarDelegate* 377 TranslateInfoBarDelegate*
380 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 378 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
381 return this; 379 return this;
382 } 380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698