| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/vr_shell/vr_shell_ui_ui.h" | 5 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_ui.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 #include <unordered_set> |
| 9 |
| 7 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" | 12 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" |
| 10 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 11 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
| 12 | 15 |
| 13 #if !defined(ENABLE_VR_SHELL_UI_DEV) | 16 #if !defined(ENABLE_VR_SHELL_UI_DEV) |
| 14 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/grit/browser_resources.h" | 18 #include "chrome/grit/browser_resources.h" |
| 16 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 DCHECK(it != pending_.end()); | 165 DCHECK(it != pending_.end()); |
| 163 std::string response; | 166 std::string response; |
| 164 source->GetResponseAsString(&response); | 167 source->GetResponseAsString(&response); |
| 165 | 168 |
| 166 if (response.empty() && use_localhost_) { | 169 if (response.empty() && use_localhost_) { |
| 167 if (source->GetOriginalURL().path().substr(1) == kRemoteDefaultPath) { | 170 if (source->GetOriginalURL().path().substr(1) == kRemoteDefaultPath) { |
| 168 // Failed to request default page from local host, try request default | 171 // Failed to request default page from local host, try request default |
| 169 // page from remote server. Empty string indicates default page. | 172 // page from remote server. Empty string indicates default page. |
| 170 use_localhost_ = false; | 173 use_localhost_ = false; |
| 171 content::URLDataSource::GotDataCallback callback = it->second; | 174 content::URLDataSource::GotDataCallback callback = it->second; |
| 172 StartDataRequest( | 175 StartDataRequest(std::string(), |
| 173 std::string(), | 176 content::ResourceRequestInfo::WebContentsGetter(), |
| 174 content::ResourceRequestInfo::WebContentsGetter(), | 177 callback); |
| 175 callback); | |
| 176 } | 178 } |
| 177 } else { | 179 } else { |
| 178 it->second.Run(base::RefCountedString::TakeString(&response)); | 180 it->second.Run(base::RefCountedString::TakeString(&response)); |
| 179 } | 181 } |
| 180 delete source; | 182 delete source; |
| 181 pending_.erase(it); | 183 pending_.erase(it); |
| 182 } | 184 } |
| 183 #else | 185 #else |
| 184 content::WebUIDataSource* CreateVrShellUIHTMLSource() { | 186 content::WebUIDataSource* CreateVrShellUIHTMLSource() { |
| 185 content::WebUIDataSource* source = | 187 content::WebUIDataSource* source = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 211 #if !defined(ENABLE_VR_SHELL_UI_DEV) | 213 #if !defined(ENABLE_VR_SHELL_UI_DEV) |
| 212 content::WebUIDataSource::Add(profile, CreateVrShellUIHTMLSource()); | 214 content::WebUIDataSource::Add(profile, CreateVrShellUIHTMLSource()); |
| 213 #else | 215 #else |
| 214 content::URLDataSource::Add( | 216 content::URLDataSource::Add( |
| 215 profile, new RemoteDataSource(profile->GetRequestContext())); | 217 profile, new RemoteDataSource(profile->GetRequestContext())); |
| 216 #endif | 218 #endif |
| 217 web_ui->AddMessageHandler(base::MakeUnique<VrShellUIMessageHandler>()); | 219 web_ui->AddMessageHandler(base::MakeUnique<VrShellUIMessageHandler>()); |
| 218 } | 220 } |
| 219 | 221 |
| 220 VrShellUIUI::~VrShellUIUI() {} | 222 VrShellUIUI::~VrShellUIUI() {} |
| OLD | NEW |