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 "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 SearchBox::Get(render_view)->display_instant_results(); | 899 SearchBox::Get(render_view)->display_instant_results(); |
900 DVLOG(1) << render_view << " " | 900 DVLOG(1) << render_view << " " |
901 << "GetDisplayInstantResults: " << display_instant_results; | 901 << "GetDisplayInstantResults: " << display_instant_results; |
902 args.GetReturnValue().Set(display_instant_results); | 902 args.GetReturnValue().Set(display_instant_results); |
903 } | 903 } |
904 | 904 |
905 // static | 905 // static |
906 void SearchBoxExtensionWrapper::GetThemeBackgroundInfo( | 906 void SearchBoxExtensionWrapper::GetThemeBackgroundInfo( |
907 const v8::FunctionCallbackInfo<v8::Value>& args) { | 907 const v8::FunctionCallbackInfo<v8::Value>& args) { |
908 content::RenderView* render_view = GetRenderView(); | 908 content::RenderView* render_view = GetRenderView(); |
909 if (!render_view) return; | 909 if (!render_view) |
| 910 return; |
910 | 911 |
911 DVLOG(1) << render_view << " GetThemeBackgroundInfo"; | 912 DVLOG(1) << render_view << " GetThemeBackgroundInfo"; |
912 const ThemeBackgroundInfo& theme_info = | 913 const ThemeBackgroundInfo& theme_info = |
913 SearchBox::Get(render_view)->GetThemeBackgroundInfo(); | 914 SearchBox::Get(render_view)->GetThemeBackgroundInfo(); |
| 915 if (!theme_info.IsValid()) |
| 916 return; |
| 917 |
914 v8::Handle<v8::Object> info = v8::Object::New(); | 918 v8::Handle<v8::Object> info = v8::Object::New(); |
915 | 919 |
916 // The theme background color is in RGBA format "rgba(R,G,B,A)" where R, G and | 920 // The theme background color is in RGBA format "rgba(R,G,B,A)" where R, G and |
917 // B are between 0 and 255 inclusive, and A is a double between 0 and 1 | 921 // B are between 0 and 255 inclusive, and A is a double between 0 and 1 |
918 // inclusive. | 922 // inclusive. |
919 // This is the CSS "background-color" format. | 923 // This is the CSS "background-color" format. |
920 // Value is always valid. | 924 // Value is always valid. |
921 info->Set(v8::String::New("colorRgba"), UTF8ToV8String( | 925 info->Set(v8::String::New("colorRgba"), UTF8ToV8String( |
922 // Convert the alpha using DoubleToString because StringPrintf will use | 926 // Convert the alpha using DoubleToString because StringPrintf will use |
923 // locale specific formatters (e.g., use , instead of . in German). | 927 // locale specific formatters (e.g., use , instead of . in German). |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 break; | 983 break; |
980 case THEME_BKGRND_IMAGE_REPEAT_X: | 984 case THEME_BKGRND_IMAGE_REPEAT_X: |
981 tiling = kCSSBackgroundRepeatX; | 985 tiling = kCSSBackgroundRepeatX; |
982 break; | 986 break; |
983 case THEME_BKGRND_IMAGE_REPEAT_Y: | 987 case THEME_BKGRND_IMAGE_REPEAT_Y: |
984 tiling = kCSSBackgroundRepeatY; | 988 tiling = kCSSBackgroundRepeatY; |
985 break; | 989 break; |
986 case THEME_BKGRND_IMAGE_REPEAT: | 990 case THEME_BKGRND_IMAGE_REPEAT: |
987 tiling = kCSSBackgroundRepeat; | 991 tiling = kCSSBackgroundRepeat; |
988 break; | 992 break; |
| 993 default: |
| 994 NOTREACHED(); |
989 } | 995 } |
990 info->Set(v8::String::New("imageTiling"), UTF8ToV8String(tiling)); | 996 info->Set(v8::String::New("imageTiling"), UTF8ToV8String(tiling)); |
991 | 997 |
992 // The theme background image height is only valid if |imageUrl| is valid. | 998 // The theme background image height is only valid if |imageUrl| is valid. |
993 info->Set(v8::String::New("imageHeight"), | 999 info->Set(v8::String::New("imageHeight"), |
994 v8::Int32::New(theme_info.image_height)); | 1000 v8::Int32::New(theme_info.image_height)); |
995 | 1001 |
996 // The attribution URL is only valid if the theme has attribution logo. | 1002 // The attribution URL is only valid if the theme has attribution logo. |
997 if (theme_info.has_attribution) { | 1003 if (theme_info.has_attribution) { |
998 info->Set(v8::String::New("attributionUrl"), UTF8ToV8String( | 1004 info->Set(v8::String::New("attributionUrl"), UTF8ToV8String( |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 Dispatch(frame, kDispatchInputCancelScript); | 1550 Dispatch(frame, kDispatchInputCancelScript); |
1545 } | 1551 } |
1546 | 1552 |
1547 // static | 1553 // static |
1548 void SearchBoxExtension::DispatchToggleVoiceSearch( | 1554 void SearchBoxExtension::DispatchToggleVoiceSearch( |
1549 WebKit::WebFrame* frame) { | 1555 WebKit::WebFrame* frame) { |
1550 Dispatch(frame, kDispatchToggleVoiceSearchScript); | 1556 Dispatch(frame, kDispatchToggleVoiceSearchScript); |
1551 } | 1557 } |
1552 | 1558 |
1553 } // namespace extensions_v8 | 1559 } // namespace extensions_v8 |
OLD | NEW |