| 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/snippets_internals_message_handler.h" | 5 #include "chrome/browser/ui/webui/snippets_internals_message_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (!dom_loaded_) return; | 67 if (!dom_loaded_) return; |
| 68 | 68 |
| 69 SendSnippets(); | 69 SendSnippets(); |
| 70 | 70 |
| 71 web_ui()->CallJavascriptFunctionUnsafe( | 71 web_ui()->CallJavascriptFunctionUnsafe( |
| 72 "chrome.SnippetsInternals.receiveJson", | 72 "chrome.SnippetsInternals.receiveJson", |
| 73 base::StringValue( | 73 base::StringValue( |
| 74 ntp_snippets_service_->snippets_fetcher()->last_json())); | 74 ntp_snippets_service_->snippets_fetcher()->last_json())); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void SnippetsInternalsMessageHandler::NTPSnippetsServiceDisabled() {} | 77 void SnippetsInternalsMessageHandler::NTPSnippetsServiceDisabledReasonChanged( |
| 78 ntp_snippets::DisabledReason disabled_reason) {} |
| 78 | 79 |
| 79 void SnippetsInternalsMessageHandler::RegisterMessages() { | 80 void SnippetsInternalsMessageHandler::RegisterMessages() { |
| 80 // additional initialization (web_ui() does not work from the constructor) | 81 // additional initialization (web_ui() does not work from the constructor) |
| 81 ntp_snippets_service_ = NTPSnippetsServiceFactory::GetInstance()-> | 82 ntp_snippets_service_ = NTPSnippetsServiceFactory::GetInstance()-> |
| 82 GetForProfile(Profile::FromWebUI(web_ui())); | 83 GetForProfile(Profile::FromWebUI(web_ui())); |
| 83 observer_.Add(ntp_snippets_service_); | 84 observer_.Add(ntp_snippets_service_); |
| 84 | 85 |
| 85 web_ui()->RegisterMessageCallback( | 86 web_ui()->RegisterMessageCallback( |
| 86 "loaded", | 87 "loaded", |
| 87 base::Bind(&SnippetsInternalsMessageHandler::HandleLoaded, | 88 base::Bind(&SnippetsInternalsMessageHandler::HandleLoaded, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 225 } |
| 225 | 226 |
| 226 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 227 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
| 227 const std::string& value) { | 228 const std::string& value) { |
| 228 base::StringValue string_name(name); | 229 base::StringValue string_name(name); |
| 229 base::StringValue string_value(value); | 230 base::StringValue string_value(value); |
| 230 | 231 |
| 231 web_ui()->CallJavascriptFunctionUnsafe( | 232 web_ui()->CallJavascriptFunctionUnsafe( |
| 232 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); | 233 "chrome.SnippetsInternals.receiveProperty", string_name, string_value); |
| 233 } | 234 } |
| OLD | NEW |