OLD | NEW |
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/extensions/app_notify_channel_setup.h" | 5 #include "chrome/browser/extensions/app_notify_channel_setup.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 std::string("not_available"))); | 72 std::string("not_available"))); |
73 return; | 73 return; |
74 } | 74 } |
75 | 75 |
76 url_fetcher_.reset(URLFetcher::Create( | 76 url_fetcher_.reset(URLFetcher::Create( |
77 0, channel_server_url, URLFetcher::POST, this)); | 77 0, channel_server_url, URLFetcher::POST, this)); |
78 | 78 |
79 // TODO(asargent) - we eventually want this to use the browser login | 79 // TODO(asargent) - we eventually want this to use the browser login |
80 // credentials instead of the regular cookie store, but for now to aid server | 80 // credentials instead of the regular cookie store, but for now to aid server |
81 // development, we're just using the regular cookie store. | 81 // development, we're just using the regular cookie store. |
82 url_fetcher_->set_request_context(profile_->GetRequestContext()); | 82 url_fetcher_->SetRequestContext(profile_->GetRequestContext()); |
83 std::string data = "client_id=" + EscapeUrlEncodedData(client_id_, true); | 83 std::string data = "client_id=" + EscapeUrlEncodedData(client_id_, true); |
84 url_fetcher_->set_upload_data("application/x-www-form-urlencoded", data); | 84 url_fetcher_->SetUploadData("application/x-www-form-urlencoded", data); |
85 url_fetcher_->Start(); | 85 url_fetcher_->Start(); |
86 } | 86 } |
87 | 87 |
88 void AppNotifyChannelSetup::OnURLFetchComplete(const URLFetcher* source) { | 88 void AppNotifyChannelSetup::OnURLFetchComplete( |
| 89 const content::URLFetcher* source) { |
89 CHECK(source); | 90 CHECK(source); |
90 net::URLRequestStatus status = source->status(); | 91 net::URLRequestStatus status = source->GetStatus(); |
91 | 92 |
92 if (status.status() == net::URLRequestStatus::SUCCESS && | 93 if (status.status() == net::URLRequestStatus::SUCCESS && |
93 source->response_code() == 200) { | 94 source->GetResponseCode() == 200) { |
94 // TODO(asargent) - we need to parse the response from |source| here. | 95 // TODO(asargent) - we need to parse the response from |source| here. |
95 ReportResult("dummy_do_not_use", ""); | 96 ReportResult("dummy_do_not_use", ""); |
96 } else { | 97 } else { |
97 ReportResult("", "channel_service_error"); | 98 ReportResult("", "channel_service_error"); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 void AppNotifyChannelSetup::ReportResult( | 102 void AppNotifyChannelSetup::ReportResult( |
102 const std::string& channel_id, | 103 const std::string& channel_id, |
103 const std::string& error) { | 104 const std::string& error) { |
104 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 105 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
105 if (delegate_.get()) | 106 if (delegate_.get()) |
106 delegate_->AppNotifyChannelSetupComplete( | 107 delegate_->AppNotifyChannelSetupComplete( |
107 channel_id, error, return_route_id_, callback_id_); | 108 channel_id, error, return_route_id_, callback_id_); |
108 Release(); // Matches AddRef in Start. | 109 Release(); // Matches AddRef in Start. |
109 } | 110 } |
OLD | NEW |