Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: chrome/browser/ui/views/network_profile_bubble.h

Issue 10388239: Make NetworkProfileBubble not use BrowserList::GetLastActive() as much. Instead pass it a profile a… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_NETWORK_PROFILE_BUBBLE_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_NETWORK_PROFILE_BUBBLE_H_
6 #define CHROME_BROWSER_UI_VIEWS_NETWORK_PROFILE_BUBBLE_H_ 6 #define CHROME_BROWSER_UI_VIEWS_NETWORK_PROFILE_BUBBLE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "ui/views/bubble/bubble_delegate.h" 11 #include "ui/views/bubble/bubble_delegate.h"
12 #include "ui/views/controls/button/button.h" 12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/link_listener.h" 13 #include "ui/views/controls/link_listener.h"
14 14
15 class Browser; 15 class Browser;
16 class FilePath; 16 class FilePath;
17 class PrefService; 17 class PrefService;
18 class Profile;
19
20 namespace content {
21 class PageNavigator;
22 }
18 23
19 // This class will try to detect if the profile is on a network share and if 24 // This class will try to detect if the profile is on a network share and if
20 // this is the case notify the user with an info bubble. 25 // this is the case notify the user with an info bubble.
21 class NetworkProfileBubble : public views::BubbleDelegateView, 26 class NetworkProfileBubble : public views::BubbleDelegateView,
22 public views::ButtonListener, 27 public views::ButtonListener,
23 public views::LinkListener { 28 public views::LinkListener {
24 public: 29 public:
25 // Verifies that the profile folder is not located on a network share, and if 30 // Verifies that the profile folder is not located on a network share, and if
26 // it is shows the warning bubble to the user. 31 // it is shows the warning bubble to the user.
27 static void CheckNetworkProfile(const FilePath& profile_path); 32 static void CheckNetworkProfile(const FilePath& profile_path);
28 33
29 // Returns true if the check for network located profile should be done. This 34 // Returns true if the check for network located profile should be done. This
30 // test is only performed up to |kMaxWarnings| times in a row and then 35 // test is only performed up to |kMaxWarnings| times in a row and then
31 // repeated after a period of silence that lasts |kSilenceDurationDays| days. 36 // repeated after a period of silence that lasts |kSilenceDurationDays| days.
32 static bool ShouldCheckNetworkProfile(PrefService* prefs); 37 static bool ShouldCheckNetworkProfile(PrefService* prefs);
33 38
34 // Shows the notification bubble using the provided |browser|. 39 // Shows the notification bubble using the provided |browser|.
35 static void ShowNotification(const Browser* browser); 40 static void ShowNotification(Browser* browser);
36 41
37 private: 42 private:
38 explicit NetworkProfileBubble(views::View* anchor); 43 NetworkProfileBubble(views::View* anchor,
44 content::PageNavigator* navigator,
45 Profile* profile);
39 virtual ~NetworkProfileBubble(); 46 virtual ~NetworkProfileBubble();
40 47
41 // views::BubbleDelegateView overrides: 48 // views::BubbleDelegateView overrides:
42 virtual void Init() OVERRIDE; 49 virtual void Init() OVERRIDE;
43 virtual gfx::Rect GetAnchorRect() OVERRIDE; 50 virtual gfx::Rect GetAnchorRect() OVERRIDE;
44 51
45 // views::ButtonListener overrides: 52 // views::ButtonListener overrides:
46 virtual void ButtonPressed(views::Button* sender, 53 virtual void ButtonPressed(views::Button* sender,
47 const views::Event& event) OVERRIDE; 54 const views::Event& event) OVERRIDE;
48 55
49 // views::LinkListener overrides: 56 // views::LinkListener overrides:
50 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 57 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
51 58
52 // This function creates the notification bubble, attaches it to the 59 // This function creates the notification bubble, attaches it to the
53 // |anchor| View and then shows it to the user. 60 // |anchor| View and then shows it to the user.
54 static void NotifyNetworkProfileDetected(); 61 static void NotifyNetworkProfileDetected();
55 62
56 // Set to true once the notification check has been performed to avoid showing 63 // Set to true once the notification check has been performed to avoid showing
57 // the notification more than once per browser run. 64 // the notification more than once per browser run.
58 // This flag is not thread-safe and should only be accessed on the UI thread! 65 // This flag is not thread-safe and should only be accessed on the UI thread!
59 static bool notification_shown_; 66 static bool notification_shown_;
60 67
68 // Used for loading pages.
69 content::PageNavigator* navigator_;
70 Profile* profile_;
71
61 DISALLOW_COPY_AND_ASSIGN(NetworkProfileBubble); 72 DISALLOW_COPY_AND_ASSIGN(NetworkProfileBubble);
62 }; 73 };
63 74
64 #endif // CHROME_BROWSER_UI_VIEWS_NETWORK_PROFILE_BUBBLE_H_ 75 #endif // CHROME_BROWSER_UI_VIEWS_NETWORK_PROFILE_BUBBLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698