Commit e244e1ae authored by noyau@chromium.org's avatar noyau@chromium.org

Bring up of the metadata accessors for enhanced bookmarks.

BUG=None

Review URL: https://codereview.chromium.org/336263003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278656 0039d316-1c4b-4281-b951-d872f2087c98
parent cd0ebe9f
......@@ -101,6 +101,7 @@
'domain_reliability/util_unittest.cc',
'enhanced_bookmarks/image_store_ios_unittest.mm',
'enhanced_bookmarks/image_store_unittest.cc',
'enhanced_bookmarks/metadata_accessor_unittest.cc',
'feedback/feedback_common_unittest.cc',
'feedback/feedback_data_unittest.cc',
'feedback/feedback_uploader_unittest.cc',
......
......@@ -15,6 +15,7 @@
'../sql/sql.gyp:sql',
'../ui/gfx/gfx.gyp:gfx',
'../url/url.gyp:url_lib',
'enhanced_bookmarks_proto',
],
'sources': [
'enhanced_bookmarks/image_store.cc',
......@@ -22,6 +23,8 @@
'enhanced_bookmarks/image_store_util.cc',
'enhanced_bookmarks/image_store_util.h',
'enhanced_bookmarks/image_store_util_ios.mm',
'enhanced_bookmarks/metadata_accessor.cc',
'enhanced_bookmarks/metadata_accessor.h',
'enhanced_bookmarks/persistent_image_store.cc',
'enhanced_bookmarks/persistent_image_store.h',
],
......@@ -48,5 +51,17 @@
'enhanced_bookmarks/test_image_store.h',
],
},
{
'target_name': 'enhanced_bookmarks_proto',
'type': 'static_library',
'sources': [
'enhanced_bookmarks/proto/metadata.proto',
],
'variables': {
'proto_in_dir': './enhanced_bookmarks/proto',
'proto_out_dir': 'components/enhanced_bookmarks/proto',
},
'includes': [ '../build/protoc.gypi' ],
},
],
}
// Copyright 2014 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.
#include "components/enhanced_bookmarks/metadata_accessor.h"
#include <iomanip>
#include "base/base64.h"
#include "base/rand_util.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/enhanced_bookmarks/proto/metadata.pb.h"
#include "ui/base/models/tree_node_iterator.h"
using namespace image::collections;
namespace {
// Helper method for working with bookmark metainfo.
std::string DataForMetaInfoField(const BookmarkNode* node,
const std::string& field) {
const BookmarkNode::MetaInfoMap* map = node->GetMetaInfoMap();
if (!map)
return "";
BookmarkNode::MetaInfoMap::const_iterator it = map->find(field);
if (it == map->end())
return "";
std::string decoded;
bool result = base::Base64Decode((*it).second, &decoded);
if (!result)
return "";
return decoded;
}
// Sets a new remote id on a bookmark.
std::string SetRemoteIdOnBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node) {
// Generate 16 digit hex string random id.
std::stringstream random_id;
random_id << std::hex << std::setfill('0') << std::setw(16);
random_id << base::RandUint64() << base::RandUint64();
std::string random_id_str = random_id.str();
bookmark_model->SetNodeMetaInfo(
node, enhanced_bookmarks::kIdDataKey, random_id_str);
return random_id_str;
}
// Helper method for working with ImageData_ImageInfo.
bool PopulateImageData(const ImageData_ImageInfo& info,
GURL* out_url,
int* width,
int* height) {
if (!info.has_url() || !info.has_width() || !info.has_height())
return false;
GURL url(info.url());
if (!url.is_valid())
return false;
*out_url = url;
*width = info.width();
*height = info.height();
return true;
}
} // namespace
namespace enhanced_bookmarks {
const char* kPageDataKey = "stars.pageData";
const char* kImageDataKey = "stars.imageData";
const char* kIdDataKey = "stars.id";
const char* kNoteKey = "stars.note";
std::string RemoteIdFromBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node) {
const BookmarkNode::MetaInfoMap* map = node->GetMetaInfoMap();
if (!map)
return SetRemoteIdOnBookmark(bookmark_model, node);
BookmarkNode::MetaInfoMap::const_iterator it = map->find(kIdDataKey);
if (it == map->end())
return SetRemoteIdOnBookmark(bookmark_model, node);
DCHECK(it->second.length());
return it->second;
}
void SetDescriptionForBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node,
const std::string& description) {
bookmark_model->SetNodeMetaInfo(node, kNoteKey, description);
}
std::string DescriptionFromBookmark(const BookmarkNode* node) {
const BookmarkNode::MetaInfoMap* map = node->GetMetaInfoMap();
if (!map)
return "";
// First, look for a custom note set by the user.
BookmarkNode::MetaInfoMap::const_iterator it = map->find(kNoteKey);
if (it != map->end() && it->second != "")
return it->second;
// If none are present, return the snippet.
return SnippetFromBookmark(node);
}
bool SetOriginalImageForBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node,
const GURL& url,
int width,
int height) {
DCHECK(url.is_valid());
std::string decoded(DataForMetaInfoField(node, kImageDataKey));
ImageData data;
// Try to populate the imageData with the existing data.
if (decoded != "") {
// If the parsing fails, something is wrong. Immediately fail.
bool result = data.ParseFromString(decoded);
if (!result)
return false;
}
scoped_ptr<ImageData_ImageInfo> info(new ImageData_ImageInfo);
info->set_url(url.spec());
info->set_width(width);
info->set_height(height);
data.set_allocated_original_info(info.release());
std::string output;
bool result = data.SerializePartialToString(&output);
if (!result)
return false;
std::string encoded;
base::Base64Encode(output, &encoded);
bookmark_model->SetNodeMetaInfo(node, kImageDataKey, encoded);
// Ensure that the bookmark has a stars.id, to trigger the server processing.
RemoteIdFromBookmark(bookmark_model, node);
return true;
}
bool OriginalImageFromBookmark(const BookmarkNode* node,
GURL* url,
int* width,
int* height) {
std::string decoded(DataForMetaInfoField(node, kImageDataKey));
if (decoded == "")
return false;
ImageData data;
bool result = data.ParseFromString(decoded);
if (!result)
return false;
if (!data.has_original_info())
return false;
return PopulateImageData(data.original_info(), url, width, height);
}
bool ThumbnailImageFromBookmark(const BookmarkNode* node,
GURL* url,
int* width,
int* height) {
std::string decoded(DataForMetaInfoField(node, kImageDataKey));
if (decoded == "")
return false;
ImageData data;
bool result = data.ParseFromString(decoded);
if (!result)
return false;
if (!data.has_thumbnail_info())
return false;
return PopulateImageData(data.thumbnail_info(), url, width, height);
}
std::string SnippetFromBookmark(const BookmarkNode* node) {
std::string decoded(DataForMetaInfoField(node, kPageDataKey));
if (decoded == "")
return decoded;
PageData data;
bool result = data.ParseFromString(decoded);
if (!result)
return "";
return data.snippet();
}
bool SetAllImagesForBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node,
const GURL& image_url,
int image_width,
int image_height,
const GURL& thumbnail_url,
int thumbnail_width,
int thumbnail_height) {
DCHECK(image_url.is_valid() || image_url.is_empty());
DCHECK(thumbnail_url.is_valid() || thumbnail_url.is_empty());
std::string decoded(DataForMetaInfoField(node, kImageDataKey));
ImageData data;
// Try to populate the imageData with the existing data.
if (decoded != "") {
// If the parsing fails, something is wrong. Immediately fail.
bool result = data.ParseFromString(decoded);
if (!result)
return false;
}
if (image_url.is_empty()) {
data.release_original_info();
} else {
// Regardless of whether an image info exists, we make a new one.
// Intentially make a raw pointer.
ImageData_ImageInfo* info = new ImageData_ImageInfo;
info->set_url(image_url.spec());
info->set_width(image_width);
info->set_height(image_height);
// This method consumes the raw pointer.
data.set_allocated_original_info(info);
}
if (thumbnail_url.is_empty()) {
data.release_thumbnail_info();
} else {
// Regardless of whether an image info exists, we make a new one.
// Intentially make a raw pointer.
ImageData_ImageInfo* info = new ImageData_ImageInfo;
info->set_url(thumbnail_url.spec());
info->set_width(thumbnail_width);
info->set_height(thumbnail_height);
// This method consumes the raw pointer.
data.set_allocated_thumbnail_info(info);
}
std::string output;
bool result = data.SerializePartialToString(&output);
if (!result)
return false;
std::string encoded;
base::Base64Encode(output, &encoded);
bookmark_model->SetNodeMetaInfo(node, kImageDataKey, encoded);
return true;
}
} // namespace enhanced_bookmarks
// Copyright 2014 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.
#ifndef COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
#define COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
#include <set>
#include <string>
#include <vector>
class BookmarkModel;
class BookmarkNode;
class GURL;
// The functions in this file store and retrieve structured data encoded in the
// bookmark metadata. This information suplements the data in the bookmark with
// images and descriptions related to the url.
namespace enhanced_bookmarks {
typedef std::vector<const BookmarkNode*> NodeVector;
typedef std::set<const BookmarkNode*> NodeSet;
// The keys used to store the data in the bookmarks metadata dictionary.
extern const char* kPageDataKey;
extern const char* kImageDataKey;
extern const char* kIdDataKey;
extern const char* kNoteKey;
// Returns the remoteId for a bookmark. If the bookmark doesn't have one already
// this function will create and set one.
std::string RemoteIdFromBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node);
// Sets the description of a bookmark.
void SetDescriptionForBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node,
const std::string& description);
// Returns the description of a bookmark.
std::string DescriptionFromBookmark(const BookmarkNode* node);
// Sets the URL of an image representative of the page.
// Expects the URL to be valid and not empty.
// Returns true if the metainfo is successfully populated.
bool SetOriginalImageForBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node,
const GURL& url,
int width,
int height);
// Returns the url and dimensions of the original scraped image.
// Returns true if the out variables are populated, false otherwise.
bool OriginalImageFromBookmark(const BookmarkNode* node,
GURL* url,
int* width,
int* height);
// Returns the url and dimensions of the server provided thumbnail image.
// Returns true if the out variables are populated, false otherwise.
bool ThumbnailImageFromBookmark(const BookmarkNode* node,
GURL* url,
int* width,
int* height);
// Returns a brief server provided synopsis of the bookmarked page.
// Returns the empty string if the snippet could not be extracted.
std::string SnippetFromBookmark(const BookmarkNode* node);
// Used for testing, simulates the process that creates the thumnails. Will
// remove existing entries for empty urls or set them if the url is not empty.
// expects valid or empty urls. Returns true if the metainfo is successfully
// populated.
bool SetAllImagesForBookmark(BookmarkModel* bookmark_model,
const BookmarkNode* node,
const GURL& image_url,
int image_width,
int image_height,
const GURL& thumbnail_url,
int thumbnail_width,
int thumbnail_height);
} // namespace enhanced_bookmarks
#endif // COMPONENTS_ENHANCED_BOOKMARKS_METADATA_ACCESSOR_H_
// Copyright 2014 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.
#include "components/enhanced_bookmarks/metadata_accessor.h"
#include "base/base64.h"
#include "base/strings/utf_string_conversions.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/test/test_bookmark_client.h"
#include "components/enhanced_bookmarks/proto/metadata.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
using namespace image::collections;
const std::string BOOKMARK_URL("http://example.com/index.html");
class MetadataAccessorTest : public testing::Test {
public:
MetadataAccessorTest() {}
virtual ~MetadataAccessorTest() {}
protected:
DISALLOW_COPY_AND_ASSIGN(MetadataAccessorTest);
// Adds a bookmark as the subnode at index 0 to other_node.
// |name| should be ASCII encoded.
// Returns the newly added bookmark.
const BookmarkNode* AddBookmark(BookmarkModel* model, std::string name) {
return model->AddURL(model->other_node(),
0, // index.
base::ASCIIToUTF16(name),
GURL(BOOKMARK_URL));
}
};
TEST_F(MetadataAccessorTest, TestEmptySnippet) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
std::string snippet(enhanced_bookmarks::SnippetFromBookmark(node.get()));
CHECK_EQ(snippet, "");
};
TEST_F(MetadataAccessorTest, TestSnippet) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
// Binary serialize the protobuf.
PageData data;
data.set_snippet("I'm happy!");
ASSERT_TRUE(data.IsInitialized());
std::string output;
bool result = data.SerializeToString(&output);
ASSERT_TRUE(result);
// base64 encode the output.
std::string encoded;
base::Base64Encode(output, &encoded);
node->SetMetaInfo(enhanced_bookmarks::kPageDataKey, encoded);
std::string snippet(enhanced_bookmarks::SnippetFromBookmark(node.get()));
CHECK_EQ(snippet, "I'm happy!");
};
TEST_F(MetadataAccessorTest, TestBadEncodingSnippet) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
// Binary serialize the protobuf.
PageData data;
data.set_snippet("You are happy!");
ASSERT_TRUE(data.IsInitialized());
std::string output;
bool result = data.SerializeToString(&output);
ASSERT_TRUE(result);
// don't base 64 encode the output.
node->SetMetaInfo(enhanced_bookmarks::kPageDataKey, output);
std::string snippet(enhanced_bookmarks::SnippetFromBookmark(node.get()));
CHECK_EQ(snippet, "");
};
TEST_F(MetadataAccessorTest, TestOriginalImage) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
ImageData data;
// Intentionally make raw pointer.
ImageData_ImageInfo* info = new ImageData_ImageInfo;
info->set_url("http://example.com/foobar");
info->set_width(15);
info->set_height(55);
// This method consumes the pointer.
data.set_allocated_original_info(info);
std::string output;
bool result = data.SerializePartialToString(&output);
ASSERT_TRUE(result);
// base64 encode the output.
std::string encoded;
base::Base64Encode(output, &encoded);
node->SetMetaInfo(enhanced_bookmarks::kImageDataKey, encoded);
GURL url;
int width;
int height;
result = enhanced_bookmarks::OriginalImageFromBookmark(
node.get(), &url, &width, &height);
ASSERT_TRUE(result);
CHECK_EQ(url, GURL("http://example.com/foobar"));
CHECK_EQ(width, 15);
CHECK_EQ(height, 55);
};
TEST_F(MetadataAccessorTest, TestThumbnailImage) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
ImageData data;
// Intentionally make raw pointer.
ImageData_ImageInfo* info = new ImageData_ImageInfo;
info->set_url("http://example.com/foobar");
info->set_width(15);
info->set_height(55);
// This method consumes the pointer.
data.set_allocated_thumbnail_info(info);
std::string output;
bool result = data.SerializePartialToString(&output);
ASSERT_TRUE(result);
// base64 encode the output.
std::string encoded;
base::Base64Encode(output, &encoded);
node->SetMetaInfo(enhanced_bookmarks::kImageDataKey, encoded);
GURL url;
int width;
int height;
result = enhanced_bookmarks::ThumbnailImageFromBookmark(
node.get(), &url, &width, &height);
ASSERT_TRUE(result);
CHECK_EQ(url, GURL("http://example.com/foobar"));
CHECK_EQ(width, 15);
CHECK_EQ(height, 55);
};
TEST_F(MetadataAccessorTest, TestOriginalImageMissingDimensions) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
ImageData data;
// Intentionally make raw pointer.
ImageData_ImageInfo* info = new ImageData_ImageInfo;
info->set_url("http://example.com/foobar");
// This method consumes the pointer.
data.set_allocated_original_info(info);
std::string output;
bool result = data.SerializePartialToString(&output);
ASSERT_TRUE(result);
// base64 encode the output.
std::string encoded;
base::Base64Encode(output, &encoded);
node->SetMetaInfo(enhanced_bookmarks::kImageDataKey, encoded);
GURL url;
int width;
int height;
result = enhanced_bookmarks::OriginalImageFromBookmark(
node.get(), &url, &width, &height);
ASSERT_FALSE(result);
};
TEST_F(MetadataAccessorTest, TestOriginalImageBadUrl) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
ImageData data;
// Intentionally make raw pointer.
ImageData_ImageInfo* info = new ImageData_ImageInfo;
info->set_url("asdf. 13r");
info->set_width(15);
info->set_height(55);
// This method consumes the pointer.
data.set_allocated_original_info(info);
std::string output;
bool result = data.SerializePartialToString(&output);
ASSERT_TRUE(result);
// base64 encode the output.
std::string encoded;
base::Base64Encode(output, &encoded);
node->SetMetaInfo(enhanced_bookmarks::kImageDataKey, encoded);
GURL url;
int width;
int height;
result = enhanced_bookmarks::OriginalImageFromBookmark(
node.get(), &url, &width, &height);
ASSERT_FALSE(result);
};
TEST_F(MetadataAccessorTest, TestEncodeDecode) {
test::TestBookmarkClient bookmark_client;
scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel(false));
const BookmarkNode* node =
bookmark_model->AddURL(bookmark_model->other_node(),
0, // index.
base::ASCIIToUTF16("whatever"),
GURL(BOOKMARK_URL));
bool result = enhanced_bookmarks::SetOriginalImageForBookmark(
bookmark_model.get(), node, GURL("http://example.com/i.jpg"), 22, 33);
ASSERT_TRUE(result);
GURL url;
int width;
int height;
result = enhanced_bookmarks::OriginalImageFromBookmark(
node, &url, &width, &height);
ASSERT_TRUE(result);
CHECK_EQ(url, GURL("http://example.com/i.jpg"));
CHECK_EQ(width, 22);
CHECK_EQ(height, 33);
};
TEST_F(MetadataAccessorTest, TestDoubleEncodeDecode) {
test::TestBookmarkClient bookmark_client;
scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel(false));
const BookmarkNode* node =
bookmark_model->AddURL(bookmark_model->other_node(),
0, // index.
base::ASCIIToUTF16("whatever"),
GURL(BOOKMARK_URL));
// Encode some information.
bool result = enhanced_bookmarks::SetOriginalImageForBookmark(
bookmark_model.get(), node, GURL("http://example.com/i.jpg"), 22, 33);
ASSERT_TRUE(result);
// Encode some different information.
result = enhanced_bookmarks::SetOriginalImageForBookmark(
bookmark_model.get(), node, GURL("http://example.com/i.jpg"), 33, 44);
ASSERT_TRUE(result);
GURL url;
int width;
int height;
result = enhanced_bookmarks::OriginalImageFromBookmark(
node, &url, &width, &height);
ASSERT_TRUE(result);
CHECK_EQ(url, GURL("http://example.com/i.jpg"));
CHECK_EQ(width, 33);
CHECK_EQ(height, 44);
};
TEST_F(MetadataAccessorTest, TestThumbnail) {
test::TestBookmarkClient bookmark_client;
scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel(false));
const BookmarkNode* node =
bookmark_model->AddURL(bookmark_model->other_node(),
0, // index.
base::ASCIIToUTF16("whatever"),
GURL(BOOKMARK_URL));
// Encode some information.
ASSERT_TRUE(enhanced_bookmarks::SetAllImagesForBookmark(
bookmark_model.get(),
node,
GURL(),
0,
0,
GURL("http://google.com/img/thumb.jpg"),
33,
44));
GURL url;
int width;
int height;
bool result = enhanced_bookmarks::ThumbnailImageFromBookmark(
node, &url, &width, &height);
ASSERT_TRUE(result);
CHECK_EQ(url, GURL("http://google.com/img/thumb.jpg"));
CHECK_EQ(width, 33);
CHECK_EQ(height, 44);
};
TEST_F(MetadataAccessorTest, TestRemoteId) {
test::TestBookmarkClient bookmark_client;
scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel(false));
const BookmarkNode* node = AddBookmark(bookmark_model.get(), "Aga Khan");
// First call creates the UUID, second call should return the same.
ASSERT_EQ(
enhanced_bookmarks::RemoteIdFromBookmark(bookmark_model.get(), node),
enhanced_bookmarks::RemoteIdFromBookmark(bookmark_model.get(), node));
}
TEST_F(MetadataAccessorTest, TestEmptyDescription) {
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
std::string description(
enhanced_bookmarks::DescriptionFromBookmark(node.get()));
CHECK_EQ(description, "");
}
TEST_F(MetadataAccessorTest, TestDescription) {
test::TestBookmarkClient bookmark_client;
scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel(false));
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
const std::string description("This is the most useful description of all.");
// Set the description.
enhanced_bookmarks::SetDescriptionForBookmark(
bookmark_model.get(), node.get(), description);
// Check the description is the one that was set.
CHECK_EQ(enhanced_bookmarks::DescriptionFromBookmark(node.get()),
description);
}
// If there is no notes field, the description should fall back on the snippet.
TEST_F(MetadataAccessorTest, TestDescriptionFallback) {
test::TestBookmarkClient bookmark_client;
scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel(false));
scoped_ptr<BookmarkNode> node(new BookmarkNode(GURL(BOOKMARK_URL)));
// Binary serialize the protobuf.
PageData data;
data.set_snippet("Joe Bar Team");
ASSERT_TRUE(data.IsInitialized());
std::string output;
bool result = data.SerializeToString(&output);
ASSERT_TRUE(result);
// base64 encode the output.
std::string encoded;
base::Base64Encode(output, &encoded);
node->SetMetaInfo(enhanced_bookmarks::kPageDataKey, encoded);
// The snippet is used as the description.
std::string snippet(enhanced_bookmarks::SnippetFromBookmark(node.get()));
CHECK_EQ("Joe Bar Team",
enhanced_bookmarks::DescriptionFromBookmark(node.get()));
// Set the description.
const std::string description("This is the most useful description of all.");
enhanced_bookmarks::SetDescriptionForBookmark(
bookmark_model.get(), node.get(), description);
// Check the description is the one that was set.
CHECK_EQ(enhanced_bookmarks::DescriptionFromBookmark(node.get()),
description);
}
} // namespace
// Copyright 2014 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.
//
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package image.collections;
message ImageData {
// Encrypted 64-bit image doc id, if it has been crawled,
// e.g. "kY7_4LKgNqDrbM:"
optional string doc_id = 1;
message ImageInfo {
// The (normalized) URL this image can be found at.
optional string url = 1;
// The dimensions in pixels.
optional int32 width = 2;
optional int32 height = 3;
}
// Information about the original collected image.
optional ImageInfo original_info = 2;
// Information about the server hosted thumbnail.
optional ImageInfo thumbnail_info = 3;
}
message PageData {
// The title of the web page.
optional string title = 1;
// A snippet of text from the web page, either computed by us or chosen by
// the user.
optional string snippet = 2;
// The (normalized) URL of the web page.
optional string url = 3;
// The /url redirect signed URL for the web page. This could be appended to
// "www.google.com" to create a URL redirect.
optional string signed_url = 5;
// The doc id of the page, if in the index. Uses the same encrypted docid
// format as ImageData.
optional string doc_id = 4;
}
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