Commit 3159bf77 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[WebUI][NTP] Renames module chrome.mojom to search.mojom in common/search

Otherwise the generated mojom-lite.js files will contain definitions
such as chrome.mojom.AutocompleteMatchSpec = {...} which won't closure
compile since |chrome| is defined as a constant namespace in
third_party/closure_compiler/externs/chrome.js:

/**
 * namespace
 * @const
 */
var chrome = {};

Bug: 1041129
Change-Id: I4c5664f796e029738ec37f519a9345c69f69f12e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2167427Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763528}
parent 89dbd5fc
......@@ -435,7 +435,7 @@ void InstantService::UpdateMostVisitedInfo() {
void InstantService::SendNewTabPageURLToRenderer(
content::RenderProcessHost* rph) {
if (auto* channel = rph->GetChannel()) {
mojo::AssociatedRemote<chrome::mojom::SearchBouncer> client;
mojo::AssociatedRemote<search::mojom::SearchBouncer> client;
channel->GetRemoteAssociatedInterface(&client);
client->SetNewTabPageURL(search::GetNewTabPageURL(profile_));
}
......
......@@ -20,14 +20,14 @@ namespace omnibox {
namespace {
base::flat_map<int32_t, chrome::mojom::SuggestionGroupPtr>
base::flat_map<int32_t, search::mojom::SuggestionGroupPtr>
CreateSuggestionGroupsMap(
PrefService* prefs,
const SearchSuggestionParser::HeadersMap& headers_map) {
base::flat_map<int32_t, chrome::mojom::SuggestionGroupPtr> result_map;
base::flat_map<int32_t, search::mojom::SuggestionGroupPtr> result_map;
for (const auto& pair : headers_map) {
chrome::mojom::SuggestionGroupPtr suggestion_group =
chrome::mojom::SuggestionGroup::New();
search::mojom::SuggestionGroupPtr suggestion_group =
search::mojom::SuggestionGroup::New();
suggestion_group->header = pair.second;
suggestion_group->hidden =
omnibox::IsSuggestionGroupIdHidden(prefs, pair.first);
......@@ -99,24 +99,24 @@ std::string AutocompleteMatchVectorIconToResourceName(
}
}
std::vector<chrome::mojom::AutocompleteMatchPtr> CreateAutocompleteMatches(
std::vector<search::mojom::AutocompleteMatchPtr> CreateAutocompleteMatches(
const AutocompleteResult& result) {
std::vector<chrome::mojom::AutocompleteMatchPtr> matches;
std::vector<search::mojom::AutocompleteMatchPtr> matches;
for (const AutocompleteMatch& match : result) {
chrome::mojom::AutocompleteMatchPtr mojom_match =
chrome::mojom::AutocompleteMatch::New();
search::mojom::AutocompleteMatchPtr mojom_match =
search::mojom::AutocompleteMatch::New();
mojom_match->allowed_to_be_default_match =
match.allowed_to_be_default_match;
mojom_match->contents = match.contents;
for (const auto& contents_class : match.contents_class) {
mojom_match->contents_class.push_back(
chrome::mojom::ACMatchClassification::New(contents_class.offset,
search::mojom::ACMatchClassification::New(contents_class.offset,
contents_class.style));
}
mojom_match->description = match.description;
for (const auto& description_class : match.description_class) {
mojom_match->description_class.push_back(
chrome::mojom::ACMatchClassification::New(description_class.offset,
search::mojom::ACMatchClassification::New(description_class.offset,
description_class.style));
}
mojom_match->destination_url = match.destination_url.spec();
......@@ -137,11 +137,11 @@ std::vector<chrome::mojom::AutocompleteMatchPtr> CreateAutocompleteMatches(
return matches;
}
chrome::mojom::AutocompleteResultPtr CreateAutocompleteResult(
search::mojom::AutocompleteResultPtr CreateAutocompleteResult(
const base::string16& input,
const AutocompleteResult& result,
PrefService* prefs) {
return chrome::mojom::AutocompleteResult::New(
return search::mojom::AutocompleteResult::New(
input, CreateSuggestionGroupsMap(prefs, result.headers_map()),
CreateAutocompleteMatches(result));
}
......
......@@ -40,10 +40,10 @@ extern const char kSearchIconResourceName[];
std::string AutocompleteMatchVectorIconToResourceName(
const gfx::VectorIcon& icon);
std::vector<chrome::mojom::AutocompleteMatchPtr> CreateAutocompleteMatches(
std::vector<search::mojom::AutocompleteMatchPtr> CreateAutocompleteMatches(
const AutocompleteResult& result);
chrome::mojom::AutocompleteResultPtr CreateAutocompleteResult(
search::mojom::AutocompleteResultPtr CreateAutocompleteResult(
const base::string16& input,
const AutocompleteResult& result,
PrefService* prefs);
......
......@@ -38,12 +38,12 @@ bool IsInInstantProcess(content::RenderFrameHost* render_frame) {
class EmbeddedSearchClientFactoryImpl
: public SearchIPCRouter::EmbeddedSearchClientFactory,
public chrome::mojom::EmbeddedSearchConnector {
public search::mojom::EmbeddedSearchConnector {
public:
// |web_contents| and |binding| must outlive this object.
EmbeddedSearchClientFactoryImpl(
content::WebContents* web_contents,
mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearch>* receiver)
mojo::AssociatedReceiver<search::mojom::EmbeddedSearch>* receiver)
: client_receiver_(receiver), factory_receivers_(web_contents, this) {
DCHECK(web_contents);
DCHECK(receiver);
......@@ -51,37 +51,37 @@ class EmbeddedSearchClientFactoryImpl
embedded_search_client_.reset();
}
chrome::mojom::EmbeddedSearchClient* GetEmbeddedSearchClient() override {
search::mojom::EmbeddedSearchClient* GetEmbeddedSearchClient() override {
return embedded_search_client_.is_bound() ? embedded_search_client_.get()
: nullptr;
}
private:
void Connect(
mojo::PendingAssociatedReceiver<chrome::mojom::EmbeddedSearch> receiver,
mojo::PendingAssociatedRemote<chrome::mojom::EmbeddedSearchClient> client)
mojo::PendingAssociatedReceiver<search::mojom::EmbeddedSearch> receiver,
mojo::PendingAssociatedRemote<search::mojom::EmbeddedSearchClient> client)
override;
// An interface used to push updates to the frame that connected to us. Before
// we've been connected to a frame, messages sent on this interface go into
// the void.
mojo::AssociatedRemote<chrome::mojom::EmbeddedSearchClient>
mojo::AssociatedRemote<search::mojom::EmbeddedSearchClient>
embedded_search_client_;
// Used to bind incoming pending receivers to the implementation, which lives
// in SearchIPCRouter.
mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearch>* client_receiver_;
mojo::AssociatedReceiver<search::mojom::EmbeddedSearch>* client_receiver_;
// Receivers used to listen to connection requests.
content::WebContentsFrameReceiverSet<chrome::mojom::EmbeddedSearchConnector>
content::WebContentsFrameReceiverSet<search::mojom::EmbeddedSearchConnector>
factory_receivers_;
DISALLOW_COPY_AND_ASSIGN(EmbeddedSearchClientFactoryImpl);
};
void EmbeddedSearchClientFactoryImpl::Connect(
mojo::PendingAssociatedReceiver<chrome::mojom::EmbeddedSearch> receiver,
mojo::PendingAssociatedRemote<chrome::mojom::EmbeddedSearchClient> client) {
mojo::PendingAssociatedReceiver<search::mojom::EmbeddedSearch> receiver,
mojo::PendingAssociatedRemote<search::mojom::EmbeddedSearchClient> client) {
content::RenderFrameHost* frame = factory_receivers_.GetCurrentTargetFrame();
const bool is_main_frame = frame->GetParent() == nullptr;
if (!IsInInstantProcess(frame) || !is_main_frame) {
......@@ -112,7 +112,7 @@ SearchIPCRouter::SearchIPCRouter(content::WebContents* web_contents,
SearchIPCRouter::~SearchIPCRouter() = default;
void SearchIPCRouter::AutocompleteResultChanged(
chrome::mojom::AutocompleteResultPtr result) {
search::mojom::AutocompleteResultPtr result) {
if (!policy_->ShouldProcessAutocompleteResultChanged(is_active_tab_) ||
!embedded_search_client()) {
return;
......
......@@ -37,7 +37,7 @@ class SearchIPCRouterTest;
// SearchIPCRouter is responsible for receiving and sending IPC messages between
// the browser and the Instant page.
class SearchIPCRouter : public content::WebContentsObserver,
public chrome::mojom::EmbeddedSearch {
public search::mojom::EmbeddedSearch {
public:
// SearchIPCRouter calls its delegate in response to messages received from
// the page.
......@@ -237,14 +237,14 @@ class SearchIPCRouter : public content::WebContentsObserver,
virtual bool ShouldProcessToggleSuggestionGroupIdVisibility() = 0;
};
// Creates chrome::mojom::EmbeddedSearchClient connections on request.
// Creates search::mojom::EmbeddedSearchClient connections on request.
class EmbeddedSearchClientFactory {
public:
EmbeddedSearchClientFactory() = default;
virtual ~EmbeddedSearchClientFactory() = default;
// The returned pointer is owned by the factory.
virtual chrome::mojom::EmbeddedSearchClient* GetEmbeddedSearchClient() = 0;
virtual search::mojom::EmbeddedSearchClient* GetEmbeddedSearchClient() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(EmbeddedSearchClientFactory);
......@@ -256,7 +256,7 @@ class SearchIPCRouter : public content::WebContentsObserver,
~SearchIPCRouter() override;
// Updates the renderer with the autocomplete results.
void AutocompleteResultChanged(chrome::mojom::AutocompleteResultPtr result);
void AutocompleteResultChanged(search::mojom::AutocompleteResultPtr result);
// Updates the renderer with the given autocomplete match's image data.
void AutocompleteMatchImageAvailable(uint32_t match_index,
......@@ -289,7 +289,7 @@ class SearchIPCRouter : public content::WebContentsObserver,
// Called when the tab corresponding to |this| instance is deactivated.
void OnTabDeactivated();
// chrome::mojom::EmbeddedSearch:
// search::mojom::EmbeddedSearch:
void FocusOmnibox(int page_id, bool focus) override;
void DeleteMostVisitedItem(int page_seq_no, const GURL& url) override;
void UndoMostVisitedDeletion(int page_seq_no, const GURL& url) override;
......@@ -391,7 +391,7 @@ class SearchIPCRouter : public content::WebContentsObserver,
// Used by unit tests.
int page_seq_no_for_testing() const { return commit_counter_; }
chrome::mojom::EmbeddedSearchClient* embedded_search_client() {
search::mojom::EmbeddedSearchClient* embedded_search_client() {
return embedded_search_client_factory_->GetEmbeddedSearchClient();
}
......@@ -408,7 +408,7 @@ class SearchIPCRouter : public content::WebContentsObserver,
// Receiver for the connected main frame. We only allow one frame to connect
// at the moment, but this could be extended to a map of connected frames, if
// desired.
mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearch> receiver_{this};
mojo::AssociatedReceiver<search::mojom::EmbeddedSearch> receiver_{this};
std::unique_ptr<EmbeddedSearchClientFactory> embedded_search_client_factory_;
......
......@@ -178,7 +178,7 @@ class MockEmbeddedSearchClientFactory
: public SearchIPCRouter::EmbeddedSearchClientFactory {
public:
MOCK_METHOD0(GetEmbeddedSearchClient,
chrome::mojom::EmbeddedSearchClient*(void));
search::mojom::EmbeddedSearchClient*(void));
};
} // namespace
......@@ -1105,10 +1105,10 @@ TEST_F(SearchIPCRouterTest, SendAutocompleteResultChanged) {
.Times(1);
GetSearchIPCRouter().AutocompleteResultChanged(
chrome::mojom::AutocompleteResult::New(
search::mojom::AutocompleteResult::New(
base::string16(),
base::flat_map<int32_t, chrome::mojom::SuggestionGroupPtr>(),
std::vector<chrome::mojom::AutocompleteMatchPtr>()));
base::flat_map<int32_t, search::mojom::SuggestionGroupPtr>(),
std::vector<search::mojom::AutocompleteMatchPtr>()));
}
TEST_F(SearchIPCRouterTest, IgnoreAutocompleteResultChanged) {
......@@ -1122,10 +1122,10 @@ TEST_F(SearchIPCRouterTest, IgnoreAutocompleteResultChanged) {
.Times(0);
GetSearchIPCRouter().AutocompleteResultChanged(
chrome::mojom::AutocompleteResult::New(
search::mojom::AutocompleteResult::New(
base::string16(),
base::flat_map<int32_t, chrome::mojom::SuggestionGroupPtr>(),
std::vector<chrome::mojom::AutocompleteMatchPtr>()));
base::flat_map<int32_t, search::mojom::SuggestionGroupPtr>(),
std::vector<search::mojom::AutocompleteMatchPtr>()));
}
TEST_F(SearchIPCRouterTest, SendAutocompleteMatchImageAvailable) {
......
......@@ -722,7 +722,7 @@ void SearchTabHelper::OnDeleteAutocompleteMatchConfirm(
DCHECK(autocomplete_controller_);
bool success = false;
std::vector<chrome::mojom::AutocompleteMatchPtr> matches;
std::vector<search::mojom::AutocompleteMatchPtr> matches;
if (accepted && search::DefaultSearchProviderIsGoogle(profile()) &&
autocomplete_controller_->result().size() > line) {
......
......@@ -39,7 +39,7 @@ class MockEmbeddedSearchClientFactory
: public SearchIPCRouter::EmbeddedSearchClientFactory {
public:
MOCK_METHOD0(GetEmbeddedSearchClient,
chrome::mojom::EmbeddedSearchClient*(void));
search::mojom::EmbeddedSearchClient*(void));
};
} // namespace
......
......@@ -12,13 +12,13 @@
#include "chrome/common/search/search.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
class MockEmbeddedSearchClient : public chrome::mojom::EmbeddedSearchClient {
class MockEmbeddedSearchClient : public search::mojom::EmbeddedSearchClient {
public:
MockEmbeddedSearchClient();
~MockEmbeddedSearchClient() override;
MOCK_METHOD1(AutocompleteResultChanged,
void(chrome::mojom::AutocompleteResultPtr result));
void(search::mojom::AutocompleteResultPtr result));
MOCK_METHOD3(AutocompleteMatchImageAvailable,
void(uint32_t, const std::string&, const std::string&));
MOCK_METHOD1(SetPageSequenceNumber, void(int));
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module chrome.mojom;
module search.mojom;
import "mojo/public/mojom/base/string16.mojom";
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module chrome.mojom;
module search.mojom;
import "chrome/common/search/omnibox.mojom";
import "mojo/public/mojom/base/string16.mojom";
......@@ -208,7 +208,7 @@ struct SearchBoxTheme;
// example, the browser will tell the frame if the omnibox got focus.
interface EmbeddedSearchClient {
// Updates the NTP realbox with the autocomplete results.
AutocompleteResultChanged(chrome.mojom.AutocompleteResult result);
AutocompleteResultChanged(search.mojom.AutocompleteResult result);
// Updates the NTP realbox popup with the image or favicon data URL for the
// given |match_index| and |url| where |url| is an AutocompleteMatch image_url
......
......@@ -16,12 +16,12 @@ deps = [
]
type_mappings = [
# TODO(dbeam): NTP -> Ntp.
"chrome.mojom.NTPLoggingEventType=::NTPLoggingEventType",
"chrome.mojom.NTPSuggestionsLoggingEventType=::NTPSuggestionsLoggingEventType",
"chrome.mojom.NTPTileImpression=::ntp_tiles::NTPTileImpression",
"chrome.mojom.OmniboxFocusState=::OmniboxFocusState",
"chrome.mojom.OmniboxFocusChangeReason=::OmniboxFocusChangeReason",
"chrome.mojom.InstantMostVisitedInfo=::InstantMostVisitedInfo",
"chrome.mojom.NtpTheme=::NtpTheme",
"chrome.mojom.SearchBoxTheme=::SearchBoxTheme",
"search.mojom.NTPLoggingEventType=::NTPLoggingEventType",
"search.mojom.NTPSuggestionsLoggingEventType=::NTPSuggestionsLoggingEventType",
"search.mojom.NTPTileImpression=::ntp_tiles::NTPTileImpression",
"search.mojom.OmniboxFocusState=::OmniboxFocusState",
"search.mojom.OmniboxFocusChangeReason=::OmniboxFocusChangeReason",
"search.mojom.InstantMostVisitedInfo=::InstantMostVisitedInfo",
"search.mojom.NtpTheme=::NtpTheme",
"search.mojom.SearchBoxTheme=::SearchBoxTheme",
]
......@@ -51,6 +51,6 @@ void SearchBouncer::SetNewTabPageURL(const GURL& new_tab_page_url) {
}
void SearchBouncer::BindSearchBouncerReceiver(
mojo::PendingAssociatedReceiver<chrome::mojom::SearchBouncer> receiver) {
mojo::PendingAssociatedReceiver<search::mojom::SearchBouncer> receiver) {
search_bouncer_receiver_.Bind(std::move(receiver));
}
......@@ -16,7 +16,7 @@
// SearchBouncer tracks a set of URLs which should be transferred back to the
// browser process for potential reassignment to an Instant renderer process.
class SearchBouncer : public content::RenderThreadObserver,
public chrome::mojom::SearchBouncer {
public search::mojom::SearchBouncer {
public:
SearchBouncer();
~SearchBouncer() override;
......@@ -30,16 +30,16 @@ class SearchBouncer : public content::RenderThreadObserver,
// Returns whether |url| is a valid Instant new tab page URL.
bool IsNewTabPage(const GURL& url) const;
// chrome::mojom::SearchBouncer:
// search::mojom::SearchBouncer:
void SetNewTabPageURL(const GURL& new_tab_page_url) override;
private:
void BindSearchBouncerReceiver(
mojo::PendingAssociatedReceiver<chrome::mojom::SearchBouncer> receiver);
mojo::PendingAssociatedReceiver<search::mojom::SearchBouncer> receiver);
GURL new_tab_page_url_;
mojo::AssociatedReceiver<chrome::mojom::SearchBouncer>
mojo::AssociatedReceiver<search::mojom::SearchBouncer>
search_bouncer_receiver_{this};
DISALLOW_COPY_AND_ASSIGN(SearchBouncer);
......
......@@ -207,9 +207,9 @@ SearchBox::SearchBox(content::RenderFrame* render_frame)
most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize),
has_received_most_visited_(false) {
// Connect to the embedded search interface in the browser.
mojo::AssociatedRemote<chrome::mojom::EmbeddedSearchConnector> connector;
mojo::AssociatedRemote<search::mojom::EmbeddedSearchConnector> connector;
render_frame->GetRemoteAssociatedInterfaces()->GetInterface(&connector);
mojo::PendingAssociatedRemote<chrome::mojom::EmbeddedSearchClient>
mojo::PendingAssociatedRemote<search::mojom::EmbeddedSearchClient>
embedded_search_client;
receiver_.Bind(embedded_search_client.InitWithNewEndpointAndPassReceiver(),
render_frame->GetTaskRunner(
......@@ -544,7 +544,7 @@ void SearchBox::DeleteCustomLinkResult(bool success) {
}
void SearchBox::AutocompleteResultChanged(
chrome::mojom::AutocompleteResultPtr result) {
search::mojom::AutocompleteResultPtr result) {
if (can_run_js_in_renderframe_) {
SearchBoxExtension::DispatchAutocompleteResultChanged(
render_frame()->GetWebFrame(), std::move(result));
......
......@@ -28,7 +28,7 @@
// https://www.chromium.org/embeddedsearch).
class SearchBox : public content::RenderFrameObserver,
public content::RenderFrameObserverTracker<SearchBox>,
public chrome::mojom::EmbeddedSearchClient {
public search::mojom::EmbeddedSearchClient {
public:
// Helper class for GenerateImageURLFromTransientURL() to adapt SearchBox's
// instance, thereby allow mocking for unit tests.
......@@ -246,9 +246,9 @@ class SearchBox : public content::RenderFrameObserver,
ui::PageTransition transition) override;
void OnDestruct() override;
// Overridden from chrome::mojom::EmbeddedSearchClient:
// Overridden from search::mojom::EmbeddedSearchClient:
void AutocompleteResultChanged(
chrome::mojom::AutocompleteResultPtr result) override;
search::mojom::AutocompleteResultPtr result) override;
void AutocompleteMatchImageAvailable(uint32_t match_index,
const std::string& image_url,
const std::string& data_url) override;
......@@ -269,9 +269,9 @@ class SearchBox : public content::RenderFrameObserver,
GURL GetURLForMostVisitedItem(InstantRestrictedID item_id) const;
// The connection to the EmbeddedSearch service in the browser process.
mojo::AssociatedRemote<chrome::mojom::EmbeddedSearch>
mojo::AssociatedRemote<search::mojom::EmbeddedSearch>
embedded_search_service_;
mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearchClient> receiver_{this};
mojo::AssociatedReceiver<search::mojom::EmbeddedSearchClient> receiver_{this};
// Whether it's legal to execute JavaScript in |render_frame()|.
// This class may want to execute JS in response to IPCs (via the
......
......@@ -428,9 +428,9 @@ SearchBox* GetSearchBoxForCurrentContext() {
}
base::Value CreateAutocompleteMatches(
const std::vector<chrome::mojom::AutocompleteMatchPtr>& matches) {
const std::vector<search::mojom::AutocompleteMatchPtr>& matches) {
base::Value list(base::Value::Type::LIST);
for (const chrome::mojom::AutocompleteMatchPtr& match : matches) {
for (const search::mojom::AutocompleteMatchPtr& match : matches) {
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetBoolKey("allowedToBeDefaultMatch",
match->allowed_to_be_default_match);
......@@ -470,7 +470,7 @@ base::Value CreateAutocompleteMatches(
}
base::Value CreateSuggestionGroupsMap(
const base::flat_map<int32_t, chrome::mojom::SuggestionGroupPtr>&
const base::flat_map<int32_t, search::mojom::SuggestionGroupPtr>&
suggestion_groups_map) {
base::Value result_map(base::Value::Type::DICTIONARY);
for (const auto& pair : suggestion_groups_map) {
......@@ -1526,7 +1526,7 @@ void SearchBoxExtension::DispatchDeleteCustomLinkResult(
// static
void SearchBoxExtension::DispatchAutocompleteResultChanged(
blink::WebLocalFrame* frame,
chrome::mojom::AutocompleteResultPtr result) {
search::mojom::AutocompleteResultPtr result) {
base::Value dict(base::Value::Type::DICTIONARY);
dict.SetStringKey("input", result->input);
dict.SetKey("matches", CreateAutocompleteMatches(result->matches));
......
......@@ -39,7 +39,7 @@ class SearchBoxExtension {
bool success);
static void DispatchAutocompleteResultChanged(
blink::WebLocalFrame* frame,
chrome::mojom::AutocompleteResultPtr result);
search::mojom::AutocompleteResultPtr result);
static void DispatchAutocompleteMatchImageAvailable(
blink::WebLocalFrame* frame,
uint32_t match_index,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment