OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/renderer/searchbox/searchbox_extension.h" | 5 #include "chrome/renderer/searchbox/searchbox_extension.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/json/string_escape.h" | 13 #include "base/json/string_escape.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "chrome/common/search/instant_types.h" | 19 #include "chrome/common/search/instant_types.h" |
20 #include "chrome/common/search/ntp_logging_events.h" | 20 #include "chrome/common/search/ntp_logging_events.h" |
21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
22 #include "chrome/grit/renderer_resources.h" | 22 #include "chrome/grit/renderer_resources.h" |
23 #include "chrome/renderer/searchbox/searchbox.h" | 23 #include "chrome/renderer/searchbox/searchbox.h" |
24 #include "components/crx_file/id_util.h" | 24 #include "components/crx_file/id_util.h" |
25 #include "components/ntp_tiles/ntp_tile_source.h" | 25 #include "components/ntp_tiles/tile_source.h" |
26 #include "content/public/renderer/render_frame.h" | 26 #include "content/public/renderer/render_frame.h" |
27 #include "content/public/renderer/render_view.h" | 27 #include "content/public/renderer/render_view.h" |
28 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 28 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
29 #include "third_party/WebKit/public/web/WebDocument.h" | 29 #include "third_party/WebKit/public/web/WebDocument.h" |
30 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 30 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
31 #include "third_party/WebKit/public/web/WebScriptSource.h" | 31 #include "third_party/WebKit/public/web/WebScriptSource.h" |
32 #include "third_party/WebKit/public/web/WebView.h" | 32 #include "third_party/WebKit/public/web/WebView.h" |
33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
34 #include "ui/base/window_open_disposition.h" | 34 #include "ui/base/window_open_disposition.h" |
35 #include "ui/events/keycodes/keyboard_codes.h" | 35 #include "ui/events/keycodes/keyboard_codes.h" |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 if (!render_frame) | 994 if (!render_frame) |
995 return; | 995 return; |
996 | 996 |
997 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber()) { | 997 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber()) { |
998 ThrowInvalidParameters(args); | 998 ThrowInvalidParameters(args); |
999 return; | 999 return; |
1000 } | 1000 } |
1001 | 1001 |
1002 DVLOG(1) << render_frame << " LogMostVisitedImpression"; | 1002 DVLOG(1) << render_frame << " LogMostVisitedImpression"; |
1003 | 1003 |
1004 if (args[1]->Uint32Value() <= | 1004 if (args[1]->Uint32Value() <= static_cast<int>(ntp_tiles::TileSource::LAST)) { |
1005 static_cast<int>(ntp_tiles::NTPTileSource::LAST)) { | 1005 ntp_tiles::TileSource tile_source = |
1006 ntp_tiles::NTPTileSource tile_source = | 1006 static_cast<ntp_tiles::TileSource>(args[1]->Uint32Value()); |
1007 static_cast<ntp_tiles::NTPTileSource>(args[1]->Uint32Value()); | |
1008 SearchBox::Get(render_frame) | 1007 SearchBox::Get(render_frame) |
1009 ->LogMostVisitedImpression(args[0]->IntegerValue(), tile_source); | 1008 ->LogMostVisitedImpression(args[0]->IntegerValue(), tile_source); |
1010 } | 1009 } |
1011 } | 1010 } |
1012 | 1011 |
1013 // static | 1012 // static |
1014 void SearchBoxExtensionWrapper::LogMostVisitedNavigation( | 1013 void SearchBoxExtensionWrapper::LogMostVisitedNavigation( |
1015 const v8::FunctionCallbackInfo<v8::Value>& args) { | 1014 const v8::FunctionCallbackInfo<v8::Value>& args) { |
1016 content::RenderFrame* render_frame = GetRenderFrameWithCheckedOrigin( | 1015 content::RenderFrame* render_frame = GetRenderFrameWithCheckedOrigin( |
1017 GURL(chrome::kChromeSearchMostVisitedUrl)); | 1016 GURL(chrome::kChromeSearchMostVisitedUrl)); |
1018 if (!render_frame) | 1017 if (!render_frame) |
1019 return; | 1018 return; |
1020 | 1019 |
1021 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber()) { | 1020 if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsNumber()) { |
1022 ThrowInvalidParameters(args); | 1021 ThrowInvalidParameters(args); |
1023 return; | 1022 return; |
1024 } | 1023 } |
1025 | 1024 |
1026 DVLOG(1) << render_frame << " LogMostVisitedNavigation"; | 1025 DVLOG(1) << render_frame << " LogMostVisitedNavigation"; |
1027 | 1026 |
1028 if (args[1]->Uint32Value() <= | 1027 if (args[1]->Uint32Value() <= static_cast<int>(ntp_tiles::TileSource::LAST)) { |
1029 static_cast<int>(ntp_tiles::NTPTileSource::LAST)) { | 1028 ntp_tiles::TileSource tile_source = |
1030 ntp_tiles::NTPTileSource tile_source = | 1029 static_cast<ntp_tiles::TileSource>(args[1]->Uint32Value()); |
1031 static_cast<ntp_tiles::NTPTileSource>(args[1]->Uint32Value()); | |
1032 SearchBox::Get(render_frame) | 1030 SearchBox::Get(render_frame) |
1033 ->LogMostVisitedNavigation(args[0]->IntegerValue(), tile_source); | 1031 ->LogMostVisitedNavigation(args[0]->IntegerValue(), tile_source); |
1034 } | 1032 } |
1035 } | 1033 } |
1036 | 1034 |
1037 // static | 1035 // static |
1038 void SearchBoxExtensionWrapper::Paste( | 1036 void SearchBoxExtensionWrapper::Paste( |
1039 const v8::FunctionCallbackInfo<v8::Value>& args) { | 1037 const v8::FunctionCallbackInfo<v8::Value>& args) { |
1040 content::RenderFrame* render_frame = GetRenderFrame(); | 1038 content::RenderFrame* render_frame = GetRenderFrame(); |
1041 if (!render_frame) | 1039 if (!render_frame) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 ThrowInvalidParameters(args); | 1091 ThrowInvalidParameters(args); |
1094 return; | 1092 return; |
1095 } | 1093 } |
1096 | 1094 |
1097 DVLOG(1) << render_frame << " UndoMostVisitedDeletion"; | 1095 DVLOG(1) << render_frame << " UndoMostVisitedDeletion"; |
1098 SearchBox::Get(render_frame) | 1096 SearchBox::Get(render_frame) |
1099 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); | 1097 ->UndoMostVisitedDeletion(args[0]->ToInteger()->Value()); |
1100 } | 1098 } |
1101 | 1099 |
1102 } // namespace extensions_v8 | 1100 } // namespace extensions_v8 |
OLD | NEW |