| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (!dom_loaded_) return; | 71 if (!dom_loaded_) return; |
| 72 | 72 |
| 73 SendSnippets(); | 73 SendSnippets(); |
| 74 SendDiscardedSnippets(); | 74 SendDiscardedSnippets(); |
| 75 | 75 |
| 76 web_ui()->CallJavascriptFunction( | 76 web_ui()->CallJavascriptFunction( |
| 77 "chrome.SnippetsInternals.receiveJson", | 77 "chrome.SnippetsInternals.receiveJson", |
| 78 base::StringValue(ntp_snippets_service_->last_json())); | 78 base::StringValue(ntp_snippets_service_->last_json())); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void SnippetsInternalsMessageHandler::NTPSnippetsServiceCleared() {} |
| 82 |
| 81 void SnippetsInternalsMessageHandler::RegisterMessages() { | 83 void SnippetsInternalsMessageHandler::RegisterMessages() { |
| 82 // additional initialization (web_ui() does not work from the constructor) | 84 // additional initialization (web_ui() does not work from the constructor) |
| 83 ntp_snippets_service_ = NTPSnippetsServiceFactory::GetInstance()-> | 85 ntp_snippets_service_ = NTPSnippetsServiceFactory::GetInstance()-> |
| 84 GetForProfile(Profile::FromWebUI(web_ui())); | 86 GetForProfile(Profile::FromWebUI(web_ui())); |
| 85 observer_.Add(ntp_snippets_service_); | 87 observer_.Add(ntp_snippets_service_); |
| 86 | 88 |
| 87 web_ui()->RegisterMessageCallback( | 89 web_ui()->RegisterMessageCallback( |
| 88 "loaded", | 90 "loaded", |
| 89 base::Bind(&SnippetsInternalsMessageHandler::HandleLoaded, | 91 base::Bind(&SnippetsInternalsMessageHandler::HandleLoaded, |
| 90 base::Unretained(this))); | 92 base::Unretained(this))); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 238 } |
| 237 | 239 |
| 238 void SnippetsInternalsMessageHandler::SendString(const std::string& name, | 240 void SnippetsInternalsMessageHandler::SendString(const std::string& name, |
| 239 const std::string& value) { | 241 const std::string& value) { |
| 240 base::StringValue string_name(name); | 242 base::StringValue string_name(name); |
| 241 base::StringValue string_value(value); | 243 base::StringValue string_value(value); |
| 242 | 244 |
| 243 web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveProperty", | 245 web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveProperty", |
| 244 string_name, string_value); | 246 string_name, string_value); |
| 245 } | 247 } |
| OLD | NEW |