Skip to content

Commit

Permalink
Revert 144071 - Add a regenerate button to regenerate the password in…
Browse files Browse the repository at this point in the history
… Windows.

BUG=120480
TEST=Not tested.


Review URL: https://chromiumcodereview.appspot.com/10642009

TBR=zysxqn@google.com
Review URL: https://chromiumcodereview.appspot.com/10659022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144074 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jam@chromium.org committed Jun 26, 2012
1 parent 4a44f66 commit 6dba1dd
Show file tree
Hide file tree
Showing 55 changed files with 6,986 additions and 34 deletions.
5 changes: 1 addition & 4 deletions chrome/browser/ui/views/frame/browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2487,8 +2487,6 @@ void BrowserView::ShowPasswordGenerationBubble(
const gfx::Rect& rect,
autofill::PasswordGenerator* password_generator,
const webkit::forms::PasswordForm& form) {
ui::ThemeProvider* theme_provider = GetWidget()->GetThemeProvider();

// Create a rect in the content bounds that the bubble will point to.
gfx::Point origin(rect.origin());
views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin);
Expand All @@ -2507,8 +2505,7 @@ void BrowserView::ShowPasswordGenerationBubble(
tab_contents->web_contents()->GetRenderViewHost(),
password_generator,
browser_.get(),
tab_contents->password_manager(),
theme_provider);
tab_contents->password_manager());

views::BubbleDelegateView::CreateBubble(bubble);
bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR);
Expand Down
25 changes: 2 additions & 23 deletions chrome/browser/ui/views/password_generation_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
#include "content/public/browser/render_view_host.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources_standard.h"
#include "ui/base/theme_provider.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
Expand All @@ -36,19 +33,16 @@ PasswordGenerationBubbleView::PasswordGenerationBubbleView(
content::RenderViewHost* render_view_host,
autofill::PasswordGenerator* password_generator,
content::PageNavigator* navigator,
PasswordManager* password_manager,
ui::ThemeProvider* theme_provider)
PasswordManager* password_manager)
: BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_LEFT),
accept_button_(NULL),
regenerate_button_(NULL),
text_field_(NULL),
anchor_rect_(anchor_rect),
form_(form),
render_view_host_(render_view_host),
password_generator_(password_generator),
navigator_(navigator),
password_manager_(password_manager),
theme_provider_(theme_provider) {}
password_manager_(password_manager) {}

PasswordGenerationBubbleView::~PasswordGenerationBubbleView() {}

Expand All @@ -58,15 +52,6 @@ void PasswordGenerationBubbleView::Init() {
accept_button_ = new views::NativeTextButton(this,
ASCIIToUTF16("Try It"));

regenerate_button_ = new views::ImageButton(this);
regenerate_button_->SetImage(views::CustomButton::BS_NORMAL,
theme_provider_->GetImageSkiaNamed(IDR_RELOAD));
regenerate_button_->SetImage(views::CustomButton::BS_HOT,
theme_provider_->GetImageSkiaNamed(IDR_RELOAD_H));
regenerate_button_->SetImage(views::CustomButton::BS_PUSHED,
theme_provider_->GetImageSkiaNamed(IDR_RELOAD_P));
regenerate_button_->SetTooltipText(ASCIIToUTF16("Regenerate"));

text_field_ = new views::Textfield();
text_field_->SetText(
ASCIIToUTF16(password_generator_->Generate()));
Expand Down Expand Up @@ -94,8 +79,6 @@ void PasswordGenerationBubbleView::Init() {
cs = layout->AddColumnSet(1);
cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 100);
cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::FIXED,
regenerate_button_->GetPreferredSize().width(), 100);
cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing);
cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 0);
Expand All @@ -106,7 +89,6 @@ void PasswordGenerationBubbleView::Init() {

layout->StartRow(0, 1);
layout->AddView(text_field_);
layout->AddView(regenerate_button_);
layout->AddView(accept_button_);
}

Expand All @@ -121,9 +103,6 @@ void PasswordGenerationBubbleView::ButtonPressed(views::Button* sender,
render_view_host_->GetRoutingID(), text_field_->text()));
password_manager_->SetFormHasGeneratedPassword(form_);
StartFade(false);
} else if (sender == regenerate_button_) {
text_field_->SetText(
ASCIIToUTF16(password_generator_->Generate()));
}
}

Expand Down
8 changes: 1 addition & 7 deletions chrome/browser/ui/views/password_generation_bubble_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RenderViewHost;
}

namespace views {
class ImageButton;
class TextButton;
class Textfield;
}
Expand All @@ -45,8 +44,7 @@ class PasswordGenerationBubbleView : public views::BubbleDelegateView,
content::RenderViewHost* render_view_host,
autofill::PasswordGenerator* password_generator,
content::PageNavigator* navigator,
PasswordManager* password_manager,
ui::ThemeProvider* theme_provider);
PasswordManager* password_manager);
virtual ~PasswordGenerationBubbleView();

private:
Expand All @@ -66,7 +64,6 @@ class PasswordGenerationBubbleView : public views::BubbleDelegateView,

// Subviews
views::TextButton* accept_button_;
views::ImageButton* regenerate_button_;
views::Textfield* text_field_;

// Location that the bubble points to
Expand All @@ -88,9 +85,6 @@ class PasswordGenerationBubbleView : public views::BubbleDelegateView,
// PasswordManager associated with this tab.
PasswordManager* password_manager_;

// Theme provider used to draw the regenerate button.
ui::ThemeProvider* theme_provider_;

DISALLOW_COPY_AND_ASSIGN(PasswordGenerationBubbleView);
};

Expand Down
70 changes: 70 additions & 0 deletions rlz/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright (c) 2012 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.
#
# This DEPS file exists so that it can capture the dependenciez of RLZ. This
# allows external projects to check it out and build it independently from all
# of chrome.

vars = {
"chrev": "@119173"
}

deps = {
"src/base":
"http://src.chromium.org/svn/trunk/src/base" + Var("chrev"),

"src/build":
"http://src.chromium.org/svn/trunk/src/build" + Var("chrev"),

"src/third_party/icu":
"http://src.chromium.org/svn/trunk/deps/third_party/icu42" + Var("chrev"),

"src/third_party/modp_b64":
"http://src.chromium.org/svn/trunk/src/third_party/modp_b64" + Var("chrev"),

"src/third_party/nss":
"http://src.chromium.org/svn/trunk/deps/third_party/nss" + Var("chrev"),

"src/third_party/sqlite":
"http://src.chromium.org/svn/trunk/src/third_party/sqlite" + Var("chrev"),

"src/third_party/wtl":
"http://src.chromium.org/svn/trunk/src/third_party/wtl" + Var("chrev"),

"src/third_party/zlib":
"http://src.chromium.org/svn/trunk/src/third_party/zlib" + Var("chrev"),

"src/testing":
"http://src.chromium.org/svn/trunk/src/testing" + Var("chrev"),

"src/testing/gmock":
"http://googlemock.googlecode.com/svn/trunk@374",

"src/testing/gtest":
"http://googletest.googlecode.com/svn/trunk@492",

"src/tools/gyp":
"http://gyp.googlecode.com/svn/trunk@1233",

"src/tools/win":
"http://src.chromium.org/svn/trunk/src/tools/win" + Var("chrev"),

# If using rlz with chrome's networking library, add it and its dependencies
# here.
}

include_rules = [
"+build",
"+net", # This is only used when force_rlz_use_chrome_net=1 is passed to gyp.
"+third_party/zlib",
]

hooks = [
{
# A change to a .gyp, .gypi, or to GYP itself should run the generator.
"pattern": ".",
"action": ["python", "src/build/gyp_chromium", "src/rlz/rlz.gyp"],
}
]

4 changes: 4 additions & 0 deletions rlz/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set noparent
rogerta@chromium.org
gwilson@chromium.org
thakis@chromium.org
15 changes: 15 additions & 0 deletions rlz/lib/assert.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2012 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.
//
// Macros specific to the RLZ library.

#include "rlz/lib/assert.h"

namespace rlz_lib {

#ifdef MUTE_EXPECTED_ASSERTS
std::string expected_assertion_;
#endif

} // namespace rlz_lib
53 changes: 53 additions & 0 deletions rlz/lib/assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2012 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.
//
// Macros specific to the RLZ library.

#ifndef RLZ_LIB_ASSERT_H_
#define RLZ_LIB_ASSERT_H_

#include <string>
#include "base/logging.h"

// An assertion macro.
// Can mute expected assertions in debug mode.

#ifndef ASSERT_STRING
#ifndef MUTE_EXPECTED_ASSERTS
#define ASSERT_STRING(expr) LOG_IF(FATAL, false) << (expr)
#else
#define ASSERT_STRING(expr) \
do { \
std::string expr_string(expr); \
if (rlz_lib::expected_assertion_ != expr_string) { \
LOG_IF(FATAL, false) << (expr); \
} \
} while (0)
#endif
#endif


#ifndef VERIFY
#ifdef _DEBUG
#define VERIFY(expr) LOG_IF(FATAL, !(expr)) << #expr
#else
#define VERIFY(expr) (void)(expr)
#endif
#endif

namespace rlz_lib {

#ifdef MUTE_EXPECTED_ASSERTS
extern std::string expected_assertion_;
#endif

inline void SetExpectedAssertion(const char* s) {
#ifdef MUTE_EXPECTED_ASSERTS
expected_assertion_ = s;
#endif
}

} // rlz_lib

#endif // RLZ_LIB_ASSERT_H_
17 changes: 17 additions & 0 deletions rlz/lib/crc32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2012 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.
//
// A wrapper around ZLib's CRC function.

#ifndef RLZ_LIB_CRC32_H_
#define RLZ_LIB_CRC32_H_

namespace rlz_lib {

int Crc32(const unsigned char* buf, int length);
bool Crc32(const char* text, int* crc);

} // namespace rlz_lib

#endif // RLZ_LIB_CRC32_H_
52 changes: 52 additions & 0 deletions rlz/lib/crc32_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2012 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.
//
// A test for ZLib's checksum function.

#include "rlz/lib/crc32.h"

#include "base/logging.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

TEST(Crc32Unittest, ByteTest) {
struct {
const char* data;
int len;
// Externally calculated at http://crc32-checksum.waraxe.us/
int crc;
} kData[] = {
{"Hello" , 5, 0xF7D18982},
{"Google" , 6, 0x62B0F067},
{"" , 0, 0x0},
{"One more string.", 16, 0x0CA14970},
{NULL , 0, 0x0},
};

for (int i = 0; kData[i].data; i++)
EXPECT_EQ(kData[i].crc,
rlz_lib::Crc32(reinterpret_cast<const unsigned char*>(kData[i].data),
kData[i].len));
}

TEST(Crc32Unittest, CharTest) {
struct {
const char* data;
// Externally calculated at http://crc32-checksum.waraxe.us/
int crc;
} kData[] = {
{"Hello" , 0xF7D18982},
{"Google" , 0x62B0F067},
{"" , 0x0},
{"One more string.", 0x0CA14970},
{"Google\r\n" , 0x83A3E860},
{NULL , 0x0},
};

int crc;
for (int i = 0; kData[i].data; i++) {
EXPECT_TRUE(rlz_lib::Crc32(kData[i].data, &crc));
EXPECT_EQ(kData[i].crc, crc);
}
}
36 changes: 36 additions & 0 deletions rlz/lib/crc32_wrapper.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2012 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.
//
// A wrapper around ZLib's CRC functions to put them in the rlz_lib namespace
// and use our types.

#include "rlz/lib/assert.h"
#include "rlz/lib/crc32.h"
#include "rlz/lib/string_utils.h"
#include "third_party/zlib/zlib.h"

namespace rlz_lib {

int Crc32(const unsigned char* buf, int length) {
return crc32(0L, buf, length);
}

bool Crc32(const char* text, int* crc) {
if (!crc) {
ASSERT_STRING("Crc32: crc is NULL.");
return false;
}

*crc = 0;
for (int i = 0; text[i]; i++) {
if (!IsAscii(text[i]))
return false;

*crc = crc32(*crc, reinterpret_cast<const unsigned char*>(text + i), 1);
}

return true;
}

} // namespace rlz_lib
Loading

0 comments on commit 6dba1dd

Please sign in to comment.