Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / login / ui / simple_web_view_dialog.h
blob2dcf8ed63c13c5f599d1ac0acd91fd60146165da
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_
8 #include <string>
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/command_updater_delegate.h"
11 #include "chrome/browser/ssl/security_state_model.h"
12 #include "chrome/browser/ui/toolbar/toolbar_model_delegate.h"
13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
14 #include "content/public/browser/page_navigator.h"
15 #include "content/public/browser/web_contents_delegate.h"
16 #include "ui/views/controls/button/image_button.h"
17 #include "ui/views/widget/widget_delegate.h"
18 #include "url/gurl.h"
20 class CommandUpdater;
21 class Profile;
22 class ReloadButton;
23 class ToolbarModel;
25 namespace views {
26 class WebView;
27 class Widget;
30 namespace chromeos {
32 class StubBubbleModelDelegate;
34 // View class which shows the light version of the toolbar and the web contents.
35 // Light version of the toolbar includes back, forward buttons and location
36 // bar. Location bar is shown in read only mode, because this view is designed
37 // to be used for sign in to captive portal on login screen (when Browser
38 // isn't running).
39 class SimpleWebViewDialog : public views::ButtonListener,
40 public views::WidgetDelegateView,
41 public LocationBarView::Delegate,
42 public ToolbarModelDelegate,
43 public CommandUpdaterDelegate,
44 public content::PageNavigator,
45 public content::WebContentsDelegate {
46 public:
47 explicit SimpleWebViewDialog(Profile* profile);
48 ~SimpleWebViewDialog() override;
50 // Starts loading.
51 void StartLoad(const GURL& gurl);
53 // Inits view. Should be attached to a Widget before call.
54 void Init();
56 // Overridden from views::View:
57 void Layout() override;
59 // Overridden from views::WidgetDelegate:
60 views::View* GetContentsView() override;
61 views::View* GetInitiallyFocusedView() override;
63 // Implements views::ButtonListener:
64 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
66 // Implements content::PageNavigator:
67 content::WebContents* OpenURL(const content::OpenURLParams& params) override;
69 // Implements content::WebContentsDelegate:
70 void NavigationStateChanged(content::WebContents* source,
71 content::InvalidateTypes changed_flags) override;
72 void LoadingStateChanged(content::WebContents* source,
73 bool to_different_document) override;
75 // Implements LocationBarView::Delegate:
76 content::WebContents* GetWebContents() override;
77 ToolbarModel* GetToolbarModel() override;
78 const ToolbarModel* GetToolbarModel() const override;
79 views::Widget* CreateViewsBubble(
80 views::BubbleDelegateView* bubble_delegate) override;
81 PageActionImageView* CreatePageActionImageView(
82 LocationBarView* owner,
83 ExtensionAction* action) override;
84 ContentSettingBubbleModelDelegate* GetContentSettingBubbleModelDelegate()
85 override;
86 void ShowWebsiteSettings(
87 content::WebContents* web_contents,
88 const GURL& url,
89 const SecurityStateModel::SecurityInfo& security_info) override;
91 // Implements ToolbarModelDelegate:
92 content::WebContents* GetActiveWebContents() const override;
94 // Implements CommandUpdaterDelegate:
95 void ExecuteCommandWithDisposition(int id, WindowOpenDisposition) override;
97 private:
98 friend class SimpleWebViewDialogTest;
100 void LoadImages();
101 void UpdateButtons();
102 void UpdateReload(bool is_loading, bool force);
104 Profile* profile_;
105 scoped_ptr<ToolbarModel> toolbar_model_;
106 scoped_ptr<CommandUpdater> command_updater_;
108 // Controls
109 views::ImageButton* back_;
110 views::ImageButton* forward_;
111 ReloadButton* reload_;
112 LocationBarView* location_bar_;
113 views::WebView* web_view_;
115 // Contains |web_view_| while it isn't owned by the view.
116 scoped_ptr<views::WebView> web_view_container_;
118 scoped_ptr<StubBubbleModelDelegate> bubble_model_delegate_;
120 DISALLOW_COPY_AND_ASSIGN(SimpleWebViewDialog);
123 } // namespace chromeos
125 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_SIMPLE_WEB_VIEW_DIALOG_H_