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

Side by Side Diff: chrome/browser/protector/protector_service.cc

Issue 10967003: Add desktop type context to most existing instances of FindTabbedBrowser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pre-review pass. Created 8 years, 2 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/protector/protector_service.h" 5 #include "chrome/browser/protector/protector_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/google/google_util.h" 8 #include "chrome/browser/google/google_util.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/protector/composite_settings_change.h" 10 #include "chrome/browser/protector/composite_settings_change.h"
11 #include "chrome/browser/protector/keys.h" 11 #include "chrome/browser/protector/keys.h"
12 #include "chrome/browser/protector/protected_prefs_watcher.h" 12 #include "chrome/browser/protector/protected_prefs_watcher.h"
13 #include "chrome/browser/protector/protector_utils.h" 13 #include "chrome/browser/protector/protector_utils.h"
14 #include "chrome/browser/protector/settings_change_global_error.h" 14 #include "chrome/browser/protector/settings_change_global_error.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/host_desktop.h"
16 #include "chrome/browser/ui/singleton_tabs.h" 17 #include "chrome/browser/ui/singleton_tabs.h"
17 #include "chrome/common/chrome_notification_types.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/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 21 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
21 22
22 namespace protector { 23 namespace protector {
23 24
24 namespace { 25 namespace {
25 26
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // GlobalError instance will be created for the composite change. 78 // GlobalError instance will be created for the composite change.
78 item_to_merge_with->error->RemoveFromProfile(); 79 item_to_merge_with->error->RemoveFromProfile();
79 } else if (change->IsUserVisible()) { 80 } else if (change->IsUserVisible()) {
80 Item new_item; 81 Item new_item;
81 SettingsChangeGlobalError* error = 82 SettingsChangeGlobalError* error =
82 new SettingsChangeGlobalError(change_ptr.get(), this); 83 new SettingsChangeGlobalError(change_ptr.get(), this);
83 new_item.error.reset(error); 84 new_item.error.reset(error);
84 new_item.change.reset(change_ptr.release()); 85 new_item.change.reset(change_ptr.release());
85 items_.push_back(new_item); 86 items_.push_back(new_item);
86 // Do not show the bubble immediately if another one is active. 87 // Do not show the bubble immediately if another one is active.
87 error->AddToProfile(profile_, !has_active_change_); 88 // TODO(robertshield): Add desktop context to protector, crbug.com/153771
89 error->AddToProfile(profile_, !has_active_change_,
90 chrome::HOST_DESKTOP_TYPE_NATIVE);
88 has_active_change_ = true; 91 has_active_change_ = true;
89 } else { 92 } else {
90 VLOG(1) << "Not showing a change because it's not user-visible."; 93 VLOG(1) << "Not showing a change because it's not user-visible.";
91 } 94 }
92 } 95 }
93 96
94 bool ProtectorService::IsShowingChange() const { 97 bool ProtectorService::IsShowingChange() const {
95 return !items_.empty(); 98 return !items_.empty();
96 } 99 }
97 100
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 MatchItemByError(error)); 172 MatchItemByError(error));
170 DCHECK(item != items_.end()); 173 DCHECK(item != items_.end());
171 174
172 if (item->was_merged) { 175 if (item->was_merged) {
173 bool show_new_error = !has_active_change_ || item->show_when_merged; 176 bool show_new_error = !has_active_change_ || item->show_when_merged;
174 item->was_merged = false; 177 item->was_merged = false;
175 item->show_when_merged = false; 178 item->show_when_merged = false;
176 // Item was merged with another change instance and error has been removed, 179 // Item was merged with another change instance and error has been removed,
177 // create a new one for the composite change. 180 // create a new one for the composite change.
178 item->error.reset(new SettingsChangeGlobalError(item->change.get(), this)); 181 item->error.reset(new SettingsChangeGlobalError(item->change.get(), this));
179 item->error->AddToProfile(profile_, show_new_error); 182 // TODO(robertshield): Add desktop context to protector, crbug.com/153771
183 item->error->AddToProfile(profile_, show_new_error,
184 chrome::HOST_DESKTOP_TYPE_NATIVE);
180 has_active_change_ = true; 185 has_active_change_ = true;
181 return; 186 return;
182 } 187 }
183 188
184 items_.erase(item); 189 items_.erase(item);
185 190
186 // If no other change is shown and there are changes that haven't been shown 191 // If no other change is shown and there are changes that haven't been shown
187 // yet, show the first one. 192 // yet, show the first one.
188 if (!has_active_change_) { 193 if (!has_active_change_) {
189 for (item = items_.begin(); item != items_.end(); ++item) { 194 for (item = items_.begin(); item != items_.end(); ++item) {
190 if (!item->error->HasShownBubbleView()) { 195 if (!item->error->HasShownBubbleView()) {
191 item->error->ShowBubble(); 196 // TODO(robertshield): Add desktop context to protector,
197 // crbug.com/153771
198 item->error->ShowBubble(chrome::HOST_DESKTOP_TYPE_NATIVE);
192 has_active_change_ = true; 199 has_active_change_ = true;
193 return; 200 return;
194 } 201 }
195 } 202 }
196 } 203 }
197 } 204 }
198 205
199 BaseSettingChange* ProtectorService::GetLastChange() { 206 BaseSettingChange* ProtectorService::GetLastChange() {
200 return items_.empty() ? NULL : items_.back().change.get(); 207 return items_.empty() ? NULL : items_.back().change.get();
201 } 208 }
(...skipping 18 matching lines...) Expand all
220 ProtectorService::MatchItemByError::MatchItemByError( 227 ProtectorService::MatchItemByError::MatchItemByError(
221 const SettingsChangeGlobalError* other) : other_(other) { 228 const SettingsChangeGlobalError* other) : other_(other) {
222 } 229 }
223 230
224 bool ProtectorService::MatchItemByError::operator()( 231 bool ProtectorService::MatchItemByError::operator()(
225 const ProtectorService::Item& item) { 232 const ProtectorService::Item& item) {
226 return other_ == item.error.get(); 233 return other_ == item.error.get();
227 } 234 }
228 235
229 } // namespace protector 236 } // namespace protector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698