| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/webui/local_discovery/local_discovery_ui_handler.h" | 5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler() | 103 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler() |
| 104 : is_visible_(false), | 104 : is_visible_(false), |
| 105 failed_list_count_(0), | 105 failed_list_count_(0), |
| 106 succeded_list_count_(0) { | 106 succeded_list_count_(0) { |
| 107 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) | 107 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) |
| 108 #if !defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 108 #if !defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
| 109 // On Windows, we need the PDF plugin which is only guaranteed to exist on | 109 // On Windows, we need the PDF plugin which is only guaranteed to exist on |
| 110 // Google Chrome builds. Use a command-line switch for Windows non-Google | 110 // Google Chrome builds. Use a command-line switch for Windows non-Google |
| 111 // Chrome builds. | 111 // Chrome builds. |
| 112 cloud_print_connector_ui_enabled_ = | 112 cloud_print_connector_ui_enabled_ = |
| 113 CommandLine::ForCurrentProcess()->HasSwitch( | 113 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 114 switches::kEnableCloudPrintProxy); | 114 switches::kEnableCloudPrintProxy); |
| 115 #else | 115 #else |
| 116 // Always enabled for Linux and Google Chrome Windows builds. | 116 // Always enabled for Linux and Google Chrome Windows builds. |
| 117 // Never enabled for Chrome OS, we don't even need to indicate it. | 117 // Never enabled for Chrome OS, we don't even need to indicate it. |
| 118 cloud_print_connector_ui_enabled_ = true; | 118 cloud_print_connector_ui_enabled_ = true; |
| 119 #endif | 119 #endif |
| 120 #endif // defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) | 120 #endif // defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) |
| 121 } | 121 } |
| 122 | 122 |
| 123 LocalDiscoveryUIHandler::~LocalDiscoveryUIHandler() { | 123 LocalDiscoveryUIHandler::~LocalDiscoveryUIHandler() { |
| 124 Profile* profile = Profile::FromWebUI(web_ui()); | 124 Profile* profile = Profile::FromWebUI(web_ui()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 | 198 |
| 199 privet_lister_->Start(); | 199 privet_lister_->Start(); |
| 200 privet_lister_->DiscoverNewDevices(false); | 200 privet_lister_->DiscoverNewDevices(false); |
| 201 | 201 |
| 202 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) | 202 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) |
| 203 StartCloudPrintConnector(); | 203 StartCloudPrintConnector(); |
| 204 #endif | 204 #endif |
| 205 | 205 |
| 206 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 206 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
| 207 if (CommandLine::ForCurrentProcess()->HasSwitch( | 207 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 208 switches::kEnableCloudDevices)) { | 208 switches::kEnableCloudDevices)) { |
| 209 StartWifiBootstrapping(); | 209 StartWifiBootstrapping(); |
| 210 } | 210 } |
| 211 #endif | 211 #endif |
| 212 | 212 |
| 213 CheckUserLoggedIn(); | 213 CheckUserLoggedIn(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void LocalDiscoveryUIHandler::HandleIsVisible(const base::ListValue* args) { | 216 void LocalDiscoveryUIHandler::HandleIsVisible(const base::ListValue* args) { |
| 217 bool is_visible = false; | 217 bool is_visible = false; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 ResetCurrentRegistration(); | 257 ResetCurrentRegistration(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void LocalDiscoveryUIHandler::HandleRequestDeviceList( | 260 void LocalDiscoveryUIHandler::HandleRequestDeviceList( |
| 261 const base::ListValue* args) { | 261 const base::ListValue* args) { |
| 262 failed_list_count_ = 0; | 262 failed_list_count_ = 0; |
| 263 succeded_list_count_ = 0; | 263 succeded_list_count_ = 0; |
| 264 cloud_devices_.clear(); | 264 cloud_devices_.clear(); |
| 265 | 265 |
| 266 cloud_print_printer_list_ = CreateApiFlow(); | 266 cloud_print_printer_list_ = CreateApiFlow(); |
| 267 if (CommandLine::ForCurrentProcess()->HasSwitch( | 267 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 268 switches::kEnableCloudDevices)) { | 268 switches::kEnableCloudDevices)) { |
| 269 cloud_device_list_ = CreateApiFlow(); | 269 cloud_device_list_ = CreateApiFlow(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 if (cloud_print_printer_list_) { | 272 if (cloud_print_printer_list_) { |
| 273 cloud_print_printer_list_->Start( | 273 cloud_print_printer_list_->Start( |
| 274 make_scoped_ptr<GCDApiFlow::Request>(new CloudPrintPrinterList(this))); | 274 make_scoped_ptr<GCDApiFlow::Request>(new CloudPrintPrinterList(this))); |
| 275 } | 275 } |
| 276 if (cloud_device_list_) { | 276 if (cloud_device_list_) { |
| 277 cloud_device_list_->Start( | 277 cloud_device_list_->Start( |
| 278 make_scoped_ptr<GCDApiFlow::Request>(new CloudDeviceList(this))); | 278 make_scoped_ptr<GCDApiFlow::Request>(new CloudDeviceList(this))); |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); | 784 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); |
| 785 | 785 |
| 786 web_ui()->CallJavascriptFunction( | 786 web_ui()->CallJavascriptFunction( |
| 787 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); | 787 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); |
| 788 } | 788 } |
| 789 } | 789 } |
| 790 | 790 |
| 791 #endif // ENABLE_WIFI_BOOTSTRAPPING | 791 #endif // ENABLE_WIFI_BOOTSTRAPPING |
| 792 | 792 |
| 793 } // namespace local_discovery | 793 } // namespace local_discovery |
| OLD | NEW |