Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: content/browser/webui/web_ui_message_handler.cc

Issue 1896463003: WebUI: Add JavaScript lifecycle-control to WebUIMessageHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/browser/web_ui_message_handler.h" 5 #include "content/public/browser/web_ui_message_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 void WebUIMessageHandler::AllowJavascript() {
15 if (javascript_allowed_)
16 return;
17
Dan Beam 2016/04/18 23:13:20 we should be checking this was called validly here
tommycli 2016/04/19 17:45:38 Done.
18 javascript_allowed_ = true;
19 OnJavascriptAllowed();
20 }
21
14 bool WebUIMessageHandler::ExtractIntegerValue(const base::ListValue* value, 22 bool WebUIMessageHandler::ExtractIntegerValue(const base::ListValue* value,
15 int* out_int) { 23 int* out_int) {
16 std::string string_value; 24 std::string string_value;
17 if (value->GetString(0, &string_value)) 25 if (value->GetString(0, &string_value))
18 return base::StringToInt(string_value, out_int); 26 return base::StringToInt(string_value, out_int);
19 double double_value; 27 double double_value;
20 if (value->GetDouble(0, &double_value)) { 28 if (value->GetDouble(0, &double_value)) {
21 *out_int = static_cast<int>(double_value); 29 *out_int = static_cast<int>(double_value);
22 return true; 30 return true;
23 } 31 }
(...skipping 14 matching lines...) Expand all
38 46
39 base::string16 WebUIMessageHandler::ExtractStringValue( 47 base::string16 WebUIMessageHandler::ExtractStringValue(
40 const base::ListValue* value) { 48 const base::ListValue* value) {
41 base::string16 string16_value; 49 base::string16 string16_value;
42 if (value->GetString(0, &string16_value)) 50 if (value->GetString(0, &string16_value))
43 return string16_value; 51 return string16_value;
44 NOTREACHED(); 52 NOTREACHED();
45 return base::string16(); 53 return base::string16();
46 } 54 }
47 55
56 void WebUIMessageHandler::RenderViewReused() {
57 if (!javascript_allowed_)
58 return;
59
60 javascript_allowed_ = false;
61 OnJavascriptDisallowed();
62 }
63
48 } // namespace content 64 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698