Commit 0342c90d authored by Travis Skare's avatar Travis Skare Committed by Commit Bot

[Omnibox] Document provider: add icons for most popular missed types.

PDF, Image (png/jpeg/gif), and video (mp4)

Change-Id: I8e97b3dc376a599cb2900f5a31c8d5cfa1999623
Reviewed-on: https://chromium-review.googlesource.com/c/1457421Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Travis Skare <skare@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630018}
parent f89e926c
......@@ -30,13 +30,16 @@ aggregate_vector_icons("omnibox_vector_icons") {
"answer_when_is.icon",
"blank.icon",
"bookmark.icon",
"calculator.icon",
"clear.icon",
"drive_docs.icon",
"drive_forms.icon",
"drive_image.icon",
"drive_logo.icon",
"drive_pdf.icon",
"drive_sheets.icon",
"drive_slides.icon",
"calculator.icon",
"drive_video.icon",
"extension_app.icon",
"find_in_page.icon",
"http.icon",
......
......@@ -250,6 +250,12 @@ const gfx::VectorIcon& AutocompleteMatch::GetVectorIcon(
return omnibox::kDriveSheetsIcon;
case DocumentType::DRIVE_SLIDES:
return omnibox::kDriveSlidesIcon;
case DocumentType::DRIVE_IMAGE:
return omnibox::kDriveImageIcon;
case DocumentType::DRIVE_PDF:
return omnibox::kDrivePdfIcon;
case DocumentType::DRIVE_VIDEO:
return omnibox::kDriveVideoIcon;
case DocumentType::DRIVE_OTHER:
return omnibox::kDriveLogoIcon;
default:
......
......@@ -124,6 +124,9 @@ struct AutocompleteMatch {
DRIVE_FORMS,
DRIVE_SHEETS,
DRIVE_SLIDES,
DRIVE_IMAGE,
DRIVE_PDF,
DRIVE_VIDEO,
DRIVE_OTHER
};
......
......@@ -7,6 +7,7 @@
#include <stddef.h>
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include <vector>
......@@ -70,6 +71,29 @@ const char kFormMimetype[] = "application/vnd.google-apps.form";
const char kSpreadsheetMimetype[] = "application/vnd.google-apps.spreadsheet";
const char kPresentationMimetype[] = "application/vnd.google-apps.presentation";
// Returns mappings from MIME types to overridden icons.
AutocompleteMatch::DocumentType GetIconForMIMEType(
const base::StringPiece& mimetype) {
static const auto kIconMap =
std::map<base::StringPiece, AutocompleteMatch::DocumentType>{
{kDocumentMimetype, AutocompleteMatch::DocumentType::DRIVE_DOCS},
{kFormMimetype, AutocompleteMatch::DocumentType::DRIVE_FORMS},
{kSpreadsheetMimetype, AutocompleteMatch::DocumentType::DRIVE_SHEETS},
{kPresentationMimetype,
AutocompleteMatch::DocumentType::DRIVE_SLIDES},
{"image/jpeg", AutocompleteMatch::DocumentType::DRIVE_IMAGE},
{"image/png", AutocompleteMatch::DocumentType::DRIVE_IMAGE},
{"image/gif", AutocompleteMatch::DocumentType::DRIVE_IMAGE},
{"application/pdf", AutocompleteMatch::DocumentType::DRIVE_PDF},
{"video/mp4", AutocompleteMatch::DocumentType::DRIVE_VIDEO},
};
const auto& iterator = kIconMap.find(mimetype);
return iterator != kIconMap.end()
? iterator->second
: AutocompleteMatch::DocumentType::DRIVE_OTHER;
}
const char kErrorMessageAdminDisabled[] =
"Not eligible to query due to admin disabled Chrome search settings.";
const char kErrorMessageRetryLater[] = "Not eligible to query, see retry info.";
......@@ -469,17 +493,7 @@ bool DocumentProvider::ParseDocumentSearchResults(const base::Value& root_val,
const base::DictionaryValue* metadata = nullptr;
if (result->GetDictionary("metadata", &metadata)) {
if (metadata->GetString("mimeType", &mimetype)) {
if (mimetype == kDocumentMimetype) {
match.document_type = AutocompleteMatch::DocumentType::DRIVE_DOCS;
} else if (mimetype == kFormMimetype) {
match.document_type = AutocompleteMatch::DocumentType::DRIVE_FORMS;
} else if (mimetype == kSpreadsheetMimetype) {
match.document_type = AutocompleteMatch::DocumentType::DRIVE_SHEETS;
} else if (mimetype == kPresentationMimetype) {
match.document_type = AutocompleteMatch::DocumentType::DRIVE_SLIDES;
} else {
match.document_type = AutocompleteMatch::DocumentType::DRIVE_OTHER;
}
match.document_type = GetIconForMIMEType(mimetype);
}
std::string update_time;
metadata->GetString("updateTime", &update_time);
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Source: ic_drive_image_black_24dp.svg
// --> Resized to 16dp
// --> SVGOMG --> Skiafy
// Mountain coordinates were manually rounded to grid.
CANVAS_DIMENSIONS, 16,
PATH_COLOR_ARGB, 0xFF, 0xEA, 0x43, 0x35,
MOVE_TO, 16, 14,
V_LINE_TO, 2,
R_CUBIC_TO, 0, -1, -1, -2, -2, -2,
H_LINE_TO, 2,
CUBIC_TO, 1, 0, 0, 1, 0, 2,
V_LINE_TO, 14,
R_CUBIC_TO, 0, 1, 1, 2, 2, 2,
H_LINE_TO, 14,
R_CUBIC_TO, 1, 0, 2, -1, 2, -2,
CLOSE,
MOVE_TO, 5, 9,
R_LINE_TO, 2, 3,
R_LINE_TO, 3, -4,
R_LINE_TO, 4, 5,
H_LINE_TO, 2,
CLOSE
\ No newline at end of file
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Source: ic_drive_pdf_black_48dp.svg
// --> Resized to 32dp.
// --> SVGOMG --> Skiafy
CANVAS_DIMENSIONS, 32,
PATH_COLOR_ARGB, 0xFF, 0xEA, 0x43, 0x35,
MOVE_TO, 7.1f, 15.1f,
H_LINE_TO, 9,
R_V_LINE_TO, -1.8f,
H_LINE_TO, 7,
CLOSE,
MOVE_TO, 28.4f, 0,
H_LINE_TO, 3.6f,
CUBIC_TO, 1.6f, 0, 0, 1.6f, 0, 3.6f,
R_V_LINE_TO, 24.8f,
R_CUBIC_TO, 0, 2, 1.6f, 3.6f, 3.6f, 3.6f,
R_H_LINE_TO, 24.8f,
R_CUBIC_TO, 2, 0, 3.6f, -1.6f, 3.6f, -3.6f,
V_LINE_TO, 3.6f,
R_CUBIC_TO, 0, -2, -1.6f, -3.6f, -3.6f, -3.6f,
CLOSE,
MOVE_TO, 11.6f, 15.1f,
R_CUBIC_TO, 0, 1.5f, -1.2f, 2.7f, -2.7f, 2.7f,
H_LINE_TO, 7,
R_V_LINE_TO, 3.5f,
H_LINE_TO, 4.4f,
V_LINE_TO, 10.7f,
H_LINE_TO, 9,
R_CUBIC_TO, 1.5f, 0, 2.7f, 1.2f, 2.7f, 2.6f,
CLOSE,
R_MOVE_TO, 17.7f, -1.8f,
H_LINE_TO, 25,
R_V_LINE_TO, 1.8f,
R_H_LINE_TO, 2.7f,
R_V_LINE_TO, 2.7f,
R_H_LINE_TO, -2.7f,
R_V_LINE_TO, 3.5f,
R_H_LINE_TO, -2.7f,
V_LINE_TO, 10.7f,
R_H_LINE_TO, 7.1f,
CLOSE,
R_MOVE_TO, -8.9f, 5.4f,
R_CUBIC_TO, 0, 1.4f, -1.1f, 2.6f, -2.6f, 2.6f,
R_H_LINE_TO, -4.5f,
V_LINE_TO, 10.7f,
R_H_LINE_TO, 4.5f,
R_CUBIC_TO, 1.5f, 0, 2.6f, 1.2f, 2.6f, 2.6f,
CLOSE,
R_MOVE_TO, -4.4f, 0,
R_H_LINE_TO, 1.8f,
R_V_LINE_TO, -5.4f,
H_LINE_TO, 16,
CLOSE
\ No newline at end of file
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Source: ic_drive_video_black_24dp.svg
// --> Resized to 16dp, rounded shape to 12px vertical for sharpness.
// --> SVGOMG --> Skiafy
// Clapperboard diagonals were not rounded.
CANVAS_DIMENSIONS, 16,
PATH_COLOR_ARGB, 0xFF, 0xEA, 0x43, 0x35,
MOVE_TO, 12.8f, 2,
R_LINE_TO, 1.6f, 2.6f,
H_LINE_TO, 12,
LINE_TO, 10.4f, 2,
H_LINE_TO, 8.8f,
R_LINE_TO, 1.6f, 2.6f,
H_LINE_TO, 8,
LINE_TO, 6.4f, 2,
H_LINE_TO, 4.8f,
R_LINE_TO, 1.6f, 2.6f,
H_LINE_TO, 4,
LINE_TO, 2.4f, 2,
R_H_LINE_TO, -0.8f,
CUBIC_TO, 0.7f, 2, 0, 2.7f, 0, 3.5f,
R_V_LINE_TO, 9,
R_CUBIC_TO, 0, 0.8f, 0.7f, 1.5f, 1.6f, 1.5f,
R_H_LINE_TO, 12.8f,
R_CUBIC_TO, 0.9f, 0, 1.6f, -0.7f, 1.6f, -1.5f,
V_LINE_TO, 2,
CLOSE
\ No newline at end of file
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