summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 21:26:13 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 21:26:13 +0000
commit8ebd02bc2e0b778418c06060d990fc6ceda21b5a (patch)
tree653dba7a527bb1ef22ce401eef8788f2ac35d844 /chrome/browser/views
parent0a9fe25653daa90f09eb7ff5b8309ccc70c20537 (diff)
downloadchromium_src-8ebd02bc2e0b778418c06060d990fc6ceda21b5a.zip
chromium_src-8ebd02bc2e0b778418c06060d990fc6ceda21b5a.tar.gz
chromium_src-8ebd02bc2e0b778418c06060d990fc6ceda21b5a.tar.bz2
Gets LocationBarView to compile on linux. PageInfoWindow is nearly
there too, but needs Separator to actually completely compile. BUG=none TEST=none Review URL: http://codereview.chromium.org/113720 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/first_run_bubble.h5
-rw-r--r--chrome/browser/views/location_bar_view.cc110
-rw-r--r--chrome/browser/views/location_bar_view.h27
-rw-r--r--chrome/browser/views/page_info_window.cc48
-rw-r--r--chrome/browser/views/page_info_window.h10
5 files changed, 136 insertions, 64 deletions
diff --git a/chrome/browser/views/first_run_bubble.h b/chrome/browser/views/first_run_bubble.h
index 8da8d04..e3c7024 100644
--- a/chrome/browser/views/first_run_bubble.h
+++ b/chrome/browser/views/first_run_bubble.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H_
#define CHROME_BROWSER_VIEWS_FIRST_RUN_BUBBLE_H_
+#include "base/compiler_specific.h"
#include "base/task.h"
#include "chrome/browser/views/info_bubble.h"
@@ -19,8 +20,8 @@ class FirstRunBubble : public InfoBubble,
bool use_OEM_bubble);
FirstRunBubble()
- : enable_window_method_factory_(this),
- has_been_activated_(false),
+ : has_been_activated_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(enable_window_method_factory_(this)),
view_(NULL) {
}
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index a2331f2..d9cc354 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -8,7 +8,6 @@
#include "app/gfx/favicon_size.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "app/win_util.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/string_util.h"
@@ -29,26 +28,28 @@
#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/info_bubble.h"
#include "chrome/browser/views/first_run_bubble.h"
-#include "chrome/browser/views/page_info_window.h"
#include "chrome/common/page_action.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "skia/ext/image_operations.h"
-#include "views/background.h"
-#include "views/border.h"
#include "views/focus/focus_manager.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
#include "webkit/glue/image_decoder.h"
+#if defined(OS_WIN)
+#include "app/win_util.h"
+#include "chrome/browser/views/page_info_window.h"
+#endif
+
using views::View;
const int LocationBarView::kVertMargin = 2;
-const COLORREF LocationBarView::kBackgroundColorByLevel[] = {
- RGB(255, 245, 195), // SecurityLevel SECURE: Yellow.
- RGB(255, 255, 255), // SecurityLevel NORMAL: White.
- RGB(255, 255, 255), // SecurityLevel INSECURE: White.
+const SkColor LocationBarView::kBackgroundColorByLevel[] = {
+ SkColorSetRGB(255, 245, 195), // SecurityLevel SECURE: Yellow.
+ SkColorSetRGB(255, 255, 255), // SecurityLevel NORMAL: White.
+ SkColorSetRGB(255, 255, 255), // SecurityLevel INSECURE: White.
};
// Padding on the right and left of the entry field.
@@ -129,29 +130,44 @@ void LocationBarView::Init() {
}
// URL edit field.
+ // View container for URL edit field.
+#if defined(OS_WIN)
views::Widget* widget = GetWidget();
location_entry_.reset(new AutocompleteEditViewWin(font_, this, model_, this,
widget->GetNativeView(),
profile_, command_updater_,
popup_window_mode_,
popup_positioner_));
-
- // View container for URL edit field.
location_entry_view_ = new views::HWNDView;
+#else
+ location_entry_.reset(new AutocompleteEditViewGtk(this, model_, profile_,
+ command_updater_,
+ popup_positioner_));
+ location_entry_view_ = new views::NativeViewHostGtk;
+#endif
DCHECK(location_entry_view_) << "LocationBarView::Init - OOM!";
location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE);
AddChildView(location_entry_view_);
location_entry_view_->SetAssociatedFocusView(this);
+#if defined(OS_WIN)
location_entry_view_->Attach(location_entry_->m_hWnd);
+#else
+ location_entry_view_->Attach(location_entry_->widget());
+#endif
AddChildView(&selected_keyword_view_);
selected_keyword_view_.SetFont(font_);
selected_keyword_view_.SetVisible(false);
selected_keyword_view_.SetParentOwned(false);
+#if defined(OS_WIN)
DWORD sys_color = GetSysColor(COLOR_GRAYTEXT);
SkColor gray = SkColorSetRGB(GetRValue(sys_color), GetGValue(sys_color),
GetBValue(sys_color));
+#else
+ NOTIMPLEMENTED();
+ SkColor gray = SK_ColorGRAY;
+#endif
AddChildView(&type_to_search_view_);
type_to_search_view_.SetVisible(false);
@@ -204,7 +220,11 @@ void LocationBarView::UpdatePageActions() {
}
void LocationBarView::Focus() {
+#if defined(OS_WIN)
::SetFocus(location_entry_->m_hWnd);
+#else
+ gtk_widget_grab_focus(location_entry_->widget());
+#endif
}
void LocationBarView::SetProfile(Profile* profile) {
@@ -230,10 +250,7 @@ void LocationBarView::Layout() {
void LocationBarView::Paint(gfx::Canvas* canvas) {
View::Paint(canvas);
- SkColor bg = SkColorSetRGB(
- GetRValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]),
- GetGValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]),
- GetBValue(kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()]));
+ SkColor bg = kBackgroundColorByLevel[model_->GetSchemeSecurityLevel()];
const SkBitmap* background =
popup_window_mode_ ? kPopupBackground : kBackground;
@@ -247,6 +264,7 @@ void LocationBarView::VisibleBoundsInRootChanged() {
location_entry_->ClosePopup();
}
+#if defined(OS_WIN)
bool LocationBarView::OnMousePressed(const views::MouseEvent& event) {
UINT msg;
if (event.IsLeftMouseButton()) {
@@ -288,6 +306,7 @@ void LocationBarView::OnMouseReleased(const views::MouseEvent& event,
}
OnMouseEvent(event, msg);
}
+#endif
void LocationBarView::OnAutocompleteAccept(
const GURL& url,
@@ -344,11 +363,6 @@ void LocationBarView::DoLayout(const bool force_layout) {
if (!location_entry_.get())
return;
- RECT formatting_rect;
- location_entry_->GetRect(&formatting_rect);
- RECT edit_bounds;
- location_entry_->GetClientRect(&edit_bounds);
-
int entry_width = width() - (kEntryPadding * 2);
gfx::Size page_action_size;
@@ -370,8 +384,17 @@ void LocationBarView::DoLayout(const bool force_layout) {
entry_width -= (info_label_size.width() + kInnerPadding);
}
- const int max_edit_width = entry_width - formatting_rect.left -
- (edit_bounds.right - formatting_rect.right);
+#if defined(OS_WIN)
+ RECT formatting_rect;
+ location_entry_->GetRect(&formatting_rect);
+ RECT edit_bounds;
+ location_entry_->GetClientRect(&edit_bounds);
+ int max_edit_width = entry_width - formatting_rect.left -
+ (edit_bounds.right - formatting_rect.right);
+#else
+ int max_edit_width = entry_width;
+#endif
+
if (max_edit_width < 0)
return;
const int text_width = TextDisplayWidth();
@@ -435,12 +458,17 @@ int LocationBarView::TopMargin() const {
}
int LocationBarView::TextDisplayWidth() {
+#if defined(OS_WIN)
POINT last_char_position =
location_entry_->PosFromChar(location_entry_->GetTextLength());
POINT scroll_position;
location_entry_->GetScrollPos(&scroll_position);
const int position_x = last_char_position.x + scroll_position.x;
return UILayoutIsRightToLeft() ? width() - position_x : position_x;
+#else
+ NOTIMPLEMENTED();
+ return 0;
+#endif
}
bool LocationBarView::UsePref(int pref_width, int text_width, int max_width) {
@@ -585,7 +613,7 @@ void LocationBarView::RefreshPageActionViews() {
TabContents* contents = delegate_->GetTabContents();
if (!page_action_image_views_.empty() && contents) {
- GURL url = GURL(model_->GetText());
+ GURL url = GURL(WideToUTF8(model_->GetText()));
for (size_t i = 0; i < page_action_image_views_.size(); i++)
page_action_image_views_[i]->UpdateVisibility(contents, url);
@@ -610,6 +638,7 @@ bool LocationBarView::ToggleVisibility(bool new_vis, View* view) {
return false;
}
+#if defined(OS_WIN)
void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) {
UINT flags = 0;
if (event.IsControlDown())
@@ -628,6 +657,7 @@ void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) {
location_entry_->HandleExternalMsg(msg, flags, screen_point.ToPOINT());
}
+#endif
bool LocationBarView::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role);
@@ -858,6 +888,7 @@ bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
return true;
}
+#if defined(OS_WIN)
int c = e.GetCharacter();
// We don't process ALT + numpad digit as accelerators, they are used for
// entering special characters.
@@ -894,6 +925,10 @@ bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
default:
return false;
}
+#else
+ NOTIMPLEMENTED();
+ return false;
+#endif
}
// ShowInfoBubbleTask-----------------------------------------------------------
@@ -914,8 +949,8 @@ class LocationBarView::ShowInfoBubbleTask : public Task {
LocationBarView::ShowInfoBubbleTask::ShowInfoBubbleTask(
LocationBarView::LocationBarImageView* image_view)
- : cancelled_(false),
- image_view_(image_view) {
+ : image_view_(image_view),
+ cancelled_(false) {
}
void LocationBarView::ShowInfoBubbleTask::Run() {
@@ -973,8 +1008,8 @@ void LocationBarView::ShowFirstRunBubbleInternal(bool use_OEM_bubble) {
// LocationBarImageView---------------------------------------------------------
LocationBarView::LocationBarImageView::LocationBarImageView()
- : show_info_bubble_task_(NULL),
- info_bubble_(NULL) {
+ : info_bubble_(NULL),
+ show_info_bubble_task_(NULL) {
}
LocationBarView::LocationBarImageView::~LocationBarImageView() {
@@ -1084,10 +1119,14 @@ bool LocationBarView::SecurityImageView::OnMousePressed(
NOTREACHED();
return true;
}
+#if defined(OS_WIN)
PageInfoWindow::CreatePageInfo(profile_,
nav_entry,
GetRootView()->GetWidget()->GetNativeView(),
PageInfoWindow::SECURITY);
+#else
+ NOTIMPLEMENTED();
+#endif
return true;
}
@@ -1139,8 +1178,8 @@ class LocationBarView::PageActionImageView::LoadImageTask : public Task {
LoadImageTask(ImageLoadingTracker* tracker,
const FilePath& path)
: callback_loop_(MessageLoop::current()),
- path_(path),
- tracker_(tracker) {}
+ tracker_(tracker),
+ path_(path) {}
void ReportBack(SkBitmap* image) {
DCHECK(image);
@@ -1197,11 +1236,11 @@ LocationBarView::PageActionImageView::PageActionImageView(
LocationBarView* owner,
Profile* profile,
const PageAction* page_action)
- : owner_(owner),
- profile_(profile),
- page_action_(page_action),
- tracker_(new ImageLoadingTracker(this)),
- LocationBarImageView() {
+ : LocationBarImageView(),
+ owner_(owner),
+ profile_(profile),
+ page_action_(page_action),
+ tracker_(new ImageLoadingTracker(this)) {
// Load the images this view needs asynchronously on the file thread. We'll
// get a call back into OnImageLoaded if the image loads successfully. If not,
// the ImageView will have no image and will not appear in the Omnibox.
@@ -1248,7 +1287,12 @@ void LocationBarView::PageActionImageView::OnImageLoaded(SkBitmap* image) {
bool LocationBarView::OverrideAccelerator(
const views::Accelerator& accelerator) {
+#if defined(OS_WIN)
return location_entry_->OverrideAccelerator(accelerator);
+#else
+ NOTIMPLEMENTED();
+ return false;
+#endif
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index f80146f..ff52a43 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -11,16 +11,22 @@
#include "app/gfx/font.h"
#include "base/gfx/rect.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
-#include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
#include "chrome/browser/location_bar.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/toolbar_model.h"
#include "chrome/browser/views/info_bubble.h"
-#include "views/controls/hwnd_view.h"
#include "views/controls/image_view.h"
#include "views/controls/label.h"
#include "views/painter.h"
+#if defined(OS_WIN)
+#include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
+#include "views/controls/hwnd_view.h"
+#else
+#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
+#include "views/controls/native_view_host_gtk.h"
+#endif
+
class AutocompletePopupPositioner;
class CommandUpdater;
class GURL;
@@ -86,10 +92,13 @@ class LocationBarView : public LocationBar,
// to close its popup.
virtual void VisibleBoundsInRootChanged();
+
+#if defined(OS_WIN)
// Event Handlers
virtual bool OnMousePressed(const views::MouseEvent& event);
virtual bool OnMouseDragged(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+#endif
// AutocompleteEditController
virtual void OnAutocompleteAccept(const GURL& url,
@@ -126,7 +135,7 @@ class LocationBarView : public LocationBar,
}
static const int kVertMargin;
- static const COLORREF kBackgroundColorByLevel[];
+ static const SkColor kBackgroundColorByLevel[];
protected:
void Focus();
@@ -400,7 +409,7 @@ class LocationBarView : public LocationBar,
// Retrieves a vector of all page actions, irrespective of which
// extension they belong to.
- std::vector<PageAction*> LocationBarView::GetPageActions();
+ std::vector<PageAction*> GetPageActions();
// Update the views for the Page Actions, to reflect state changes for
// PageActions.
@@ -417,8 +426,10 @@ class LocationBarView : public LocationBar,
// changed.
bool ToggleVisibility(bool new_vis, views::View* view);
+#if defined(OS_WIN)
// Helper for the Mouse event handlers that does all the real work.
void OnMouseEvent(const views::MouseEvent& event, UINT msg);
+#endif
// Helper to show the first run info bubble.
void ShowFirstRunBubbleInternal(bool use_OEM_bubble);
@@ -427,7 +438,11 @@ class LocationBarView : public LocationBar,
Profile* profile_;
// The Autocomplete Edit field.
+#if defined(OS_WIN)
scoped_ptr<AutocompleteEditViewWin> location_entry_;
+#else
+ scoped_ptr<AutocompleteEditViewGtk> location_entry_;
+#endif
// The CommandUpdater for the Browser object that corresponds to this View.
CommandUpdater* command_updater_;
@@ -452,7 +467,11 @@ class LocationBarView : public LocationBar,
gfx::Font font_;
// Location_entry view wrapper
+#if defined(OS_WIN)
views::HWNDView* location_entry_view_;
+#else
+ views::NativeViewHostGtk* location_entry_view_;
+#endif
// The following views are used to provide hints and remind the user as to
// what is going in the edit. They are all added a children of the
diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc
index c92325b..d05aabb 100644
--- a/chrome/browser/views/page_info_window.cc
+++ b/chrome/browser/views/page_info_window.cc
@@ -4,16 +4,13 @@
#include "chrome/browser/views/page_info_window.h"
+#if defined(OS_WIN)
#include <cryptuiapi.h>
#pragma comment(lib, "cryptui.lib")
-
-#include <atlbase.h>
-#include <atlapp.h>
-#include <atlmisc.h>
+#endif
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "app/win_util.h"
#include "base/string_util.h"
#include "base/time_format.h"
#include "chrome/browser/browser_process.h"
@@ -37,6 +34,10 @@
#include "views/controls/separator.h"
#include "views/standard_layout.h"
+#if defined(OS_WIN)
+#include "app/win_util.h"
+#endif
+
using base::Time;
const int kVerticalPadding = 10;
@@ -560,9 +561,8 @@ void PageInfoWindow::Init(Profile* profile,
gfx::Rect bounds;
bool maximized = false;
if (GetSavedWindowBounds(&bounds) && GetSavedMaximizedState(&maximized)) {
- CRect bounds_crect(bounds.ToRECT());
- CalculateWindowBounds(&bounds_crect);
- SaveWindowPlacement(gfx::Rect(bounds_crect), maximized);
+ CalculateWindowBounds(&bounds);
+ SaveWindowPlacement(bounds, maximized);
}
}
@@ -625,42 +625,49 @@ void PageInfoWindow::ButtonPressed(views::Button* sender) {
}
}
-void PageInfoWindow::CalculateWindowBounds(CRect* bounds) {
+void PageInfoWindow::CalculateWindowBounds(gfx::Rect* bounds) {
const int kDefaultOffset = 15;
- gfx::Rect window_bounds(*bounds);
- gfx::Rect monitor_bounds(win_util::GetMonitorBoundsForRect(window_bounds));
+#if defined(OS_WIN)
+ gfx::Rect monitor_bounds(win_util::GetMonitorBoundsForRect(*bounds));
+#else
+ gfx::Rect monitor_bounds;
+ NOTIMPLEMENTED();
+#endif
+
+ if (monitor_bounds.IsEmpty())
+ return;
// If necessary, move the window so it is visible on the screen.
- gfx::Rect adjusted_bounds = window_bounds.AdjustToFit(monitor_bounds);
- if (adjusted_bounds != window_bounds) {
+ gfx::Rect adjusted_bounds = bounds->AdjustToFit(monitor_bounds);
+ if (adjusted_bounds != *bounds) {
// The bounds have moved, we are done.
- RECT rect = adjusted_bounds.ToRECT();
- bounds->CopyRect(&rect);
+ *bounds = adjusted_bounds;
return;
}
// Move the window from its specified position, trying to keep it entirely
// visible.
int x_offset, y_offset;
- if (window_bounds.right() + kDefaultOffset >= monitor_bounds.right() &&
- abs(monitor_bounds.x() - window_bounds.x()) >= kDefaultOffset) {
+ if (bounds->right() + kDefaultOffset >= monitor_bounds.right() &&
+ abs(monitor_bounds.x() - bounds->x()) >= kDefaultOffset) {
x_offset = -kDefaultOffset;
} else {
x_offset = kDefaultOffset;
}
- if (window_bounds.bottom() + kDefaultOffset >= monitor_bounds.bottom() &&
- abs(monitor_bounds.y() - window_bounds.y()) >= kDefaultOffset) {
+ if (bounds->bottom() + kDefaultOffset >= monitor_bounds.bottom() &&
+ abs(monitor_bounds.y() - bounds->y()) >= kDefaultOffset) {
y_offset = -kDefaultOffset;
} else {
y_offset = kDefaultOffset;
}
- bounds->OffsetRect(x_offset, y_offset);
+ bounds->Offset(x_offset, y_offset);
}
void PageInfoWindow::ShowCertDialog(int cert_id) {
+#if defined(OS_WIN)
scoped_refptr<net::X509Certificate> cert;
CertStore::GetSharedInstance()->RetrieveCert(cert_id, &cert);
if (!cert.get()) {
@@ -686,4 +693,5 @@ void PageInfoWindow::ShowCertDialog(int cert_id) {
// This next call blocks but keeps processing windows messages, making it
// modal to the browser window.
BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed);
+#endif
}
diff --git a/chrome/browser/views/page_info_window.h b/chrome/browser/views/page_info_window.h
index 6a27558..a7d1ca1 100644
--- a/chrome/browser/views/page_info_window.h
+++ b/chrome/browser/views/page_info_window.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H__
-#define CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H__
+#ifndef CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H_
+#define CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H_
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "googleurl/src/gurl.h"
@@ -82,7 +82,7 @@ class PageInfoWindow : public views::DialogDelegate,
// Offsets the specified rectangle so it is showing on the screen and shifted
// from its original location.
- void CalculateWindowBounds(CRect* bounds);
+ void CalculateWindowBounds(gfx::Rect* bounds);
// Shows various information for the specified certificate in a new dialog.
void ShowCertDialog(int cert_id);
@@ -98,7 +98,7 @@ class PageInfoWindow : public views::DialogDelegate,
// A counter of how many page info windows are currently opened.
static int opened_window_count_;
- DISALLOW_EVIL_CONSTRUCTORS(PageInfoWindow);
+ DISALLOW_COPY_AND_ASSIGN(PageInfoWindow);
};
-#endif // #define CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H__
+#endif // #define CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H_