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

Side by Side Diff: chrome/browser/chromeos/network_message_observer.cc

Issue 6347044: Only show notification for low 3g data for the last data-based plan.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « no previous file | 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/chromeos/network_message_observer.h" 5 #include "chrome/browser/chromeos/network_message_observer.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (!new_failed_network.empty()) { 141 if (!new_failed_network.empty()) {
142 // Hide if already shown to force show it in case user has closed it. 142 // Hide if already shown to force show it in case user has closed it.
143 if (notification_connection_error_.visible()) 143 if (notification_connection_error_.visible())
144 notification_connection_error_.Hide(); 144 notification_connection_error_.Hide();
145 notification_connection_error_.Show(l10n_util::GetStringFUTF16( 145 notification_connection_error_.Show(l10n_util::GetStringFUTF16(
146 IDS_NETWORK_CONNECTION_ERROR_MESSAGE, 146 IDS_NETWORK_CONNECTION_ERROR_MESSAGE,
147 ASCIIToUTF16(new_failed_network)), false, false); 147 ASCIIToUTF16(new_failed_network)), false, false);
148 } 148 }
149 } 149 }
150 150
151 void NetworkMessageObserver::OnCellularDataPlanChanged(NetworkLibrary* obj) { 151 void NetworkMessageObserver::OnCellularDataPlanChanged(NetworkLibrary* obj) {
Vince Laviano 2011/02/02 21:47:43 I'm going to comment on the entire method rather t
Charlie Lee 2011/02/08 02:09:16 Done.
152 const CellularNetwork* cellular = obj->cellular_network(); 152 const CellularNetwork* cellular = obj->cellular_network();
153 if (!cellular) 153 if (!cellular)
154 return; 154 return;
155 const CellularDataPlan* plan = cellular->GetSignificantDataPlan(); 155
156 // Check to see if the active plan is time-based or data-based.
157 // If data-based, then only do notification if there's 1 data-based plan left.
158 const CellularDataPlan* plan = NULL;
159 const CellularDataPlanVector& plans = cellular->GetDataPlans();
160 for (CellularDataPlanVector::const_iterator iter = plans.begin();
161 iter != plans.end();
162 ++iter) {
163 if (plan == NULL) { // Looking at first active plan
164 plan = *iter;
165 // If time-based, then no need to look further.
166 if (plan->plan_type == CELLULAR_DATA_PLAN_UNLIMITED)
167 break;
168 } else {
169 // If we find any other data-based plan, then no need for notification.
170 if ((*iter)->plan_type == CELLULAR_DATA_PLAN_METERED_PAID ||
171 (*iter)->plan_type == CELLULAR_DATA_PLAN_METERED_BASE) {
Vince Laviano 2011/02/02 21:47:43 This logic assumes that the data-based plan that w
Charlie Lee 2011/02/08 02:09:16 Done.
172 plan = NULL;
173 break;
174 }
175 }
176 }
177
Vince Laviano 2011/02/02 21:47:43 It looks like |plan| is set to non-NULL if there i
Charlie Lee 2011/02/08 02:09:16 Done.
156 std::string new_plan_name = plan ? plan->plan_name : ""; 178 std::string new_plan_name = plan ? plan->plan_name : "";
157 CellularDataPlanType new_plan_type = plan ? plan->plan_type : 179 CellularDataPlanType new_plan_type = plan ? plan->plan_type :
158 CELLULAR_DATA_PLAN_UNKNOWN; 180 CELLULAR_DATA_PLAN_UNKNOWN;
Vince Laviano 2011/02/02 21:47:43 I think that we could eliminate these two vars and
Charlie Lee 2011/02/08 02:09:16 Done.
159 181
160 // If connected cellular network changed, or data plan is different, then 182 // If connected cellular network changed, or data plan is different, then
161 // it's a new network. Then hide all previous notifications. 183 // it's a new network. Then hide all previous notifications.
162 bool new_plan = false; 184 bool new_plan = false;
163 if (cellular->service_path() != cellular_service_path_) { 185 if (cellular->service_path() != cellular_service_path_) {
164 cellular_service_path_ = cellular->service_path(); 186 cellular_service_path_ = cellular->service_path();
165 new_plan = true; 187 new_plan = true;
166 } else if (new_plan_name != cellular_data_plan_name_ || 188 } else if (new_plan_name != cellular_data_plan_name_ ||
167 new_plan_type != cellular_data_plan_type_) { 189 new_plan_type != cellular_data_plan_type_) {
168 new_plan = true; 190 new_plan = true;
169 } 191 }
Vince Laviano 2011/02/02 21:47:43 Not sure that testing just name and type is suffic
Charlie Lee 2011/02/08 02:09:16 Done.
170 192
171 cellular_data_plan_name_ = new_plan_name; 193 cellular_data_plan_name_ = new_plan_name;
172 cellular_data_plan_type_ = new_plan_type; 194 cellular_data_plan_type_ = new_plan_type;
173 195
174 bool should_show_notifications = ShouldShowMobilePlanNotifications(); 196 bool should_show_notifications = ShouldShowMobilePlanNotifications();
175 if (!should_show_notifications) { 197 if (!should_show_notifications) {
Vince Laviano 2011/02/02 21:47:43 This bool isn't used anywhere else, so we could el
Charlie Lee 2011/02/08 02:09:16 Done.
176 notification_low_data_.Hide(); 198 notification_low_data_.Hide();
177 notification_no_data_.Hide(); 199 notification_no_data_.Hide();
Vince Laviano 2011/02/02 21:47:43 I see these two lines repeated several times. Mayb
Charlie Lee 2011/02/08 02:09:16 Done.
178 return; 200 return;
179 } 201 }
180 202
181 if (new_plan) { 203 if (new_plan) {
182 notification_low_data_.Hide(); 204 notification_low_data_.Hide();
183 notification_no_data_.Hide(); 205 notification_no_data_.Hide();
184 if (!plan && cellular->needs_new_plan()) { 206 if (!plan && cellular->needs_new_plan()) {
185 notification_no_data_.set_title( 207 notification_no_data_.set_title(
186 l10n_util::GetStringFUTF16(IDS_NETWORK_NO_DATA_PLAN_TITLE, 208 l10n_util::GetStringFUTF16(IDS_NETWORK_NO_DATA_PLAN_TITLE,
187 UTF8ToUTF16(cellular->service_name()))); 209 UTF8ToUTF16(cellular->service_name())));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 NewCallback(this, &NetworkMessageObserver::OpenMoreInfoPage), 258 NewCallback(this, &NetworkMessageObserver::OpenMoreInfoPage),
237 false, false); 259 false, false);
238 } else { 260 } else {
239 // Got data, so hide notifications. 261 // Got data, so hide notifications.
240 notification_low_data_.Hide(); 262 notification_low_data_.Hide();
241 notification_no_data_.Hide(); 263 notification_no_data_.Hide();
242 } 264 }
243 } 265 }
244 266
245 } // namespace chromeos 267 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698