1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UI_SIMPLE_WEB_VIEW_DIALOG_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UI_SIMPLE_WEB_VIEW_DIALOG_H_
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/command_updater_delegate.h"
11 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
13 #include "content/public/browser/page_navigator.h"
14 #include "content/public/browser/web_contents_delegate.h"
15 #include "ui/views/controls/button/image_button.h"
16 #include "ui/views/widget/widget_delegate.h"
31 class StubBubbleModelDelegate;
33 // View class which shows the light version of the toolbar and the web contents.
34 // Light version of the toolbar includes back, forward buttons and location
35 // bar. Location bar is shown in read only mode, because this view is designed
36 // to be used for sign in to captive portal on login screen (when Browser
38 class SimpleWebViewDialog : public views::ButtonListener,
39 public views::WidgetDelegateView,
40 public LocationBarView::Delegate,
41 public ToolbarModelDelegate,
42 public CommandUpdaterDelegate,
43 public content::PageNavigator,
44 public content::WebContentsDelegate {
46 explicit SimpleWebViewDialog(Profile* profile);
47 virtual ~SimpleWebViewDialog();
50 void StartLoad(const GURL& gurl);
52 // Inits view. Should be attached to a Widget before call.
55 // Overridden from views::View:
56 virtual void Layout() override;
58 // Overridden from views::WidgetDelegate:
59 virtual views::View* GetContentsView() override;
60 virtual views::View* GetInitiallyFocusedView() override;
62 // Implements views::ButtonListener:
63 virtual void ButtonPressed(views::Button* sender,
64 const ui::Event& event) override;
66 // Implements content::PageNavigator:
67 virtual content::WebContents* OpenURL(
68 const content::OpenURLParams& params) override;
70 // Implements content::WebContentsDelegate:
71 virtual void NavigationStateChanged(
72 const content::WebContents* source,
73 content::InvalidateTypes changed_flags) override;
74 virtual void LoadingStateChanged(content::WebContents* source,
75 bool to_different_document) override;
77 // Implements LocationBarView::Delegate:
78 virtual content::WebContents* GetWebContents() override;
79 virtual ToolbarModel* GetToolbarModel() override;
80 virtual const ToolbarModel* GetToolbarModel() const override;
81 virtual InstantController* GetInstant() override;
82 virtual views::Widget* CreateViewsBubble(
83 views::BubbleDelegateView* bubble_delegate) override;
84 virtual PageActionImageView* CreatePageActionImageView(
85 LocationBarView* owner,
86 ExtensionAction* action) override;
87 virtual ContentSettingBubbleModelDelegate*
88 GetContentSettingBubbleModelDelegate() override;
89 virtual void ShowWebsiteSettings(content::WebContents* web_contents,
91 const content::SSLStatus& ssl) override;
93 // Implements ToolbarModelDelegate:
94 virtual content::WebContents* GetActiveWebContents() const override;
95 virtual bool InTabbedBrowser() const override;
97 // Implements CommandUpdaterDelegate:
98 virtual void ExecuteCommandWithDisposition(
100 WindowOpenDisposition) override;
103 friend class SimpleWebViewDialogTest;
106 void UpdateButtons();
107 void UpdateReload(bool is_loading, bool force);
110 scoped_ptr<ToolbarModel> toolbar_model_;
111 scoped_ptr<CommandUpdater> command_updater_;
114 views::ImageButton* back_;
115 views::ImageButton* forward_;
116 ReloadButton* reload_;
117 LocationBarView* location_bar_;
118 views::WebView* web_view_;
120 // Contains |web_view_| while it isn't owned by the view.
121 scoped_ptr<views::WebView> web_view_container_;
123 scoped_ptr<StubBubbleModelDelegate> bubble_model_delegate_;
125 DISALLOW_COPY_AND_ASSIGN(SimpleWebViewDialog);
128 } // namespace chromeos
130 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_SIMPLE_WEB_VIEW_DIALOG_H_