| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/json/json_reader.h" | |
| 6 #include "blimp/engine/app/blimp_browser_main_parts.h" | |
| 7 #include "blimp/engine/app/blimp_content_browser_client.h" | |
| 8 #include "blimp/engine/app/settings_manager.h" | |
| 9 #include "blimp/engine/grit/blimp_browser_resources.h" | |
| 10 #include "blimp/engine/mojo/blob_channel_service.h" | |
| 11 #include "content/public/browser/browser_thread.h" | |
| 12 #include "content/public/common/service_names.mojom.h" | |
| 13 #include "services/service_manager/public/cpp/interface_registry.h" | |
| 14 #include "ui/base/resource/resource_bundle.h" | |
| 15 | |
| 16 namespace blimp { | |
| 17 namespace engine { | |
| 18 | |
| 19 BlimpContentBrowserClient::BlimpContentBrowserClient() {} | |
| 20 | |
| 21 BlimpContentBrowserClient::~BlimpContentBrowserClient() {} | |
| 22 | |
| 23 content::BrowserMainParts* BlimpContentBrowserClient::CreateBrowserMainParts( | |
| 24 const content::MainFunctionParams& parameters) { | |
| 25 blimp_browser_main_parts_ = new BlimpBrowserMainParts(parameters); | |
| 26 // BrowserMainLoop takes ownership of the returned BrowserMainParts. | |
| 27 return blimp_browser_main_parts_; | |
| 28 } | |
| 29 | |
| 30 void BlimpContentBrowserClient::OverrideWebkitPrefs( | |
| 31 content::RenderViewHost* render_view_host, | |
| 32 content::WebPreferences* prefs) { | |
| 33 if (!blimp_browser_main_parts_) | |
| 34 return; | |
| 35 | |
| 36 if (!blimp_browser_main_parts_->GetSettingsManager()) | |
| 37 return; | |
| 38 | |
| 39 blimp_browser_main_parts_->GetSettingsManager()->UpdateWebkitPreferences( | |
| 40 prefs); | |
| 41 } | |
| 42 | |
| 43 BlimpBrowserContext* BlimpContentBrowserClient::GetBrowserContext() { | |
| 44 return blimp_browser_main_parts_->GetBrowserContext(); | |
| 45 } | |
| 46 | |
| 47 void BlimpContentBrowserClient::ExposeInterfacesToRenderer( | |
| 48 service_manager::InterfaceRegistry* registry, | |
| 49 content::RenderProcessHost* render_process_host) { | |
| 50 registry->AddInterface<mojom::BlobChannel>(base::Bind( | |
| 51 &BlobChannelService::BindRequest, | |
| 52 base::Unretained(blimp_browser_main_parts_->GetBlobChannelService()))); | |
| 53 } | |
| 54 | |
| 55 std::unique_ptr<base::Value> | |
| 56 BlimpContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) { | |
| 57 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 58 int id = -1; | |
| 59 if (name == content::mojom::kBrowserServiceName) { | |
| 60 id = IDR_BLIMP_CONTENT_BROWSER_MANIFEST_OVERLAY; | |
| 61 } | |
| 62 if (id == -1) { | |
| 63 return nullptr; | |
| 64 } | |
| 65 | |
| 66 base::StringPiece manifest_contents = | |
| 67 rb.GetRawDataResourceForScale(id, ui::ScaleFactor::SCALE_FACTOR_NONE); | |
| 68 return base::JSONReader::Read(manifest_contents); | |
| 69 } | |
| 70 | |
| 71 } // namespace engine | |
| 72 } // namespace blimp | |
| OLD | NEW |