summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 04:17:08 +0000
committersreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 04:17:08 +0000
commit299fc6d7a4a72895e8196992b573c93a11d4a109 (patch)
tree8e18fe7ce9accad53d620d038a34dd656d435e7c /chrome
parentd1034eb9724dd15cdc0c185d6857e749859d03ef (diff)
downloadchromium_src-299fc6d7a4a72895e8196992b573c93a11d4a109.zip
chromium_src-299fc6d7a4a72895e8196992b573c93a11d4a109.tar.gz
chromium_src-299fc6d7a4a72895e8196992b573c93a11d4a109.tar.bz2
Remove unused focus/blur API from searchbox (Instant).
BUG=80118 R=jered@chromium.org,jschuh@chromium.org TEST=none; no change in functionality. Review URL: https://codereview.chromium.org/11415013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168131 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/instant/instant_browsertest.cc39
-rw-r--r--chrome/browser/instant/instant_controller.cc10
-rw-r--r--chrome/browser/instant/instant_loader.cc12
-rw-r--r--chrome/browser/instant/instant_loader.h6
-rw-r--r--chrome/common/render_messages.h4
-rw-r--r--chrome/renderer/resources/extensions/searchbox/searchbox_api.js4
-rw-r--r--chrome/renderer/searchbox/searchbox.cc20
-rw-r--r--chrome/renderer/searchbox/searchbox.h2
-rw-r--r--chrome/renderer/searchbox/searchbox_extension.cc42
-rw-r--r--chrome/test/data/instant.html10
10 files changed, 5 insertions, 144 deletions
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index f62a597..3a6f7d6 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -155,8 +155,6 @@ class InstantTest : public InProcessBrowserTest {
GetIntFromJS(rvh, "onsubmitcalls", &onsubmitcalls_) &&
GetIntFromJS(rvh, "oncancelcalls", &oncancelcalls_) &&
GetIntFromJS(rvh, "onresizecalls", &onresizecalls_) &&
- GetIntFromJS(rvh, "onfocuscalls", &onfocuscalls_) &&
- GetIntFromJS(rvh, "onblurcalls", &onblurcalls_) &&
GetStringFromJS(rvh, "value", &value_) &&
GetBoolFromJS(rvh, "verbatim", &verbatim_) &&
GetIntFromJS(rvh, "height", &height_);
@@ -184,8 +182,6 @@ class InstantTest : public InProcessBrowserTest {
int onsubmitcalls_;
int oncancelcalls_;
int onresizecalls_;
- int onfocuscalls_;
- int onblurcalls_;
std::string value_;
bool verbatim_;
@@ -244,6 +240,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OmniboxFocusLoadsInstant) {
// Test that the onchange event is dispatched upon typing in the omnibox.
IN_PROC_BROWSER_TEST_F(InstantTest, OnChangeEvent) {
ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
// Use the Instant page as the active tab, so we can exploit its visibility
// handler to check visibility transitions.
@@ -257,7 +254,6 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnChangeEvent) {
EXPECT_EQ(0, active_tab_onvisibilitycalls);
// Typing "query" into the omnibox causes the first onchange event.
- FocusOmniboxAndWaitForInstantSupport();
SetOmniboxTextAndWaitForInstantToShow("query");
// The page suggested "query suggestion" is inline autocompleted into the
@@ -420,31 +416,6 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnResizeEvent) {
EXPECT_LT(0, height_);
}
-// Test that the searchbox isFocused property and focus and blur events work.
-IN_PROC_BROWSER_TEST_F(InstantTest, Focus) {
- ASSERT_NO_FATAL_FAILURE(SetupInstant());
- FocusOmniboxAndWaitForInstantSupport();
-
- content::RenderViewHost* preview_rvh =
- instant()->GetPreviewContents()->web_contents()->GetRenderViewHost();
-
- bool is_focused = false;
- EXPECT_TRUE(GetBoolFromJS(preview_rvh, "chrome.searchBox.isFocused",
- &is_focused));
- EXPECT_TRUE(is_focused);
-
- instant()->OnAutocompleteGotFocus();
- instant()->OnAutocompleteLostFocus(NULL);
-
- EXPECT_TRUE(GetBoolFromJS(preview_rvh, "chrome.searchBox.isFocused",
- &is_focused));
- EXPECT_FALSE(is_focused);
-
- EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents()));
- EXPECT_EQ(1, onfocuscalls_);
- EXPECT_EQ(1, onblurcalls_);
-}
-
// Test that the INSTANT_COMPLETE_NOW behavior works as expected.
IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) {
ASSERT_NO_FATAL_FAILURE(SetupInstant());
@@ -567,8 +538,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, RejectsURLs) {
// Test that Instant doesn't fire for intranet paths that look like searches.
// http://crbug.com/99836
-// Disabled, http://crbug.com/80118 .
-IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_IntranetPathLooksLikeSearch) {
+IN_PROC_BROWSER_TEST_F(InstantTest, IntranetPathLooksLikeSearch) {
ASSERT_NO_FATAL_FAILURE(SetupInstant());
// Navigate to a URL that looks like a search (when the scheme is stripped).
@@ -698,8 +668,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsTwo) {
}
// Test that a non-Instant search provider shows no previews.
-// Disabled, http://crbug.com/80118 .
-IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_NonInstantSearchProvider) {
+IN_PROC_BROWSER_TEST_F(InstantTest, NonInstantSearchProvider) {
instant_url_ = test_server()->GetURL("files/empty.html");
ASSERT_NO_FATAL_FAILURE(SetupInstant());
@@ -971,6 +940,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) {
// Test that the preview can be committed onto a new tab.
IN_PROC_BROWSER_TEST_F(InstantTest, CommitInNewTab) {
ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
// Use the Instant page as the active tab, so we can exploit its visibility
// handler to check visibility transitions.
@@ -982,7 +952,6 @@ IN_PROC_BROWSER_TEST_F(InstantTest, CommitInNewTab) {
"onvisibilitycalls", &active_tab_onvisibilitycalls));
EXPECT_EQ(0, active_tab_onvisibilitycalls);
- FocusOmniboxAndWaitForInstantSupport();
SetOmniboxTextAndWaitForInstantToShow("search");
// Stash a reference to the preview, so we can refer to it after commit.
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 04c95ce..4f8ba01 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -462,8 +462,6 @@ void InstantController::OnAutocompleteLostFocus(
if (!GetPreviewContents())
return;
- loader_->OnAutocompleteLostFocus();
-
// It's bizarre if custom NTP content disappears when the user focuses
// outside the omnibox.
if (model_.preview_state() == InstantModel::CUSTOM_NTP_CONTENT)
@@ -546,8 +544,6 @@ void InstantController::OnAutocompleteLostFocus(
void InstantController::OnAutocompleteGotFocus() {
is_omnibox_focused_ = true;
- if (GetPreviewContents())
- loader_->OnAutocompleteGotFocus();
CreateDefaultLoader();
}
@@ -696,11 +692,7 @@ void InstantController::ResetLoader(const std::string& instant_url,
loader_.reset(new InstantLoader(this, instant_url, active_tab));
loader_->Init();
- // Ensure the searchbox API has the correct focus state and context.
- if (is_omnibox_focused_)
- loader_->OnAutocompleteGotFocus();
- else
- loader_->OnAutocompleteLostFocus();
+ // Ensure the searchbox API has the correct context.
loader_->OnActiveTabModeChanged(active_tab_mode_.is_ntp());
// Reset the loader timer.
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index 98d1002..47681aa 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -359,18 +359,6 @@ void InstantLoader::OnUpOrDownKeyPressed(int count) {
count));
}
-void InstantLoader::OnAutocompleteGotFocus() {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxFocus(rvh->GetRoutingID()));
-}
-
-void InstantLoader::OnAutocompleteLostFocus() {
- content::RenderViewHost* rvh =
- preview_contents_->web_contents()->GetRenderViewHost();
- rvh->Send(new ChromeViewMsg_SearchBoxBlur(rvh->GetRoutingID()));
-}
-
void InstantLoader::OnActiveTabModeChanged(bool active_tab_is_ntp) {
content::RenderViewHost* rvh =
preview_contents_->web_contents()->GetRenderViewHost();
diff --git a/chrome/browser/instant/instant_loader.h b/chrome/browser/instant/instant_loader.h
index c32cba8..1f52b16 100644
--- a/chrome/browser/instant/instant_loader.h
+++ b/chrome/browser/instant/instant_loader.h
@@ -73,12 +73,6 @@ class InstantLoader : public content::NotificationObserver {
// is a repeat count, negative for moving up, positive for moving down.
void OnUpOrDownKeyPressed(int count);
- // Tells the preview page that the searchbox has been focused.
- void OnAutocompleteGotFocus();
-
- // Tells the preview page that the searchbox has lost focus.
- void OnAutocompleteLostFocus();
-
// Tells the preview page that the active tab's "NTP status" has changed.
void OnActiveTabModeChanged(bool active_tab_is_ntp);
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 8953ef0..500f7f3 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -295,10 +295,6 @@ IPC_MESSAGE_ROUTED1(ChromeViewMsg_SearchBoxAutocompleteResults,
IPC_MESSAGE_ROUTED1(ChromeViewMsg_SearchBoxUpOrDownKeyPressed,
int /* count */)
-IPC_MESSAGE_ROUTED0(ChromeViewMsg_SearchBoxFocus)
-
-IPC_MESSAGE_ROUTED0(ChromeViewMsg_SearchBoxBlur)
-
IPC_MESSAGE_ROUTED1(ChromeViewMsg_SearchBoxActiveTabModeChanged,
bool /* active_tab_is_ntp */)
diff --git a/chrome/renderer/resources/extensions/searchbox/searchbox_api.js b/chrome/renderer/resources/extensions/searchbox/searchbox_api.js
index 23d4ce2..fd6cd62 100644
--- a/chrome/renderer/resources/extensions/searchbox/searchbox_api.js
+++ b/chrome/renderer/resources/extensions/searchbox/searchbox_api.js
@@ -29,7 +29,6 @@ if (!chrome.searchBox) {
native function GetWidth();
native function GetHeight();
native function GetAutocompleteResults();
- native function GetIsFocused();
native function GetContext();
native function NavigateContentWindow();
native function SetSuggestions();
@@ -175,7 +174,6 @@ if (!chrome.searchBox) {
this.__defineGetter__('width', GetWidth);
this.__defineGetter__('height', GetHeight);
this.__defineGetter__('nativeSuggestions', GetAutocompleteResultsWrapper);
- this.__defineGetter__('isFocused', GetIsFocused);
this.__defineGetter__('context', GetContext);
this.setSuggestions = function(text) {
SetSuggestions(text);
@@ -207,8 +205,6 @@ if (!chrome.searchBox) {
this.onresize = null;
this.onautocompleteresults = null;
this.onkeypress = null;
- this.onfocus = null;
- this.onblur = null;
this.oncontextchange = null;
};
}
diff --git a/chrome/renderer/searchbox/searchbox.cc b/chrome/renderer/searchbox/searchbox.cc
index f074237..f5ff4b1 100644
--- a/chrome/renderer/searchbox/searchbox.cc
+++ b/chrome/renderer/searchbox/searchbox.cc
@@ -17,7 +17,6 @@ SearchBox::SearchBox(content::RenderView* render_view)
selection_end_(0),
results_base_(0),
last_results_base_(0),
- is_focused_(false),
active_tab_is_ntp_(false) {
}
@@ -92,8 +91,6 @@ bool SearchBox::OnMessageReceived(const IPC::Message& message) {
OnAutocompleteResults)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxUpOrDownKeyPressed,
OnUpOrDownKeyPressed)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFocus, OnFocus)
- IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxBlur, OnBlur)
IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxActiveTabModeChanged,
OnActiveTabModeChanged)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -171,22 +168,6 @@ void SearchBox::OnUpOrDownKeyPressed(int count) {
}
}
-void SearchBox::OnFocus() {
- is_focused_ = true;
- if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
- extensions_v8::SearchBoxExtension::DispatchFocus(
- render_view()->GetWebView()->mainFrame());
- }
-}
-
-void SearchBox::OnBlur() {
- is_focused_ = false;
- if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
- extensions_v8::SearchBoxExtension::DispatchBlur(
- render_view()->GetWebView()->mainFrame());
- }
-}
-
void SearchBox::OnActiveTabModeChanged(bool active_tab_is_ntp) {
active_tab_is_ntp_ = active_tab_is_ntp;
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
@@ -203,6 +184,5 @@ void SearchBox::Reset() {
results_base_ = 0;
rect_ = gfx::Rect();
autocomplete_results_.clear();
- is_focused_ = false;
active_tab_is_ntp_ = false;
}
diff --git a/chrome/renderer/searchbox/searchbox.h b/chrome/renderer/searchbox/searchbox.h
index 10b3b22..d2d752a 100644
--- a/chrome/renderer/searchbox/searchbox.h
+++ b/chrome/renderer/searchbox/searchbox.h
@@ -41,7 +41,6 @@ class SearchBox : public content::RenderViewObserver,
size_t selection_start() const { return selection_start_; }
size_t selection_end() const { return selection_end_; }
int results_base() const { return results_base_; }
- bool is_focused() const { return is_focused_; }
bool active_tab_is_ntp() const { return active_tab_is_ntp_; }
gfx::Rect GetRect();
@@ -81,7 +80,6 @@ class SearchBox : public content::RenderViewObserver,
std::vector<InstantAutocompleteResult> autocomplete_results_;
size_t last_results_base_;
std::vector<InstantAutocompleteResult> last_autocomplete_results_;
- bool is_focused_;
bool active_tab_is_ntp_;
DISALLOW_COPY_AND_ASSIGN(SearchBox);
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index 54e5e91..c2aa810 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -109,24 +109,6 @@ static const char kDispatchUpOrDownKeyPressEventScript[] =
" true;"
"}";
-static const char kDispatchFocusEventScript[] =
- "if (window.chrome &&"
- " window.chrome.searchBox &&"
- " window.chrome.searchBox.onfocus &&"
- " typeof window.chrome.searchBox.onfocus == 'function') {"
- " window.chrome.searchBox.onfocus();"
- " true;"
- "}";
-
-static const char kDispatchBlurEventScript[] =
- "if (window.chrome &&"
- " window.chrome.searchBox &&"
- " window.chrome.searchBox.onblur &&"
- " typeof window.chrome.searchBox.onblur == 'function') {"
- " window.chrome.searchBox.onblur();"
- " true;"
- "}";
-
static const char kDispatchContextChangeEventScript[] =
"if (window.chrome &&"
" window.chrome.searchBox &&"
@@ -182,9 +164,6 @@ class SearchBoxExtensionWrapper : public v8::Extension {
static v8::Handle<v8::Value> GetAutocompleteResults(
const v8::Arguments& args);
- // Gets whether the search box is focused.
- static v8::Handle<v8::Value> GetIsFocused(const v8::Arguments& args);
-
// Gets the current session context.
static v8::Handle<v8::Value> GetContext(const v8::Arguments& args);
@@ -241,8 +220,6 @@ v8::Handle<v8::FunctionTemplate> SearchBoxExtensionWrapper::GetNativeFunction(
return v8::FunctionTemplate::New(GetHeight);
if (name->Equals(v8::String::New("GetAutocompleteResults")))
return v8::FunctionTemplate::New(GetAutocompleteResults);
- if (name->Equals(v8::String::New("GetIsFocused")))
- return v8::FunctionTemplate::New(GetIsFocused);
if (name->Equals(v8::String::New("GetContext")))
return v8::FunctionTemplate::New(GetContext);
if (name->Equals(v8::String::New("NavigateContentWindow")))
@@ -378,15 +355,6 @@ v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetAutocompleteResults(
}
// static
-v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetIsFocused(
- const v8::Arguments& args) {
- content::RenderView* render_view = GetRenderView();
- if (!render_view) return v8::Undefined();
-
- return v8::Boolean::New(SearchBox::Get(render_view)->is_focused());
-}
-
-// static
v8::Handle<v8::Value> SearchBoxExtensionWrapper::GetContext(
const v8::Arguments& args) {
content::RenderView* render_view = GetRenderView();
@@ -628,16 +596,6 @@ void SearchBoxExtension::DispatchUpOrDownKeyPress(WebKit::WebFrame* frame,
}
// static
-void SearchBoxExtension::DispatchFocus(WebKit::WebFrame* frame) {
- Dispatch(frame, kDispatchFocusEventScript);
-}
-
-// static
-void SearchBoxExtension::DispatchBlur(WebKit::WebFrame* frame) {
- Dispatch(frame, kDispatchBlurEventScript);
-}
-
-// static
void SearchBoxExtension::DispatchContextChange(WebKit::WebFrame* frame) {
Dispatch(frame, kDispatchContextChangeEventScript);
}
diff --git a/chrome/test/data/instant.html b/chrome/test/data/instant.html
index c5f050e..eded0e0b 100644
--- a/chrome/test/data/instant.html
+++ b/chrome/test/data/instant.html
@@ -9,8 +9,6 @@ var onchangecalls = 0;
var onsubmitcalls = 0;
var oncancelcalls = 0;
var onresizecalls = 0;
-var onfocuscalls = 0;
-var onblurcalls = 0;
var value = "";
var verbatim = false;
@@ -46,14 +44,6 @@ chrome.searchBox.onresize = function() {
height = chrome.searchBox.height;
};
-chrome.searchBox.onfocus = function() {
- onfocuscalls++;
-};
-
-chrome.searchBox.onblur = function() {
- onblurcalls++;
-};
-
if (chrome.searchBox.value != "")
chrome.searchBox.onchange();