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

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

Issue 9702005: Call libcros functions through proxy functions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More comment fix Created 8 years, 9 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/chromeos/cros/network_library_impl_cros.cc ('k') | chrome/chrome_browser.gypi » ('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) 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/chromeos/sms_observer.h" 5 #include "chrome/browser/chromeos/sms_observer.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/cros/cros_library.h" 8 #include "chrome/browser/chromeos/cros/cros_library.h"
9 #include "chrome/browser/chromeos/notifications/system_notification.h" 9 #include "chrome/browser/chromeos/notifications/system_notification.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 26 matching lines...) Expand all
37 bool found = false; 37 bool found = false;
38 for (CellularNetworkVector::const_iterator it_network = networks.begin(); 38 for (CellularNetworkVector::const_iterator it_network = networks.begin();
39 it_network != networks.end(); ++it_network) { 39 it_network != networks.end(); ++it_network) {
40 if (it_observer->first == (*it_network)->device_path()) { 40 if (it_observer->first == (*it_network)->device_path()) {
41 found = true; 41 found = true;
42 break; 42 break;
43 } 43 }
44 } 44 }
45 if (!found) { 45 if (!found) {
46 VLOG(1) << "Remove SMS monitor for " << it_observer->first; 46 VLOG(1) << "Remove SMS monitor for " << it_observer->first;
47 chromeos::DisconnectSMSMonitor(it_observer->second); 47 CrosDisconnectSMSMonitor(it_observer->second);
48 observers_.erase(it_observer++); 48 observers_.erase(it_observer++);
49 } else { 49 } else {
50 ++it_observer; 50 ++it_observer;
51 } 51 }
52 } 52 }
53 53
54 // Add monitors for new networks. 54 // Add monitors for new networks.
55 for (CellularNetworkVector::const_iterator it_network = networks.begin(); 55 for (CellularNetworkVector::const_iterator it_network = networks.begin();
56 it_network != networks.end(); ++it_network) { 56 it_network != networks.end(); ++it_network) {
57 const std::string& device_path((*it_network)->device_path()); 57 const std::string& device_path((*it_network)->device_path());
58 if (device_path.empty()) { 58 if (device_path.empty()) {
59 LOG(WARNING) << "Cellular Network has empty device path: " 59 LOG(WARNING) << "Cellular Network has empty device path: "
60 << (*it_network)->name(); 60 << (*it_network)->name();
61 continue; 61 continue;
62 } 62 }
63 ObserversMap::iterator it_observer = observers_.find(device_path); 63 ObserversMap::iterator it_observer = observers_.find(device_path);
64 if (it_observer == observers_.end()) { 64 if (it_observer == observers_.end()) {
65 VLOG(1) << "Add SMS monitor for " << device_path; 65 VLOG(1) << "Add SMS monitor for " << device_path;
66 chromeos::SMSMonitor monitor = 66 chromeos::SMSMonitor monitor =
67 chromeos::MonitorSMS(device_path.c_str(), &StaticCallback, this); 67 CrosMonitorSMS(device_path.c_str(), &StaticCallback, this);
68 observers_.insert(ObserversMap::value_type(device_path, monitor)); 68 observers_.insert(ObserversMap::value_type(device_path, monitor));
69 } else { 69 } else {
70 VLOG(1) << "Already has SMS monitor for " << device_path; 70 VLOG(1) << "Already has SMS monitor for " << device_path;
71 } 71 }
72 } 72 }
73 } 73 }
74 74
75 void SmsObserver::DisconnectAll() { 75 void SmsObserver::DisconnectAll() {
76 // Guard against calls to libcros (http://crosbug.com/17863). 76 // Guard against calls to libcros (http://crosbug.com/17863).
77 if (!CrosLibrary::Get()->libcros_loaded()) 77 if (!CrosLibrary::Get()->libcros_loaded())
78 return; 78 return;
79 79
80 for (ObserversMap::iterator it = observers_.begin(); 80 for (ObserversMap::iterator it = observers_.begin();
81 it != observers_.end(); ++it) { 81 it != observers_.end(); ++it) {
82 VLOG(1) << "Remove SMS monitor for " << it->first; 82 VLOG(1) << "Remove SMS monitor for " << it->first;
83 chromeos::DisconnectSMSMonitor(it->second); 83 CrosDisconnectSMSMonitor(it->second);
84 } 84 }
85 observers_.clear(); 85 observers_.clear();
86 } 86 }
87 87
88 void SmsObserver::OnNetworkManagerChanged(NetworkLibrary* library) { 88 void SmsObserver::OnNetworkManagerChanged(NetworkLibrary* library) {
89 UpdateObservers(library); 89 UpdateObservers(library);
90 } 90 }
91 91
92 // static 92 // static
93 void SmsObserver::StaticCallback(void* object, 93 void SmsObserver::StaticCallback(void* object,
(...skipping 12 matching lines...) Expand all
106 profile_, 106 profile_,
107 "incoming _sms.chromeos", 107 "incoming _sms.chromeos",
108 IDR_NOTIFICATION_SMS, 108 IDR_NOTIFICATION_SMS,
109 l10n_util::GetStringFUTF16( 109 l10n_util::GetStringFUTF16(
110 IDS_SMS_NOTIFICATION_TITLE, UTF8ToUTF16(message->number))); 110 IDS_SMS_NOTIFICATION_TITLE, UTF8ToUTF16(message->number)));
111 111
112 note.Show(UTF8ToUTF16(message->text), true, false); 112 note.Show(UTF8ToUTF16(message->text), true, false);
113 } 113 }
114 114
115 } // namespace chromeos 115 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/network_library_impl_cros.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698