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

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

Issue 8844003: Send notifications to off-the-record profile about error bubble being added/removed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment Created 9 years 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/protector/settings_change_global_error.cc ('k') | no next file » | 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/global_error_service.h" 5 #include "chrome/browser/ui/global_error_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/global_error.h" 11 #include "chrome/browser/ui/global_error.h"
11 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
12 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
13 14
14 GlobalErrorService::GlobalErrorService(Profile* profile) : profile_(profile) { 15 GlobalErrorService::GlobalErrorService(Profile* profile) : profile_(profile) {
15 } 16 }
16 17
17 GlobalErrorService::~GlobalErrorService() { 18 GlobalErrorService::~GlobalErrorService() {
18 STLDeleteElements(&errors_); 19 STLDeleteElements(&errors_);
19 } 20 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 for (std::vector<GlobalError*>::const_iterator 54 for (std::vector<GlobalError*>::const_iterator
54 it = errors_.begin(); it != errors_.end(); ++it) { 55 it = errors_.begin(); it != errors_.end(); ++it) {
55 GlobalError* error = *it; 56 GlobalError* error = *it;
56 if (error->HasBubbleView() && !error->HasShownBubbleView()) 57 if (error->HasBubbleView() && !error->HasShownBubbleView())
57 return error; 58 return error;
58 } 59 }
59 return NULL; 60 return NULL;
60 } 61 }
61 62
62 void GlobalErrorService::NotifyErrorsChanged(GlobalError* error) { 63 void GlobalErrorService::NotifyErrorsChanged(GlobalError* error) {
63 content::NotificationService::current()->Notify( 64 // GlobalErrorService is bound only to original profile so we need to send
64 chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, 65 // notifications to both it and its off-the-record profile to update
65 content::Source<Profile>(profile_), 66 // incognito windows as well.
66 content::Details<GlobalError>(error)); 67 std::vector<Profile*> profiles_to_notify;
68 if (profile_ != NULL) {
69 profiles_to_notify.push_back(profile_);
70 if (profile_->IsOffTheRecord())
71 profiles_to_notify.push_back(profile_->GetOriginalProfile());
72 else if (profile_->HasOffTheRecordProfile())
73 profiles_to_notify.push_back(profile_->GetOffTheRecordProfile());
74 for (size_t i = 0; i < profiles_to_notify.size(); ++i) {
75 content::NotificationService::current()->Notify(
76 chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
77 content::Source<Profile>(profiles_to_notify[i]),
78 content::Details<GlobalError>(error));
79 }
80 }
67 } 81 }
OLDNEW
« no previous file with comments | « chrome/browser/protector/settings_change_global_error.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698